diff --git a/environment.yml b/environment.yml index ce690d9..96159dc 100644 --- a/environment.yml +++ b/environment.yml @@ -2,9 +2,9 @@ name: prism-dev channels: - defaults dependencies: - - python=3.7 - - click>=6,<8 - - requests>=2.20.0,<3 + - python=3.8 + - click + - requests - pytest - - black=19.10b0 + - black - flake8 diff --git a/prism/cli.py b/prism/cli.py index e13f102..3a1fd1f 100644 --- a/prism/cli.py +++ b/prism/cli.py @@ -28,10 +28,18 @@ def param_fixup(value, config, config_name, option): @click.group(help="CLI for interacting with Workday’s Prism API") # Tenant specific parameters @click.option( - "--base_url", envvar="workday_base_url", type=str, required=False, help="The base URL for the API client", + "--base_url", + envvar="workday_base_url", + type=str, + required=False, + help="The base URL for the API client", ) @click.option( - "--tenant_name", envvar="workday_tenant_name", type=str, required=False, help="The name of your Workday tenant", + "--tenant_name", + envvar="workday_tenant_name", + type=str, + required=False, + help="The name of your Workday tenant", ) @click.option( "--client_id", @@ -86,7 +94,16 @@ def param_fixup(value, config, config_name, option): ) @click.pass_context def cli( - ctx, base_url, tenant_name, client_id, client_secret, refresh_token, log_level, log_file, config_file, config_name, + ctx, + base_url, + tenant_name, + client_id, + client_secret, + refresh_token, + log_level, + log_file, + config_file, + config_name, ): # Attempt to locate a configuration file - this is not required and config # parameters are only used if the configuration values are not passed on diff --git a/prism/commands/buckets_commands.py b/prism/commands/buckets_commands.py index b5721a4..1ce3c72 100644 --- a/prism/commands/buckets_commands.py +++ b/prism/commands/buckets_commands.py @@ -8,7 +8,11 @@ @click.command("get") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the bucket or table argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the bucket or table argument as a name.", ) @click.option( "-l", @@ -33,7 +37,12 @@ help="How much information to be returned in response JSON.", ) @click.option( - "-s", "--search", is_flag=True, show_default=True, default=False, help="Use substring search bucket or table.", + "-s", + "--search", + is_flag=True, + show_default=True, + default=False, + help="Use substring search bucket or table.", ) @click.option("--table", help="The id or name of a Prism table to list all buckets.") @click.argument("bucket", required=False) @@ -90,7 +99,11 @@ def buckets_get(ctx, bucket, table, isname, limit, offset, type_, search): help="Schema JSON file for the target table.", ) @click.option( - "-o", "--operation", default="TruncateAndInsert", show_default=True, help="Operation to perform on the table.", + "-o", + "--operation", + default="TruncateAndInsert", + show_default=True, + help="Operation to perform on the table.", ) @click.argument("bucket", required=False) @click.pass_context @@ -107,7 +120,11 @@ def buckets_create(ctx, target_name, target_id, file, operation, bucket): sys.exit(1) bucket = p.buckets_create( - bucket_name=bucket, target_id=target_id, target_name=target_name, schema=file, operation=operation, + bucket_name=bucket, + target_id=target_id, + target_name=target_name, + schema=file, + operation=operation, ) if bucket is not None: @@ -119,12 +136,19 @@ def buckets_create(ctx, target_name, target_id, file, operation, bucket): @click.command("files") @click.option( - "-n", "--target_name", default=None, help="Name of the table to associate with the bucket.", + "-n", + "--target_name", + default=None, + help="Name of the table to associate with the bucket.", ) @click.option("-i", "--target_id", default=None, help="Table ID to associate with the table.") @click.option("-f", "--file", default=None, help="Schema JSON file for the target table.") @click.option( - "-o", "--operation", default="TruncateAndInsert", show_default=True, help="Operation to perform on the table.", + "-o", + "--operation", + default="TruncateAndInsert", + show_default=True, + help="Operation to perform on the table.", ) @click.option("-b", "--bucket", help="Bucket name to load files.", default=None) @click.option( @@ -165,7 +189,11 @@ def buckets_files(ctx, target_name, target_id, file, operation, bucket, complete @click.command("complete") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the bucket argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the bucket argument as a name.", ) @click.argument("bucket", required=True) @click.pass_context @@ -202,7 +230,11 @@ def buckets_complete(ctx, isname, bucket): @click.command("errorFile") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the bucket argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the bucket argument as a name.", ) @click.argument("bucket", required=True) @click.pass_context diff --git a/prism/commands/dataChanges_commands.py b/prism/commands/dataChanges_commands.py index 7bb0b5a..63b8892 100644 --- a/prism/commands/dataChanges_commands.py +++ b/prism/commands/dataChanges_commands.py @@ -9,13 +9,23 @@ @click.command("get") @click.option( - "-n", "--isName", default=False, is_flag=True, help="Flag to treat the dct argument as a name.", + "-n", + "--isName", + default=False, + is_flag=True, + help="Flag to treat the dct argument as a name.", ) @click.option( - "-l", "--limit", default=-1, help="The maximum number of object data entries included in the response.", + "-l", + "--limit", + default=-1, + help="The maximum number of object data entries included in the response.", ) @click.option( - "-o", "--offset", default=0, help="The offset to the first object in a collection to include in the response.", + "-o", + "--offset", + default=0, + help="The offset to the first object in a collection to include in the response.", ) @click.option( "-t", @@ -65,7 +75,11 @@ def dataChanges_get(ctx, isname, dct, limit, offset, type_, search): @click.command("validate") @click.option( - "-n", "--isName", default=False, is_flag=True, help="Flag to treat the dct argument as a name.", + "-n", + "--isName", + default=False, + is_flag=True, + help="Flag to treat the dct argument as a name.", ) @click.option("-s", "--search", is_flag=True, help="Use contains search substring for --name.") @click.argument("dct", required=True) @@ -106,7 +120,11 @@ def dataChanges_validate(ctx, isname, dct, search): @click.command("run") @click.option( - "-n", "--isName", default=False, is_flag=True, help="Flag to treat the dct argument as a name.", + "-n", + "--isName", + default=False, + is_flag=True, + help="Flag to treat the dct argument as a name.", ) @click.argument("dct", required=True) @click.argument("fid", required=False) @@ -146,10 +164,18 @@ def dataChanges_run(ctx, dct, fid, isname): @click.command("activities") @click.option( - "-n", "--isName", default=False, is_flag=True, help="Flag to treat the dct argument as a name.", + "-n", + "--isName", + default=False, + is_flag=True, + help="Flag to treat the dct argument as a name.", ) @click.option( - "-s", "--status", is_flag=True, default=False, help="Return only the status of the activity.", + "-s", + "--status", + is_flag=True, + default=False, + help="Return only the status of the activity.", ) @click.argument("dct", required=True) @click.argument("activityID", required=True) @@ -190,13 +216,25 @@ def dataChanges_activities(ctx, dct, activityid, status, isname): @click.command("upload") @click.option( - "-n", "--isName", default=False, is_flag=True, help="Flag to treat the dct argument as a name.", + "-n", + "--isName", + default=False, + is_flag=True, + help="Flag to treat the dct argument as a name.", ) @click.option( - "-w", "--wait", default=False, is_flag=True, help="Wait for the data change task to complete.", + "-w", + "--wait", + default=False, + is_flag=True, + help="Wait for the data change task to complete.", ) @click.option( - "-v", "--verbose", default=False, is_flag=True, help="Display additional information.", + "-v", + "--verbose", + default=False, + is_flag=True, + help="Display additional information.", ) @click.argument("dct", required=True) @click.argument("file", required=True, nargs=-1, type=click.Path(exists=True)) diff --git a/prism/commands/fileContainers_commands.py b/prism/commands/fileContainers_commands.py index e217e6b..775ac03 100644 --- a/prism/commands/fileContainers_commands.py +++ b/prism/commands/fileContainers_commands.py @@ -40,7 +40,10 @@ def fileContainers_get(ctx, id): @click.command("load") @click.option( - "-i", "--id", default=None, help="Target File container ID - defaults to a new container.", + "-i", + "--id", + default=None, + help="Target File container ID - defaults to a new container.", ) @click.argument("file", nargs=-1, type=click.Path(exists=True)) @click.pass_context diff --git a/prism/commands/tables_commands.py b/prism/commands/tables_commands.py index 66b08e2..a9f2523 100644 --- a/prism/commands/tables_commands.py +++ b/prism/commands/tables_commands.py @@ -10,7 +10,11 @@ @click.command("get") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the table argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the table argument as a name.", ) @click.option( "-l", @@ -35,10 +39,17 @@ help="How much information returned for each table.", ) @click.option( - "-c", "--compact", is_flag=True, default=False, help="Compact the table schema for use in edit (put) operations.", + "-c", + "--compact", + is_flag=True, + default=False, + help="Compact the table schema for use in edit (put) operations.", ) @click.option( - "-s", "--search", is_flag=True, help="Enable substring search of NAME in api name or display name.", + "-s", + "--search", + is_flag=True, + help="Enable substring search of NAME in api name or display name.", ) @click.argument("table", required=False) @click.pass_context @@ -86,7 +97,12 @@ def tables_get(ctx, isname, table, limit, offset, type_, compact, search): @click.option("-n", "--table_name", help="Table name - overrides name from schema.") @click.option("-d", "--displayName", help="Specify a display name - defaults to name.") @click.option( - "-e", "--enableForAnalysis", type=bool, is_flag=True, default=None, help="Enable this table for analytics.", + "-e", + "--enableForAnalysis", + type=bool, + is_flag=True, + default=None, + help="Enable this table for analytics.", ) @click.option("-s", "--sourceName", help="The API name of an existing table to copy.") @click.option("-w", "--sourceWID", help="The WID of an existing table to copy.") @@ -148,7 +164,11 @@ def tables_create(ctx, table_name, displayname, enableforanalysis, sourcename, s @click.command("edit") @click.option( - "-t", "--truncate", is_flag=True, default=False, help="Truncate the table before updating.", + "-t", + "--truncate", + is_flag=True, + default=False, + help="Truncate the table before updating.", ) @click.argument("file", required=True, type=click.Path(exists=True, dir_okay=False, readable=True)) @click.pass_context @@ -174,7 +194,11 @@ def tables_edit(ctx, file, truncate): @click.command("patch") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the table argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the table argument as a name.", ) @click.option( "--displayName", @@ -198,7 +222,10 @@ def tables_edit(ctx, file, truncate): help="Set the documentation for an existing table.", ) @click.option( - "--enableForAnalysis", is_flag=False, default=None, type=click.Choice(["true", "false"], case_sensitive=False), + "--enableForAnalysis", + is_flag=False, + default=None, + type=click.Choice(["true", "false"], case_sensitive=False), ) @click.argument("table", required=True, type=str) @click.argument("file", required=False, type=click.Path(dir_okay=False)) @@ -307,7 +334,11 @@ def set_patch_value(attr, value): @click.command("upload") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the table argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the table argument as a name.", ) @click.option( "-o", @@ -344,7 +375,11 @@ def tables_upload(ctx, table, isname, operation, file): @click.command("truncate") @click.option( - "-n", "--isName", is_flag=True, default=False, help="Flag to treat the table argument as a name.", + "-n", + "--isName", + is_flag=True, + default=False, + help="Flag to treat the table argument as a name.", ) @click.argument("table", required=True) @click.pass_context diff --git a/prism/prism.py b/prism/prism.py index 60a3fc9..24af8ba 100644 --- a/prism/prism.py +++ b/prism/prism.py @@ -228,7 +228,13 @@ class Prism: """ def __init__( - self, base_url, tenant_name, client_id, client_secret, refresh_token, version="v3", + self, + base_url, + tenant_name, + client_id, + client_secret, + refresh_token, + version="v3", ): """Init the Prism class with required attributes.""" @@ -435,7 +441,13 @@ def reset_bearer_token(self): self.bearer_token_timestamp = None def tables_get( - self, table_name=None, table_id=None, limit=None, offset=None, type_="summary", search=False, + self, + table_name=None, + table_id=None, + limit=None, + offset=None, + type_="summary", + search=False, ): """Obtain details for all tables or a given table(s). @@ -824,7 +836,12 @@ def buckets_get( return return_buckets def buckets_create( - self, bucket_name=None, target_name=None, target_id=None, schema=None, operation="TruncateAndInsert", + self, + bucket_name=None, + target_name=None, + target_id=None, + schema=None, + operation="TruncateAndInsert", ): """Create a Prism bucket to upload files. @@ -1072,7 +1089,13 @@ def buckets_errorFile(self, bucket_id): return None def dataChanges_get( - self, datachange_name=None, datachange_id=None, limit=None, offset=None, type_="summary", search=False, + self, + datachange_name=None, + datachange_id=None, + limit=None, + offset=None, + type_="summary", + search=False, ): """ """ # We are doing a dataChanges GET operation. @@ -1502,7 +1525,6 @@ def tables_create( # Initialize a new schema with the particulars for this table operation. if table_name is not None: - # If we got a name, set it in the table schema schema["name"] = table_name.replace(" ", "_") # Minor clean-up