10000 docs: docstrings for Server and ServerInfo (#1494) · LehmD/server-client-python@f8728b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f8728b2

Browse files
authored
docs: docstrings for Server and ServerInfo (tableau#1494)
Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 0efd735 commit f8728b2

File tree

3 files changed

+116
-3
lines changed

3 files changed

+116
-3
lines changed

tableauserverclient/models/server_info_item.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77

88

99
class ServerInfoItem:
10+
"""
11+
The ServerInfoItem class contains the build and version information for
12+
Tableau Server. The server information is accessed with the
13+
server_info.get() method, which returns an instance of the ServerInfo class.
14+
15+
Attributes
16+
----------
17+
product_version : str
18+
Shows the version of the Tableau Server or Tableau Cloud
19+
(for example, 10.2.0).
20+
21+
build_number : str
22+
Shows the specific build number (for example, 10200.17.0329.1446).
23+
24+
rest_api_version : str
25+
Shows the supported REST API version number. Note that this might be
26+
different from the default value specified for the server, with the
27+
Server.version attribute. To take advantage of new features, you should
28+
query the server and set the Server.version to match the supported REST
29+
API version number.
30+
"""
31+
1032
def __init__(self, product_version, build_number, rest_api_version):
1133
self._product_version = product_version
1234
self._build_number = build_number

tableauserverclient/server/endpoint/server_info_endpoint.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from typing import Union
23

34
from .endpoint import Endpoint, api
45
from .exceptions import ServerResponseError
@@ -24,12 +25,46 @@ def __repr__(self):
2425
return f"<Endpoint {self.serverInfo}>"
2526

2627
@property
27-
def baseurl(self):
28+
def baseurl(self) -> str:
2829
return f"{self.parent_srv.baseurl}/serverInfo"
2930

3031
@api(version="2.4")
31-
def get(self):
32-
"""Retrieve the server info for the server. This is an unauthenticated call"""
32+
def get(self) -> Union[ServerInfoItem, None]:
33+
"""
34+
Retrieve the build and version information for the server.
35+
36+
This method makes an unauthenticated call, so no sign in or
37+
authentication token is required.
38+
39+
Returns
40+
-------
41+
:class:`~tableauserverclient.models.ServerInfoItem`
42+
43+
Raises
44+
------
45+
:class:`~tableauserverclient.exceptions.ServerInfoEndpointNotFoundError`
46+
Raised when the server info endpoint is not found.
47+
48+
:class:`~tableauserverclient.exceptions.EndpointUnavailableError`
49+
Raised when the server info endpoint is not available.
50+
51+
Examples
52+
--------
53+
>>> import tableauserverclient as TSC
54+
55+
>>> # create a instance of server
56+
>>> server = TSC.Server('https://MY-SERVER')
57+
58+
>>> # set the version number > 2.3
59+
>>> # the server_info.get() method works in 2.4 and later
60+
>>> server.version = '2.5'
61+
62+
>>> s_info = server.server_info.get()
63+
>>> print("\nServer info:")
64+
>>> print("\tProduct version: {0}".format(s_info.product_version))
65+
>>> print("\tREST API version: {0}".format(s_info.rest_api_version))
66+
>>> print("\tBuild number: {0}".format(s_info.build_number))
67+
"""
3368
try:
3469
server_response = self.get_unauthenticated_request(self.baseurl)
3570
except ServerResponseError as e:

tableauserverclient/server/server.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,63 @@
5959

6060

6161
class Server:
62+
"""
63+
In the Tableau REST API, the server (https://MY-SERVER/) is the base or core
64+
of the URI that makes up the various endpoints or methods for accessing
65+
resources on the server (views, workbooks, sites, users, data sources, etc.)
66+
The TSC library provides a Server class that represents the server. You
67+
create a server instance to sign in to the server and to call the various
68+
methods for accessing resources.
69+
70+
The Server class contains the attributes that represent the server on
71+
Tableau Server. After you create an instance of the Server class, you can
72+
sign in to the server and call methods to access all of the resources on the
73+
server.
74+
75+
Parameters
76+
----------
77+
server_address : str
78+
Specifies the address of the Tableau Server or Tableau Cloud (for
79+
example, https://MY-SERVER/).
80+
81+
use_server_version : bool
82+
Specifies the version of the REST API to use (for example, '2.5'). When
83+
you use the TSC library to call methods that access Tableau Server, the
84+
version is passed to the endpoint as part of the URI
85+
(https://MY-SERVER/api/2.5/). Each release of Tableau Server supports
86+
specific versions of the REST API. New versions of the REST API are
87+
released with Tableau Server. By default, the value of version is set to
88+
'2.3', which corresponds to Tableau Server 10.0. You can view or set
89+
this value. You might need to set this to a different value, for
90+
example, if you want to access features that are supported by the server
91+
and a later version of the REST API. For more information, see REST API
92+
Versions.
93+
94+
Examples
95+
--------
96+
>>> import tableauserverclient as TSC
97+
98+
>>> # create a instance of server
99+
>>> server = TSC.Server('https://MY-SERVER')
100+
101+
>>> # sign in, etc.
102+
103+
>>> # change the REST API version to match the server
104+
>>> server.use_server_version()
105+
106+
>>> # or change the REST API version to match a specific version
107+
>>> # for example, 2.8
108+
>>> # server.version = '2.8'
109+
110+
"""
111+
62112
class PublishMode:
113+
"""
114+
Enumerates the options that specify what happens when you publish a
115+
workbook or data source. The options are Overwrite, Append, or
116+
CreateNew.
117+
"""
118+
63119
Append = "Append"
64120
Overwrite = "Overwrite"
65121
CreateNew = "CreateNew"

0 commit comments

Comments
 (0)
0