UNPKG

@itentialopensource/adapter-snowflake_sql

Version:

This adapter integrates with system described as: snowflakeSqlApi.

836 lines (835 loc) 35.3 kB
openapi: 3.0.0 info: title: Snowflake SQL API description: 'The Snowflake SQL API is a REST API that you can use to access and update data in a Snowflake database. ' contact: name: Snowflake, Inc. url: https://snowflake.com email: support@snowflake.com version: '2.0.0' servers: - url: https://org-account.snowflakecomputing.com description: Snowflake SQL API V2 variables: {} paths: /api/v2/statements: post: tags: - statements summary: SubmitStatement description: Submits a single statement for execution. You can specify that the statement should be executed asynchronously. operationId: SubmitStatement parameters: - name: requestId in: query description: Unique ID of the API request. This ensures that the execution is idempotent. If not specified, a new UUID is generated and assigned. style: form explode: true schema: type: string format: uuid - name: async in: query description: Set to true to execute the statement asynchronously and return the statement handle. If the parameter is not specified or is set to false, a statement is executed and the first result is returned if the execution is completed in 45 seconds. If the statement execution takes longer to complete, the statement handle is returned. style: form explode: true schema: type: boolean example: true - name: nullable in: query description: Set to true to execute the statement to generate the result set including null. If the parameter is set to false, the result set value null will be replaced with a string 'null'. style: form explode: true schema: type: boolean example: true - name: Accept in: header description: The response payload format. The schema should be specified in resultSetMetaData in the request payload. style: simple schema: type: string example: application/json - name: User-Agent in: header description: Set this to the name and version of your application (e.g. “applicationName/applicationVersion”). You must use a value that complies with RFC 7231. required: true style: simple schema: type: string example: myApplication/1.0 - name: X-Snowflake-Authorization-Token-Type in: header description: Specify the authorization token type for the Authorization header. KEYPAIR_JWT is for Keypair JWT or OAUTH for oAuth token. If not specified, OAUTH is assumed. style: simple schema: type: string example: KEYPAIR_JWT requestBody: description: Specifies the SQL statement to execute and the statement context. content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiV2StatementsRequest' - description: Specifies the SQL statement to execute and the statement context. example: statement: select * from T where c1=? timeout: 10 database: TESTDB schema: TESTSCHEMA warehouse: TESTWH bindings: '1': type: FIXED value: '123' example: statement: select * from T where c1=? timeout: 10 database: TESTDB schema: TESTSCHEMA warehouse: TESTWH bindings: '1': type: FIXED value: '123' required: true responses: '200': description: The statement was executed successfully, and the response includes any data requested. headers: link: content: text/plain: schema: type: string example: </api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="last",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="next",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=0>;rel="first" example: </api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="last",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="next",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=0>;rel="first" content: application/json: schema: $ref: '#/components/schemas/ResultSet' '202': description: The execution of the statement is still in progress. Use GET /statements/ and specify the statement handle to check the status of the statement execution. headers: {} content: application/json: schema: $ref: '#/components/schemas/QueryStatus' '400': description: Bad Request. The request payload is invalid or malformed. This happens if the application didn't send the correct request payload. The response body may include the error code and message indicating the actual cause. The application must reconstruct the request body for retry. headers: {} content: {} '401': description: Unauthorized. The request is not authorized. This happens if the attached access token is invalid or missing. The response body may include the error code and message indicating the actual cause, e.g., expired, invalid token. The application must obtain a new access token for retry. headers: {} content: {} '403': description: Forbidden. The request is forbidden. This happens if the request is made even if the API is not enabled. headers: {} content: {} '404': description: Not Found. The request endpoint is not valid. This happens if the API endpoint is wrong. For example, if the application hits /api/api/hello which doesn't exist, it will receive this code. headers: {} content: {} '405': description: Method Not Allowed. The request method doesn't match the supported API. This happens, for example, if the application calls the API with GET method but the endpoint accepts only POST. The application must change a method for retry. headers: {} content: {} '408': description: The execution of the statement exceeded the timeout period. The execution of the statement was cancelled. headers: {} content: application/json: schema: $ref: '#/components/schemas/QueryStatus' '415': description: The request header Content-Type includes unsupported media type. The API supports application/json only. If none specified, the request payload is taken as JSON, but if any other media type is specified, this error is returned. headers: {} content: {} '422': description: An error occurred when executing the statement. Check the error code and error message for details. headers: {} content: application/json: schema: $ref: '#/components/schemas/QueryFailureStatus' '429': description: Limit Exceeded. The number of requests hit the rate limit. The application must slow down the frequency of hitting the API endpoints. headers: {} content: {} '500': description: Internal Server Error. The server hits an unrecoverable system error. The response body may include the error code and message for further guidance. The application owner may need to reach out the customer support. headers: {} content: {} '503': description: Service Unavailable. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} '504': description: Gateway Timeout. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} deprecated: false security: - keyPair: [] - ExternalOAuth: [] - snowflakeOAuth: [] /api/v2/statements/{statementHandle}: get: tags: - statements summary: GetStatementStatus description: Checks the status of the execution of the statement with the specified statement handle. If the statement was executed successfully, the operation returns the requested partition of the result set. operationId: GetStatementStatus parameters: - name: statementHandle in: path description: The handle of the statement that you want to use (e.g. to fetch the result set or cancel execution). required: true style: simple schema: type: string format: uuid example: e4ce975e-f7ff-4b5e-b15e-bf25f59371ae - name: requestId in: query description: Unique ID of the API request. This ensures that the execution is idempotent. If not specified, a new UUID is generated and assigned. style: form explode: true schema: type: string format: uuid - name: partition in: query description: Number of the partition of results to return. The number can range from 0 to the total number of partitions minus 1. style: form explode: true schema: minimum: 0 type: integer format: int64 example: 2 - name: Accept in: header description: The response payload format. The schema should be specified in resultSetMetaData in the request payload. style: simple schema: type: string example: application/json - name: User-Agent in: header description: Set this to the name and version of your application (e.g. “applicationName/applicationVersion”). You must use a value that complies with RFC 7231. required: true style: simple schema: type: string example: myApplication/1.0 - name: X-Snowflake-Authorization-Token-Type in: header description: Specify the authorization token type for the Authorization header. KEYPAIR_JWT is for Keypair JWT or OAUTH for oAuth token. If not specified, OAUTH is assumed. style: simple schema: type: string example: KEYPAIR_JWT responses: '200': description: The statement was executed successfully, and the response includes any data requested. headers: link: content: text/plain: schema: type: string example: </api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="last",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="next",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=0>;rel="first" example: </api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="last",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=1>;rel="next",</api/statements/e127cc7c-7812-4e72-9a55-3b4d4f969840/fetch?partition=0>;rel="first" content: application/json: schema: $ref: '#/components/schemas/ResultSet' '202': description: The execution of the statement is still in progress. Use this method again to check the status of the statement execution. headers: {} content: application/json: schema: $ref: '#/components/schemas/QueryStatus' '400': description: Bad Request. The request payload is invalid or malformed. This happens if the application didn't send the correct request payload. The response body may include the error code and message indicating the actual cause. The application must reconstruct the request body for retry. headers: {} content: {} '401': description: Unauthorized. The request is not authorized. This happens if the attached access token is invalid or missing. The response body may include the error code and message indicating the actual cause, e.g., expired, invalid token. The application must obtain a new access token for retry. headers: {} content: {} '403': description: Forbidden. The request is forbidden. This happens if the request is made even if the API is not enabled. headers: {} content: {} '404': description: Not Found. The request endpoint is not valid. This happens if the API endpoint is wrong. For example, if the application hits /api/api/hello which doesn't exist, it will receive this code. headers: {} content: {} '405': description: Method Not Allowed. The request method doesn't match the supported API. This happens, for example, if the application calls the API with GET method but the endpoint accepts only POST. The application must change a method for retry. headers: {} content: {} '415': description: The request header Content-Type includes unsupported media type. The API supports application/json only. If none specified, the request payload is taken as JSON, but if any other media type is specified, this error is returned. headers: {} content: {} '422': description: An error occurred when executing the statement. Check the error code and error message for details. headers: {} content: application/json: schema: $ref: '#/components/schemas/QueryFailureStatus' '429': description: Limit Exceeded. The number of requests hit the rate limit. The application must slow down the frequency of hitting the API endpoints. headers: {} content: {} '500': description: Internal Server Error. The server hits an unrecoverable system error. The response body may include the error code and message for further guidance. The application owner may need to reach out the customer support. headers: {} content: {} '503': description: Service Unavailable. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} '504': description: Gateway Timeout. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} deprecated: false security: - keyPair: [] - ExternalOAuth: [] - snowflakeOAuth: [] /api/v2/statements/{statementHandle}/cancel: post: tags: - statements summary: CancelStatement description: Cancels the execution of the statement with the specified statement handle. operationId: CancelStatement parameters: - name: statementHandle in: path description: The handle of the statement that you want to use (e.g. to fetch the result set or cancel execution). required: true style: simple schema: type: string format: uuid example: e4ce975e-f7ff-4b5e-b15e-bf25f59371ae - name: requestId in: query description: Unique ID of the API request. This ensures that the execution is idempotent. If not specified, a new UUID is generated and assigned. style: form explode: true schema: type: string format: uuid - name: Accept in: header description: The response payload format. The schema should be specified in resultSetMetaData in the request payload. style: simple schema: type: string example: application/json - name: User-Agent in: header description: Set this to the name and version of your application (e.g. “applicationName/applicationVersion”). You must use a value that complies with RFC 7231. required: true style: simple schema: type: string example: myApplication/1.0 - name: X-Snowflake-Authorization-Token-Type in: header description: Specify the authorization token type for the Authorization header. KEYPAIR_JWT is for Keypair JWT or OAUTH for oAuth token. If not specified, OAUTH is assumed. style: simple schema: type: string example: KEYPAIR_JWT responses: '200': description: The execution of the statement was successfully canceled. headers: {} content: application/json: schema: $ref: '#/components/schemas/CancelStatus' '400': description: Bad Request. The request payload is invalid or malformed. This happens if the application didn't send the correct request payload. The response body may include the error code and message indicating the actual cause. The application must reconstruct the request body for retry. headers: {} content: {} '401': description: Unauthorized. The request is not authorized. This happens if the attached access token is invalid or missing. The response body may include the error code and message indicating the actual cause, e.g., expired, invalid token. The application must obtain a new access token for retry. headers: {} content: {} '403': description: Forbidden. The request is forbidden. This happens if the request is made even if the API is not enabled. headers: {} content: {} '404': description: Not Found. The request endpoint is not valid. This happens if the API endpoint is wrong. For example, if the application hits /api/api/hello which doesn't exist, it will receive this code. headers: {} content: {} '405': description: Method Not Allowed. The request method doesn't match the supported API. This happens, for example, if the application calls the API with GET method but the endpoint accepts only POST. The application must change a method for retry. headers: {} content: {} '422': description: An error occurred when cancelling the execution of the statement. Check the error code and error message for details. headers: {} content: application/json: schema: $ref: '#/components/schemas/CancelStatus' '500': description: Internal Server Error. The server hits an unrecoverable system error. The response body may include the error code and message for further guidance. The application owner may need to reach out the customer support. headers: {} content: {} '503': description: Service Unavailable. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} '504': description: Gateway Timeout. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ headers: {} content: {} deprecated: false security: - keyPair: [] - ExternalOAuth: [] - snowflakeOAuth: [] components: schemas: QueryStatus: title: QueryStatus required: - statementHandle type: object properties: code: type: string sqlState: type: string message: type: string statementHandle: type: string format: uuid createdOn: type: integer description: Timestamp that specifies when the statement execution started. The timestamp is expressed in milliseconds since the epoch. format: int64 example: 1597090533987 statementStatusUrl: type: string description: URL that you can use to check the status of the execution of the statement and the result set. example: code: '000000' sqlState: '00000' message: successfully executed statementHandle: e4ce975e-f7ff-4b5e-b15e-bf25f59371ae createdOn: 1597090533987 statementStatusUrl: /api/v2/statements/e4ce975e-f7ff-4b5e-b15e-bf25f59371ae?requestId=f63f7776-71d8-4ae6-af69-8c0e54dcf906 QueryFailureStatus: title: QueryFailureStatus required: - message - statementHandle type: object properties: code: type: string sqlState: type: string message: type: string statementHandle: type: string format: uuid createdOn: type: integer description: Timestamp that specifies when the statement execution started.‌ The timestamp is expressed in milliseconds since the epoch. format: int64 statementStatusUrl: type: string example: code: '000123' sqlState: '42601' message: SQL compilation error statementHandle: e4ce975e-f7ff-4b5e-b15e-bf25f59371ae createdOn: 1597090533987 statementStatusUrl: /api/v2/statements/e4ce975e-f7ff-4b5e-b15e-bf25f59371ae CancelStatus: title: CancelStatus required: - statementHandle type: object properties: code: type: string sqlState: type: string message: type: string statementHandle: type: string format: uuid statementStatusUrl: type: string example: message: successfully canceled statementHandle: 536fad38-b564-4dc5-9892-a4543504df6c statementStatusUrl: /api/v2/statements/536fad38-b564-4dc5-9892-a4543504df6c ResultSet: title: ResultSet type: object properties: code: type: string example: '000123' sqlState: type: string example: '42601' message: type: string example: successfully executed statementHandle: type: string format: uuid example: 536fad38-b564-4dc5-9892-a4543504df6c createdOn: type: integer description: Timestamp that specifies when the statement execution started.‌ The timestamp is expressed in milliseconds since the epoch.‌ format: int64 example: 1597090533987 statementStatusUrl: type: string example: /api/v2/statements/536fad38-b564-4dc5-9892-a4543504df6c resultSetMetaData: $ref: '#/components/schemas/ResultSetMetaData' data: minItems: 0 type: array items: type: array items: type: string nullable: true description: Result set data. example: - - customer1 - 1234 A Avenue - '98765' - 2019-08-10 23:56:34.123 - - customer2 - 987 B Street - '98765' - 2019-08-11 09:45:12.890 - - customer3 - 8777 C Blvd - '98765' - 2019-08-12 10:23:51.999 - - customer4 - 64646 D Circle - '98765' - 2019-08-13 01:54:32.000 stats: allOf: - $ref: '#/components/schemas/Stats' - description: these stats might not be available for each request. ApiV2StatementsRequest: title: ApiV2StatementsRequest type: object properties: statement: type: string description: 'SQL statement or batch of SQL statements to execute. You can specify query, DML and DDL statements. The following statements are not supported: PUT, GET, USE, ALTER SESSION, BEGIN, COMMIT, ROLLBACK, statements that set session variables, and statements that create temporary tables and stages.' timeout: minimum: 0 type: integer description: Timeout in seconds for statement execution. If the execution of a statement takes longer than the specified timeout, the execution is automatically canceled. To set the timeout to the maximum value (604800 seconds), set timeout to 0. format: int64 example: 10 database: type: string description: Database in which the statement should be executed. The value in this field is case-sensitive. example: TESTDB schema: type: string description: Schema in which the statement should be executed. The value in this field is case-sensitive. example: TESTSCHEMA warehouse: type: string description: Warehouse to use when executing the statement. The value in this field is case-sensitive. example: TESTWH role: type: string description: Role to use when executing the statement. The value in this field is case-sensitive. example: TESTROLE bindings: type: object description: Values of bind variables in the SQL statement. When executing the statement, Snowflake replaces placeholders ('?' and ':name') in the statement with these specified values. example: '1': type: FIXED value: '123' '2': type: TEXT value: teststring parameters: allOf: - $ref: '#/components/schemas/Parameters1' - description: Session parameters that should be set before executing the statement. Format: title: Format enum: - jsonv2 type: string description: For v2 endpoints the only possible value for this field is jsonv2. example: jsonv2 Parameters: title: Parameters type: object properties: binary_output_format: type: string example: HEX date_output_format: type: string example: YYYY-MM-DD time_output_format: type: string example: HH24:MI:SS timestamp_output_format: type: string example: YYYY-MM-DD HH24:MI:SS.FF6 timestamp_ltz_output_format: type: string example: YYYY-MM-DD HH24:MI:SS.FF6 timestamp_ntz_output_format: type: string example: YYYY-MM-DD HH24:MI:SS.FF6 timestamp_tz_output_format: type: string example: YYYY-MM-DDTHH24:MI:SS.FF6 TZHTZM multi_statement_count: type: integer format: int32 example: 4 Parameters1: title: Parameters1 type: object properties: timezone: type: string description: Time zone to use when executing the statement. example: america/los_angeles query_tag: type: string description: Query tag that you want to associate with the SQL statement. example: tag-1234 binary_output_format: type: string description: Output format for binary values. example: HEX date_output_format: type: string description: Output format for DATE values. example: YYYY-MM-DD time_output_format: type: string description: Output format for TIME values. example: HH24:MI:SS.FF6 timestamp_output_format: type: string description: Output format for TIMESTAMP values. example: YYYY-MM-DDTHH24:MI:SS.FF6 timestamp_ltz_output_format: type: string description: Output format for TIMESTAMP_LTZ values. example: YYYY-MM-DDTHH24:MI:SS.FF6 timestamp_ntz_output_format: type: string description: Output format for TIMESTAMP_NTZ values. example: YYYY-MM-DDTHH24:MI:SS.FF6 timestamp_tz_output_format: type: string description: Output format for TIMESTAMP_TZ values. example: YYYY-MM-DDTHH24:MI:SS.FF6 TZHTZM multi_statement_count: type: integer description: Number of statements to execute when using multi-statement capability. 0 implies variable number of statements. Negative numbers are not allowed. format: int32 default: 1 example: 4 description: Session parameters that should be set before executing the statement. PartitionInfo: title: PartitionInfo type: object properties: rowCount: minimum: 0 type: integer description: Number of rows in the partition. format: int64 example: 1324 compressedSize: minimum: 0 type: integer description: the partition size before the decompression. This may or may not be present in the partitionInfo. Uncompressed size would always be there. format: int64 example: 37436824 uncompressedSize: minimum: 0 type: integer description: the partition size after the decompression format: int64 example: 1343787384 ResultSetMetaData: title: ResultSetMetaData type: object properties: format: allOf: - $ref: '#/components/schemas/Format' - description: For v2 endpoints the only possible value for this field is jsonv2. example: jsonv2 rowType: minItems: 1 type: array items: $ref: '#/components/schemas/RowType' description: '' example: - name: ROWNUM type: FIXED length: 0 precision: 38 scale: 0 nullable: false - name: ACCOUNT_ID type: FIXED length: 0 precision: 38 scale: 0 nullable: false - name: ACCOUNT_NAME type: TEXT length: 1024 precision: 0 scale: 0 nullable: false - name: ADDRESS type: TEXT length: 16777216 precision: 0 scale: 0 nullable: true - name: ZIP type: TEXT length: 100 precision: 0 scale: 0 nullable: true - name: CREATED_ON type: TIMESTAMP_NTZ length: 0 precision: 0 scale: 3 nullable: false partitionInfo: minItems: 0 type: array items: $ref: '#/components/schemas/PartitionInfo' description: Partition information nullable: type: boolean description: false if null is replaced with a string 'null' otherwise false parameters: $ref: '#/components/schemas/Parameters' RowType: title: RowType type: object properties: name: type: string type: type: string length: minimum: 0 type: integer format: int64 precision: minimum: 0 type: integer format: int64 scale: minimum: 0 type: integer format: int64 nullable: type: boolean Stats: title: Stats type: object properties: numRowsInserted: minimum: 0 type: integer description: Number of rows that were inserted. format: int64 example: 12 numRowsUpdated: minimum: 0 type: integer description: Number of rows that were updated. format: int64 example: 9 numRowsDeleted: minimum: 0 type: integer description: Number of rows that were deleted. format: int64 example: 8 numDuplicateRowsUpdated: minimum: 0 type: integer description: Number of duplicate rows that were updated. format: int64 example: 20 description: these stats might not be available for each request. securitySchemes: keyPair: type: http description: Set X-Snowflake-Authorization-Token-Type to KEYPAIR_JWT if the token is a key pair authn JWT. scheme: bearer bearerFormat: jwt ExternalOAuth: type: http description: Configure External Oauth with Snowflake (refer to docs). Set X-Snowflake-Authorization-Token-Type to OAUTH and set the Token to auth token received from the external Auth server. scheme: bearer bearerFormat: jwt snowflakeOAuth: type: oauth2 flows: implicit: authorizationUrl: https://org-account.snowflakecomputing.com/oauth/authorize scopes: {} security: - keyPair: [] - ExternalOAuth: [] - snowflakeOAuth: [] tags: - name: statements description: '' externalDocs: url: https://docs.snowflake.com/en/developer-guide/sql-api/index.html