8000 0.26 logging updates, long running uploads (#1222) · LehmD/server-client-python@307d8a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 307d8a2

Browse files
jacalatama7tcsp
andauthored
0.26 logging updates, long running uploads (tableau#1222)
TableauIDWithMFA added to the user_item model to allow creating users on Tableau Cloud with MFA enabled (tableau#1217) Run long requests on second thread (tableau#1212) tableau#1210 tableau#1087 tableau#1058 tableau#456 tableau#1209 update datasource to use bridge (tableau#1224) Co-authored-by: Tim Payne <47423639+ma7tcsp@users.noreply.github.com>
1 parent cc62a50 commit 307d8a2
  • tableauserverclient
  • test
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    81 files changed

    +401
    -333
    lines changed

    .gitignore

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -84,6 +84,7 @@ celerybeat-schedule
    8484

    8585
    # dotenv
    8686
    .env
    87+
    env.py
    8788

    8889
    # virtualenv
    8990
    venv/

    samples/add_default_permission.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -18,14 +18,10 @@
    1818
    def main():
    1919
    parser = argparse.ArgumentParser(description="Add workbook default permissions for a given project.")
    2020
    # Common options; please keep those in sync across all samples
    21-
    parser.add_argument("--server", "-s", required=True, help="server address")
    21+
    parser.add_argument("--server", "-s", help="server address")
    2222
    parser.add_argument("--site", "-S", help="site name")
    23-
    parser.add_argument(
    24-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    25-
    )
    26-
    parser.add_argument(
    27-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    28-
    )
    23+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    24+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2925
    parser.add_argument(
    3026
    "--logging-level",
    3127
    "-l",

    samples/create_group.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -20,14 +20,10 @@
    2020
    def main():
    2121
    parser = argparse.ArgumentParser(description="Creates a sample user group.")
    2222
    # Common options; please keep those in sync across all samples
    23-
    parser.add_argument("--server", "-s", required=True, help="server address")
    23+
    parser.add_argument("--server", "-s", help="server address")
    2424
    parser.add_argument("--site", "-S", help="site name")
    25-
    parser.add_argument(
    26-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    27-
    )
    28-
    parser.add_argument(
    29-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    30-
    )
    25+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    26+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    3127
    parser.add_argument(
    3228
    "--logging-level",
    3329
    "-l",

    samples/create_project.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -28,14 +28,10 @@ def create_project(server, project_item, samples=False):
    2828
    def main():
    2929
    parser = argparse.ArgumentParser(description="Create new projects.")
    3030
    # Common options; please keep those in sync across all samples
    31-
    parser.add_argument("--server", "-s", required=True, help="server address")
    31+
    parser.add_argument("--server", "-s", help="server address")
    3232
    parser.add_argument("--site", "-S", help="site name")
    33-
    parser.add_argument(
    34-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    35-
    )
    36-
    parser.add_argument(
    37-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    38-
    )
    33+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    34+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    3935
    parser.add_argument(
    4036
    "--logging-level",
    4137
    "-l",

    samples/create_schedules.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -17,14 +17,10 @@
    1717
    def main():
    1818
    parser = argparse.ArgumentParser(description="Creates sample schedules for each type of frequency.")
    1919
    # Common options; please keep those in sync across all samples
    20-
    parser.add_argument("--server", "-s", required=True, help="server address")
    20+
    parser.add_argument("--server", "-s", help="server address")
    2121
    parser.add_argument("--site", "-S", help="site name")
    22-
    parser.add_argument(
    23-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    24-
    )
    25-
    parser.add_argument(
    26-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    27-
    )
    22+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    23+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2824
    parser.add_argument(
    2925
    "--logging-level",
    3026
    "-l",

    samples/explore_datasource.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -18,14 +18,10 @@
    1818
    def main():
    1919
    parser = argparse.ArgumentParser(description="Explore datasource functions supported by the Server API.")
    2020
    # Common options; please keep those in sync across all samples
    21-
    parser.add_argument("--server", "-s", required=True, help="server address")
    21+
    parser.add_argument("--server", "-s", help="server address")
    2222
    parser.add_argument("--site", "-S", help="site name")
    23-
    parser.add_argument(
    24-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    25-
    )
    26-
    parser.add_argument(
    27-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    28-
    )
    23+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    24+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2925
    parser.add_argument(
    3026
    "--logging-level",
    3127
    "-l",

    samples/explore_site.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,14 +14,10 @@
    1414
    def main():
    1515
    parser = argparse.ArgumentParser(description="Explore site updates by the Server API.")
    1616
    # Common options; please keep those in sync across all samples
    17-
    parser.add_argument("--server", "-s", required=True, help="server address")
    17+
    parser.add_argument("--server", "-s", help="server address")
    1818
    parser.add_argument("--site", "-S", help="site name")
    19-
    parser.add_argument(
    20-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    21-
    )
    22-
    parser.add_argument(
    23-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    24-
    )
    19+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    20+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2521
    parser.add_argument(
    2622
    "--logging-level",
    2723
    "-l",

    samples/explore_webhooks.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -19,14 +19,10 @@
    1919
    def main():
    2020
    parser = argparse.ArgumentParser(description="Explore webhook functions supported by the Server API.")
    2121
    # Common options; please keep those in sync across all samples
    22-
    parser.add_argument("--server", "-s", required=True, help="server address")
    22+
    parser.add_argument("--server", "-s", help="server address")
    2323
    parser.add_argument("--site", "-S", help="site name")
    24-
    parser.add_argument(
    25-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    26-
    )
    27-
    parser.add_argument(
    28-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    29-
    )
    24+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    25+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    3026
    parser.add_argument(
    3127
    "--logging-level",
    3228
    "-l",

    samples/explore_workbook.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -19,14 +19,10 @@
    1919
    def main():
    2020
    parser = argparse.ArgumentParser(description="Explore workbook functions supported by the Server API.")
    2121
    # Common options; please keep those in sync across all samples
    22-
    parser.add_argument("--server", "-s", required=True, help="server address")
    22+
    parser.add_argument("--server", "-s", help="server address")
    2323
    parser.add_argument("--site", "-S", help="site name")
    24-
    parser.add_argument(
    25-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    26-
    )
    27-
    parser.add_argument(
    28-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    29-
    )
    24+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    25+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    3026
    parser.add_argument(
    3127
    "--logging-level",
    3228
    "-l",

    samples/export.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,14 +14,10 @@
    1414
    def main():
    1515
    parser = argparse.ArgumentParser(description="Export a view as an image, PDF, or CSV")
    1616
    # Common options; please keep those in sync across all samples
    17-
    parser.add_argument("--server", "-s", required=True, help="server address")
    17+
    parser.add_argument("--server", "-s", help="server address")
    1818
    parser.add_argument("--site", "-S", help="site name")
    19-
    parser.add_argument(
    20-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    21-
    )
    22-
    parser.add_argument(
    23-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    24-
    )
    19+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    20+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2521
    parser.add_argument(
    2622
    "--logging-level",
    2723
    "-l",

    samples/extracts.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -19,14 +19,10 @@
    1919
    def main():
    2020
    parser = argparse.ArgumentParser(description="Explore extract functions supported by the Server API.")
    2121
    # Common options; please keep those in sync across all samples
    22-
    parser.add_argument("--server", "-s", required=True, help="server address")
    22+
    parser.add_argument("--server", "-s", help="server address")
    2323
    parser.add_argument("--site", help="site name")
    24-
    parser.add_argument(
    25-
    "--token-name", "-tn", required=True, help="name of the personal access token used to sign into the server"
    26-
    )
    27-
    parser.add_argument(
    28-
    "--token-value", "-tv", required=True, help="value of the personal access token used to sign into the server"
    29-
    )
    24+
    parser.add_argument("--token-name", "-tn", help="name of the personal access token used to sign into the server")
    25+
    parser.add_argument("--token-value", "-tv", help="value of the personal access token used to sign into the server")
    3026
    parser.add_argument(
    3127
    "--logging-level",
    3228
    "-l",

    samples/filter_sort_groups.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -26,14 +26,10 @@ def create_example_group(group_name="Example Group", server=None):
    2626
    def main():
    2727
    parser = argparse.ArgumentParser(description="Filter and sort groups.")
    2828
    # Common options; please keep those in sync across all samples
    29-
    parser.add_argument("--server", "-s", required=True, help="server address")
    29+
    parser.add_argument("--server", "-s", help="server address")
    3030
    parser.add_argument("--site", "-S", help="site name")
    31-
    parser.add_argument(
    32-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    33-
    )
    34-
    parser.add_argument(
    35-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    36-
    )
    31+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    32+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    3733
    parser.add_argument(
    3834
    "--logging-level",
    3935
    "-l",

    samples/filter_sort_projects.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -29,14 +29,10 @@ def create_example_project(
    2929
    def main():
    3030
    parser = argparse.ArgumentParser(description="Filter and sort projects.")
    3131
    # Common options; please keep those in sync across all samples
    32-
    parser.add_argument("--server", "-s", required=True, help="server address")
    32+
    parser.add_argument("--server", "-s", help="server address")
    3333
    parser.add_argument("--site", "-S", help="site name")
    34-
    parser.add_argument(
    35-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    36-
    )
    37-
    parser.add_argument(
    38-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    39-
    )
    34+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    35+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    4036
    parser.add_argument(
    4137
    "--logging-level",
    4238
    "-l",

    samples/initialize_server.py

    Lines changed: 5 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,14 +13,10 @@
    1313
    def main():
    1414
    parser = argparse.ArgumentParser(description="Initialize a server with content.")
    1515
    # Common options; please keep those in sync across all samples
    16-
    parser.add_argument("--server", "-s", required=True, help="server address")
    16+
    parser.add_argument("--server", "-s", help="server address")
    1717
    parser.add_argument("--site", "-S", help="site name")
    18-
    parser.add_argument(
    19-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    20-
    )
    21-
    parser.add_argument(
    22-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    23-
    )
    18+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    19+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2420
    parser.add_argument(
    2521
    "--logging-level",
    2622
    "-l",
    @@ -29,8 +25,8 @@ def main():
    2925
    help="desired logging level (set to error by default)",
    3026
    )
    3127
    # Options specific to this sample
    32-
    parser.add_argument("--datasources-folder", "-df", required=True, help="folder containing datasources")
    33-
    parser.add_argument("--workbooks-folder", "-wf", required=True, help="folder containing workbooks")
    28+
    parser.add_argument("--datasources-folder", "-df", help="folder containing datasources")
    29+
    parser.add_argument("--workbooks-folder", "-wf", help="folder containing workbooks")
    3430
    parser.add_argument("--project", required=False, default="Default", help="project to use")
    3531

    3632
    args = parser.parse_args()

    samples/kill_all_jobs.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,14 +13,10 @@
    1313
    def main():
    1414
    parser = argparse.ArgumentParser(description="Cancel all of the running background jobs.")
    1515
    # Common options; please keep those in sync across all samples
    16-
    parser.add_argument("--server", "-s", required=True, help="server address")
    16+
    parser.add_argument("--server", "-s", help="server address")
    1717
    parser.add_argument("--site", "-S", help="site name")
    18-
    parser.add_argument(
    19-
    "--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
    20-
    )
    21-
    parser.add_argument(
    22-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    23-
    )
    18+
    parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server")
    19+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2420
    parser.add_argument(
    2521
    "--logging-level",
    2622
    "-l",

    samples/list.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -15,14 +15,10 @@
    1515
    def main():
    1616
    parser = argparse.ArgumentParser(description="List out the names and LUIDs for different resource types.")
    1717
    # Common options; please keep those in sync across all samples
    18-
    parser.add_argument("--server", "-s", required=True, help="server address")
    18+
    parser.add_argument("--server", "-s", help="server address")
    1919
    parser.add_argument("--site", "-S", help="site name")
    20-
    parser.add_argument(
    21-
    "--token-name", "-n", required=True, help="name of the personal access token used to sign into the server"
    22-
    )
    23-
    parser.add_argument(
    24-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    25-
    )
    20+
    parser.add_argument("--token-name", "-n", help="name of the personal access token used to sign into the server")
    21+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2622
    parser.add_argument(
    2723
    "--logging-level",
    2824
    "-l",

    samples/login.py

    Lines changed: 15 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,6 +9,7 @@
    99
    import logging
    1010

    1111
    import tableauserverclient as TSC
    12+
    import env
    1213

    1314

    1415
    # If a sample has additional arguments, then it should copy this code and insert them after the call to
    @@ -18,10 +19,15 @@ def set_up_and_log_in():
    1819
    parser = argparse.ArgumentParser(description="Logs in to the server.")
    1920
    sample_define_common_options(parser)
    2021
    args = parser.parse_args()
    21-
    22-
    # Set logging level based on user input, or error by default.
    23-
    logging_level = getattr(logging, args.logging_level.upper())
    24-
    logging.basicConfig(level=logging_level)
    22+
    if not args.server:
    23+
    args.server = env.server
    24+
    if not args.site:
    25+
    args.site = env.site
    26+
    if not args.token_name:
    27+
    args.token_name = env.token_name
    28+
    if not args.token_value:
    29+
    args.token_value = env.token_value
    30+
    args.logging_level = "debug"
    2531

    2632
    server = sample_connect_to_server(args)
    2733
    print(server.server_info.get())
    @@ -30,9 +36,9 @@ def set_up_and_log_in():
    3036

    3137
    def sample_define_common_options(parser):
    3238
    # Common options; please keep these in sync across all samples by copying or calling this method directly
    33-
    parser.add_argument("--server", "-s", required=True, help="server address")
    39+
    parser.add_argument("--server", "-s", help="server address")
    3440
    parser.add_argument("--site", "-t", help="site name")
    35-
    auth = parser.add_mutually_exclusive_group(required=True)
    41+
    auth = parser.add_mutually_exclusive_group(required=False)
    3642
    auth.add_argument("--token-name", "-tn", help="name of the personal access token used to sign into the server")
    3743
    auth.add_argument("--username", "-u", help="username to sign into the server")
    3844

    @@ -73,6 +79,9 @@ def sample_connect_to_server(args):
    7379
    # Make sure we use an updated version of the rest apis, and pass in our cert handling choice
    7480
    server = TSC.Server(args.server, use_server_version=True, http_options={"verify": check_ssl_certificate})
    7581
    server.auth.sign_in(tableau_auth)
    82+
    server.version = "2.6"
    83+
    new_site: TSC.SiteItem = TSC.SiteItem("cdnear", content_url=env.site)
    84+
    server.auth.switch_site(new_site)
    7685
    print("Logged in successfully")
    7786

    7887
    return server

    samples/metadata_query.py

    Lines changed: 3 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,14 +14,10 @@
    1414
    def main():
    1515
    parser = argparse.ArgumentParser(description="Use the metadata API to get information on a published data source.")
    1616
    # Common options; please keep those in sync across all samples
    17-
    parser.add_argument("--server", "-s", required=True, help="server address")
    17+
    parser.add_argument("--server", "-s", help="server address")
    1818
    parser.add_argument("--site", "-S", help="site name")
    19-
    parser.add_argument(
    20-
    "--token-name", "-n", required=True, help="name of the personal access token used to sign into the server"
    21-
    )
    22-
    parser.add_argument(
    23-
    "--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
    24-
    )
    19+
    parser.add_argument("--token-name", "-n", help="name of the personal access token used to sign into the server")
    20+
    parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server")
    2521
    parser.add_argument(
    2622
    "--logging-level",
    2723
    "-l",

    0 commit comments

    Comments
     (0)
    0