Details
| ID | AWS - Athena - Beta |
|---|---|
| Provider | Amazon |
| Category | IT Services |
| From Version | 5.0.0 |
| Docker Image | demisto/boto3py3:1.0.0.10221838 |
| Supported Modules | Agentix XSIAM |
README
Amazon Web Services Athena.
Configure AWS - Athena in Cortex
| Parameter | Description | Required |
|---|---|---|
| Role Arn | False | |
| Role Session Name | False | |
| Role Session Duration | False | |
| AWS Default Region | False | |
| Access Key | True | |
| Secret Key | True | |
| Timeout | The time in seconds until a timeout exception is reached. You can specify just the read timeout (for example 60) or also the connect timeout followed after a comma (for example 60,10). If a connect timeout is not specified, a default of 10 second will be used. | False |
| Retries | The maximum number of retry attempts when connection or throttling errors are encountered. Set to 0 to disable retries. The default value is 5 and the limit is 10. Note: Increasing the number of retries will increase the execution time. | False |
| Trust any certificate (not secure) | False | |
| Use system proxy settings | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
aws-athena-execute-query
Execute a new query, wait for the query to complete (using polling), and return query’s execution information, and query’s results (if successful). Either ‘OutputLocation’ or ‘WorkGroup’ must be specified for the query to run.
Base Command
aws-athena-execute-query
Input
| Argument Name | Description | Required |
|---|---|---|
| QueryString | The SQL query statements to be executed. | Required |
| QueryLimit | A limit (number) to use for the query. If the keyword ‘LIMIT’ exists within ‘QueryString’, this parameter will be ignored. Default is 50. | Optional |
| ClientRequestToken | A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another StartQueryExecution request is received, the same response is returned and another query is not created. | Optional |
| Database | The name of the database. | Optional |
| OutputLocation | The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/. | Optional |
| EncryptionOption | Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used. | Optional |
| KmsKey | For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID. | Optional |
| WorkGroup | The name of the workgroup in which the query is being started. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| region | The AWS Region, if not specified the default region will be used. | Optional |
| QueryExecutionId | ID of the newly created query. Used internally for polling. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Athena.Query.QueryExecutionId | String | The unique identifier for each query execution. |
| AWS.Athena.Query.Query | String | The SQL query statements which the query execution ran. |
| AWS.Athena.Query.StatementType | String | The type of query statement that was run. |
| AWS.Athena.Query.ResultConfiguration.OutputLocation | String | The location in Amazon S3 where your query and calculation results are stored, such as ‘s3://path/to/query/bucket/’. |
| AWS.Athena.Query.ResultConfiguration.EncryptionConfiguration.EncryptionOption | String | If query and calculation results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE_KMS or CSE_KMS) and key information. |
| AWS.Athena.Query.ResultConfiguration.EncryptionConfiguration.KmsKey | String | For SSE_KMS and CSE_KMS, this is the KMS key ARN or ID. |
| AWS.Athena.Query.ResultConfiguration.ExpectedBucketOwner | String | The Amazon Web Services account ID that you expect to be the owner of the Amazon S3 bucket specified by ResultConfiguration.OutputLocation. |
| AWS.Athena.Query.ResultConfiguration.AclConfiguration.S3AclOption | String | The Amazon S3 canned ACL that Athena should specify when storing query results. |
| AWS.Athena.Query.ResultReuseConfiguration.ResultReuseByAgeConfiguration.Enabled | Boolean | True if previous query results can be reused when the query is run; otherwise, false. The default is false. |
| AWS.Athena.Query.ResultReuseConfiguration.ResultReuseByAgeConfiguration.MaxAgeInMinutes | Number | Specifies, in minutes, the maximum age of a previous query result that Athena should consider for reuse. The default is 60. |
| AWS.Athena.Query.QueryExecutionContext.Database | String | The name of the database used in the query execution. |
| AWS.Athena.Query.QueryExecutionContext.Catalog | String | The name of the data catalog used in the query execution. |
| AWS.Athena.Query.Status.State | String | The state of query execution. |
| AWS.Athena.Query.Status.StateChangeReason | String | Further detail about the status of the query. |
| AWS.Athena.Query.Status.SubmissionDateTime | String | The date and time that the query was submitted. |
| AWS.Athena.Query.Status.CompletionDateTime | String | The date and time that the query completed. |
| AWS.Athena.Query.Status.AthenaError.ErrorCategory | Number | An integer value that specifies the category of a query failure error. |
| AWS.Athena.Query.Status.AthenaError.ErrorType | Number | An integer value that provides specific information about an Athena query error. For the meaning of specific values, see the Error Type Reference in the Amazon Athena User Guide. |
| AWS.Athena.Query.Status.AthenaError.Retryable | Boolean | True if the query might succeed if resubmitted. |
| AWS.Athena.Query.Status.AthenaError.ErrorMessage | String | Contains a short description of the error that occurred. |
| AWS.Athena.Query.Statistics.EngineExecutionTimeInMillis | Number | The number of milliseconds that the query took to execute. |
| AWS.Athena.Query.Statistics.DataScannedInBytes | Number | The number of bytes in the data that was queried. |
| AWS.Athena.Query.Statistics.DataManifestLocation | String | The location and file name of a data manifest file. The manifest file is saved to the Athena query results location in Amazon S3. |
| AWS.Athena.Query.Statistics.TotalExecutionTimeInMillis | Number | The number of milliseconds that Athena took to run the query. |
| AWS.Athena.Query.Statistics.QueryQueueTimeInMillis | Number | The number of milliseconds that the query was in your query queue waiting for resources. |
| AWS.Athena.Query.Statistics.ServicePreProcessingTimeInMillis | Number | The number of milliseconds that Athena took to preprocess the query before submitting the query to the query engine. |
| AWS.Athena.Query.Statistics.QueryPlanningTimeInMillis | Number | The number of milliseconds that Athena took to plan the query processing flow. This includes the time spent retrieving table partitions from the data source. |
| AWS.Athena.Query.Statistics.ServiceProcessingTimeInMillis | Number | The number of milliseconds that Athena took to finalize and publish the query results after the query engine finished running the query. |
| AWS.Athena.Query.ResultReuseInformation.ReusedPreviousResult | Boolean | True if a previous query result was reused; false if the result was generated from a new run of the query. |
| AWS.Athena.Query.WorkGroup | String | The name of the workgroup in which the query ran. |
| AWS.Athena.Query.EngineVersion.SelectedEngineVersion | String | The engine version requested by the user. Possible values are determined by the output of ListEngineVersions, including AUTO. |
| AWS.Athena.Query.EngineVersion.EffectiveEngineVersion | String | The engine version on which the query runs. |
| AWS.Athena.Query.ExecutionParameters | List | A list of values for the parameters in a query. The values are applied sequentially to the parameters in the query in the order in which the parameters occur. The list of parameters is not returned in the response. |
| AWS.Athena.Query.SubstatementType | String | The kind of query statement that was run. |
| AWS.Athena.QueryResults | List | List of query results. |
aws-athena-start-query
Start an Athena query. Either ‘OutputLocation’ or ‘WorkGroup’ must be specified for the query to run.
Base Command
aws-athena-start-query
Input
| Argument Name | Description | Required |
|---|---|---|
| QueryString | The SQL query statements to be executed. | Required |
| QueryLimit | A limit (number) to use for the query. If the keyword ‘LIMIT’ exists within ‘QueryString’, this parameter will be ignored. Default is 50. | Optional |
| ClientRequestToken | A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another StartQueryExecution request is received, the same response is returned and another query is not created. | Optional |
| Database | The name of the database. | Optional |
| OutputLocation | The location in Amazon S3 where your query results are stored, such as s3://path/to/query/bucket/. | Optional |
| EncryptionOption | Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE-S3 ), server-side encryption with KMS-managed keys (SSE-KMS ), or client-side encryption with KMS-managed keys (CSE-KMS) is used. | Optional |
| KmsKey | For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID. | Optional |
| WorkGroup | The name of the workgroup in which the query is being started. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| region | The AWS Region, if not specified the default region will be used. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Athena.Query.QueryExecutionId | String | ID of the newly created query. |
| AWS.Athena.Query.Query | String | The query string submitted. |
aws-athena-stop-query
Stop an existing running query.
Base Command
aws-athena-stop-query
Input
| Argument Name | Description | Required |
|---|---|---|
| QueryExecutionId | The unique ID of the query execution to stop. This field is auto-populated if not provided. | Required |
| region | The AWS Region, if not specified the default region will be used. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
There is no context output for this command.
aws-athena-get-query-execution
Return execution information of a query.
Base Command
aws-athena-get-query-execution
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region, if not specified the default region will be used. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
| QueryExecutionId | The unique ID of the query execution. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Athena.Query.QueryExecutionId | String | The unique identifier for each query execution. |
| AWS.Athena.Query.Query | String | The SQL query statements which the query execution ran. |
| AWS.Athena.Query.StatementType | String | The type of query statement that was run. |
| AWS.Athena.Query.ResultConfiguration.OutputLocation | String | The location in Amazon S3 where your query and calculation results are stored, such as ‘s3://path/to/query/bucket/’. |
| AWS.Athena.Query.ResultConfiguration.EncryptionConfiguration.EncryptionOption | String | If query and calculation results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE_KMS or CSE_KMS) and key information. |
| AWS.Athena.Query.ResultConfiguration.EncryptionConfiguration.KmsKey | String | For SSE_KMS and CSE_KMS, this is the KMS key ARN or ID. |
| AWS.Athena.Query.ResultConfiguration.ExpectedBucketOwner | String | The Amazon Web Services account ID that you expect to be the owner of the Amazon S3 bucket specified by ResultConfiguration.OutputLocation. |
| AWS.Athena.Query.ResultConfiguration.AclConfiguration.S3AclOption | String | The Amazon S3 canned ACL that Athena should specify when storing query results. |
| AWS.Athena.Query.ResultReuseConfiguration.ResultReuseByAgeConfiguration.Enabled | Boolean | True if previous query results can be reused when the query is run; otherwise, false. The default is false. |
| AWS.Athena.Query.ResultReuseConfiguration.ResultReuseByAgeConfiguration.MaxAgeInMinutes | Number | Specifies, in minutes, the maximum age of a previous query result that Athena should consider for reuse. The default is 60. |
| AWS.Athena.Query.QueryExecutionContext.Database | String | The name of the database used in the query execution. |
| AWS.Athena.Query.QueryExecutionContext.Catalog | String | The name of the data catalog used in the query execution. |
| AWS.Athena.Query.Status.State | String | The state of query execution. |
| AWS.Athena.Query.Status.StateChangeReason | String | Further detail about the status of the query. |
| AWS.Athena.Query.Status.SubmissionDateTime | String | The date and time that the query was submitted. |
| AWS.Athena.Query.Status.CompletionDateTime | String | The date and time that the query completed. |
| AWS.Athena.Query.Status.AthenaError.ErrorCategory | Number | An integer value that specifies the category of a query failure error. |
| AWS.Athena.Query.Status.AthenaError.ErrorType | Number | An integer value that provides specific information about an Athena query error. For the meaning of specific values, see the Error Type Reference in the Amazon Athena User Guide. |
| AWS.Athena.Query.Status.AthenaError.Retryable | Boolean | True if the query might succeed if resubmitted. |
| AWS.Athena.Query.Status.AthenaError.ErrorMessage | String | Contains a short description of the error that occurred. |
| AWS.Athena.Query.Statistics.EngineExecutionTimeInMillis | Number | The number of milliseconds that the query took to execute. |
| AWS.Athena.Query.Statistics.DataScannedInBytes | Number | The number of bytes in the data that was queried. |
| AWS.Athena.Query.Statistics.DataManifestLocation | String | The location and file name of a data manifest file. The manifest file is saved to the Athena query results location in Amazon S3. |
| AWS.Athena.Query.Statistics.TotalExecutionTimeInMillis | Number | The number of milliseconds that Athena took to run the query. |
| AWS.Athena.Query.Statistics.QueryQueueTimeInMillis | Number | The number of milliseconds that the query was in your query queue waiting for resources. |
| AWS.Athena.Query.Statistics.ServicePreProcessingTimeInMillis | Number | The number of milliseconds that Athena took to preprocess the query before submitting the query to the query engine. |
| AWS.Athena.Query.Statistics.QueryPlanningTimeInMillis | Number | The number of milliseconds that Athena took to plan the query processing flow. This includes the time spent retrieving table partitions from the data source. |
| AWS.Athena.Query.Statistics.ServiceProcessingTimeInMillis | Number | The number of milliseconds that Athena took to finalize and publish the query results after the query engine finished running the query. |
| AWS.Athena.Query.ResultReuseInformation.ReusedPreviousResult | Boolean | True if a previous query result was reused; false if the result was generated from a new run of the query. |
| AWS.Athena.Query.WorkGroup | String | The name of the workgroup in which the query ran. |
| AWS.Athena.Query.EngineVersion.SelectedEngineVersion | String | The engine version requested by the user. Possible values are determined by the output of ListEngineVersions, including AUTO. |
| AWS.Athena.Query.EngineVersion.EffectiveEngineVersion | String | The engine version on which the query runs. |
| AWS.Athena.Query.ExecutionParameters | List | A list of values for the parameters in a query. The values are applied sequentially to the parameters in the query in the order in which the parameters occur. The list of parameters is not returned in the response. |
| AWS.Athena.Query.SubstatementType | String | The kind of query statement that was run. |
aws-athena-get-query-results
Return the results of a query.
Base Command
aws-athena-get-query-results
Input
| Argument Name | Description | Required |
|---|---|---|
| QueryExecutionId | The unique ID of the query execution. | Required |
| region | The AWS Region, if not specified the default region will be used. | Optional |
| roleArn | The Amazon Resource Name (ARN) of the role to assume. | Optional |
| roleSessionName | An identifier for the assumed role session. | Optional |
| roleSessionDuration | The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.Athena.QueryResults | List | List of query results. |
Configuration parameters
roleArn— Role ArnroleSessionName— Role Session NamesessionDuration— Role Session DurationdefaultRegion— AWS Default Regioncredentials— Access Keyaccess_key— Access Keysecret_key— Secret Keytimeout— Timeoutretries— Retriessts_regional_endpoint— AWS STS Regional Endpointsinsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (5)
-
aws-athena-execute-queryExecute a new query, wait for the query to complete (using polling), and return query's execution information, and query's results (if successful). Either 'OutputLocation' or 'WorkGroup' must be specified for the query to run.
-
aws-athena-get-query-executionReturn execution information of a query.
-
aws-athena-get-query-resultsReturn the results of a query.
-
aws-athena-start-queryStart an Athena query. Either 'OutputLocation' or 'WorkGroup' must be specified for the query to run.
-
aws-athena-stop-queryStop an existing running query.
from datetime import datetime import demistomock as demisto from CommonServerPython import * from CommonServerUserPython import * AWS_SERVICE_NAME = "athena" QUERY_DATA_OUTPUTS_KEY = "Query" QUERY_RESULTS_OUTPUTS_KEY = "QueryResults" def parse_rows_response(rows_data: list[dict]) -> list[dict]: """ Parse and arrange the 'Rows' data from the response. Args: rows_data (list[dict]): The 'Rows' data from the response. Note: The 'Rows' data is returned in a table format, where each item in the list is a row. Example for such a response can be seen on 'test_data/raw_data_mock/get_query_results.json' Returns: list[dict]: The data in a parsed and arranged format. """ if not rows_data or not rows_data[0].get("Data"): return [] keys: list[str] = [item["VarCharValue"] for item in rows_data[0]["Data"]] raw_results = [item["Data"] for item in rows_data[1:]] result_data = [] for raw_result in raw_results: current_item_data = {} for idx, value in enumerate(raw_result): if "VarCharValue" in value: current_item_data[keys[idx]] = value["VarCharValue"] result_data.append(current_item_data) return result_data # --- API Call Functions --- # def start_query_execution( client, query_string: str, query_limit: int | None = None, client_request_token: str | None = None, database: str | None = None, output_location: str | None = None, encryption_option: str | None = None, kms_key: str | None = None, work_group: str | None = None, ) -> dict: if query_limit and "LIMIT" not in query_string: query_string = f"{query_string} LIMIT {query_limit}" kwargs: dict[str, Any] = {"QueryString": query_string} if client_request_token: kwargs.update({"ClientRequestToken": client_request_token}) if database: kwargs.update({"QueryExecutionContext": {"Database": database}}) if output_location: kwargs.update({"ResultConfiguration": {"OutputLocation": output_location}}) if encryption_option: kwargs.update({"ResultConfiguration": {"EncryptionConfiguration": {"EncryptionOption": encryption_option}}}) if kms_key: kwargs.update({"ResultConfiguration": {"EncryptionConfiguration": {"KmsKey": kms_key}}}) if work_group: kwargs.update({"WorkGroup": work_group}) return client.start_query_execution(**kwargs) def get_query_execution(client, query_execution_id: str) -> dict: response = client.get_query_execution(QueryExecutionId=query_execution_id) # Convert datetime objects to strings if (datetime_value := response.get("QueryExecution", {}).get("Status", {}).get("SubmissionDateTime")) and isinstance( datetime_value, datetime ): response["QueryExecution"]["Status"]["SubmissionDateTime"] = datetime_value.isoformat() if (datetime_value := response.get("QueryExecution", {}).get("Status", {}).get("CompletionDateTime")) and isinstance( datetime_value, datetime ): response["QueryExecution"]["Status"]["CompletionDateTime"] = datetime_value.isoformat() return response["QueryExecution"] def get_query_results(client, query_execution_id: str) -> list[dict]: raw_response = client.get_query_results(QueryExecutionId=query_execution_id) parsed_response = parse_rows_response(rows_data=raw_response["ResultSet"]["Rows"]) for result_item in parsed_response: result_item["query_execution_id"] = query_execution_id return parsed_response # --- Command Functions --- # def module_test_command(client) -> str | CommandResults: response = client.list_named_queries() if response["ResponseMetadata"]["HTTPStatusCode"] == 200: return "ok" else: raise DemistoException(f"Error: {response}") def start_query_command(args: dict, client): query_string: str = args["QueryString"] response = start_query_execution( client=client, query_string=query_string, query_limit=args.get("QueryLimit"), client_request_token=args.get("ClientRequestToken"), database=args.get("Database"), output_location=args.get("OutputLocation"), encryption_option=args.get("EncryptionOption"), kms_key=args.get("KmsKey"), work_group=args.get("WorkGroup"), ) context_data = {"Query": query_string, "QueryExecutionId": response["QueryExecutionId"]} return CommandResults( outputs_prefix=f"AWS.Athena.{QUERY_DATA_OUTPUTS_KEY}", outputs_key_field="QueryExecutionId", outputs=context_data, raw_response=response, readable_output=tableToMarkdown("AWS Athena Query Start", context_data), ) def stop_query_command(args: dict, client): query_execution_id: str = args["QueryExecutionId"] response = client.stop_query_execution(QueryExecutionId=query_execution_id) if response.get("ResponseMetadata", {}).get("HTTPStatusCode") == 200: return CommandResults(readable_output=f"Query '{query_execution_id}' has been successfully stopped.") else: demisto.debug("Response:\n" + str(response)) raise DemistoException(f"Failed to stop query '{query_execution_id}'.") def get_query_execution_command(args: dict, client): query_execution_id: str = args["QueryExecutionId"] response = get_query_execution(client=client, query_execution_id=query_execution_id) return CommandResults( outputs_prefix=f"AWS.Athena.{QUERY_DATA_OUTPUTS_KEY}", outputs_key_field="QueryExecutionId", outputs=response, raw_response=response, readable_output=tableToMarkdown("AWS Athena Query Execution", response), ) def get_query_results_command(args: dict, client): query_execution_id: str = args["QueryExecutionId"] response = get_query_results(client=client, query_execution_id=query_execution_id) return CommandResults( outputs_prefix=f"AWS.Athena.{QUERY_RESULTS_OUTPUTS_KEY}", outputs=response, raw_response=response, readable_output=tableToMarkdown("AWS Athena Query Results", response), ) @polling_function( name=demisto.command(), interval=arg_to_number(demisto.args().get("interval_in_seconds", 10)), timeout=arg_to_number(demisto.args().get("timeout_in_seconds", 300)), requires_polling_arg=False, ) def execute_query_command(args: dict, client): if "QueryExecutionId" not in args: start_query_response = start_query_execution( client=client, query_string=args["QueryString"], query_limit=args.get("QueryLimit"), client_request_token=args.get("ClientRequestToken"), database=args.get("Database"), output_location=args.get("OutputLocation"), encryption_option=args.get("EncryptionOption"), kms_key=args.get("KmsKey"), work_group=args.get("WorkGroup"), ) query_execution_id = start_query_response["QueryExecutionId"] # If this is the first polling iteration, wait a second to allow the query to complete. # This saves time for most cases where waiting for the next poll (with a minimum of 10 seconds) is not necessary. time.sleep(1) else: query_execution_id = args["QueryExecutionId"] query_execution_response = get_query_execution(client=client, query_execution_id=query_execution_id) query_state = query_execution_response["Status"]["State"] if query_state in ("QUEUED", "RUNNING"): args["QueryExecutionId"] = query_execution_id return PollResult( response=None, continue_to_poll=True, args_for_next_run=args, partial_result=CommandResults(readable_output=f"Query is still running. Current state: '{query_state}'."), ) output_data: dict[str, Any] = {QUERY_DATA_OUTPUTS_KEY: query_execution_response} readable_output = None if query_state == "SUCCEEDED": query_results_response = get_query_results(client=client, query_execution_id=query_execution_id) output_data[QUERY_RESULTS_OUTPUTS_KEY] = query_results_response readable_output = tableToMarkdown("AWS Athena Query Results", query_results_response) elif query_state == "CANCELLED": readable_output = f"Query '{query_execution_id}' has been cancelled." elif query_state == "FAILED": readable_output = f"Query '{query_execution_id}' has failed." if query_execution_response["QueryExecution"]["Status"].get("AthenaError", {}).get("ErrorMessage"): error_message = query_execution_response["QueryExecution"]["Status"]["AthenaError"]["ErrorMessage"] readable_output += f"\nError: {error_message}" return PollResult( response=CommandResults( outputs_prefix="AWS.Athena", outputs=output_data, raw_response=output_data, readable_output=readable_output, ), continue_to_poll=False, ) def main(): # pragma: no cover params = demisto.params() args = demisto.args() command = demisto.command() aws_role_arn = params.get("roleArn") aws_role_session_name = params.get("roleSessionName") aws_default_region = params.get("defaultRegion") aws_role_session_duration = params.get("sessionDuration") aws_access_key_id = demisto.get(params, "credentials.identifier") or params.get("access_key") aws_secret_access_key = demisto.get(params, "credentials.password") or params.get("secret_key") verify_certificate = not params.get("insecure", True) timeout = params.get("timeout") retries = params.get("retries", 5) try: demisto.debug(f"Command being called is '{command}'.") aws_client = AWSClient( aws_default_region=aws_default_region, aws_role_arn=aws_role_arn, aws_role_session_name=aws_role_session_name, aws_role_session_duration=aws_role_session_duration, aws_role_policy=None, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, verify_certificate=verify_certificate, timeout=timeout, retries=retries, ) client = aws_client.aws_session( service=AWS_SERVICE_NAME, region=args.get("region"), role_arn=args.get("roleArn"), role_session_name=args.get("roleSessionName"), role_session_duration=args.get("roleSessionDuration"), ) result: str | CommandResults if command == "test-module": result = module_test_command(client) elif command == "aws-athena-start-query": result = start_query_command(args=args, client=client) elif command == "aws-athena-stop-query": result = stop_query_command(args=args, client=client) elif command == "aws-athena-get-query-execution": result = get_query_execution_command(args=args, client=client) elif command == "aws-athena-get-query-results": result = get_query_results_command(args=args, client=client) elif command == "aws-athena-execute-query": result = execute_query_command(args=args, client=client) else: raise NotImplementedError(f'Command "{command}" is not implemented.') return_results(result) except Exception as e: return_error(f"Error: {e}") from AWSApiModule import * # noqa: E402 if __name__ in ("__main__", "__builtin__", "builtins"): main()