capo-redshift-data 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- capo_redshift_data/__init__.py +72 -0
- capo_redshift_data/_async.py +25 -0
- capo_redshift_data/_auth/_identity.py +16 -0
- capo_redshift_data/_auth/_providers.py +886 -0
- capo_redshift_data/_auth/_signers.py +88 -0
- capo_redshift_data/_auth/_sigv4.py +434 -0
- capo_redshift_data/_auth/_zapros_handler.py +80 -0
- capo_redshift_data/_iter.py +113 -0
- capo_redshift_data/_operations/redshift_data/batch_execute_statement.py +181 -0
- capo_redshift_data/_operations/redshift_data/cancel_statement.py +173 -0
- capo_redshift_data/_operations/redshift_data/describe_statement.py +161 -0
- capo_redshift_data/_operations/redshift_data/describe_table.py +172 -0
- capo_redshift_data/_operations/redshift_data/execute_statement.py +178 -0
- capo_redshift_data/_operations/redshift_data/get_statement_result.py +161 -0
- capo_redshift_data/_operations/redshift_data/get_statement_result_v2.py +161 -0
- capo_redshift_data/_operations/redshift_data/list_databases.py +172 -0
- capo_redshift_data/_operations/redshift_data/list_schemas.py +170 -0
- capo_redshift_data/_operations/redshift_data/list_statements.py +162 -0
- capo_redshift_data/_operations/redshift_data/list_tables.py +170 -0
- capo_redshift_data/_pagination.py +21 -0
- capo_redshift_data/_protocol/__init__.py +1 -0
- capo_redshift_data/_protocol/errors.py +93 -0
- capo_redshift_data/_protocol/eventstream.py +238 -0
- capo_redshift_data/_protocol/serialize.py +47 -0
- capo_redshift_data/_protocol/xml.py +33 -0
- capo_redshift_data/_rule_engine/__init__.py +0 -0
- capo_redshift_data/_rule_engine/_aws_partition.py +160 -0
- capo_redshift_data/_rule_engine/_endpoint_rule_set.py +138 -0
- capo_redshift_data/_rule_engine/_endpoint_runtime.py +389 -0
- capo_redshift_data/_services/_aws_config.py +160 -0
- capo_redshift_data/_services/_pipeline.py +198 -0
- capo_redshift_data/_services/async_redshift_data.py +1251 -0
- capo_redshift_data/_services/redshift_data.py +1240 -0
- capo_redshift_data/errors/__init__.py +46 -0
- capo_redshift_data/errors/_base.py +94 -0
- capo_redshift_data/errors/active_sessions_exceeded_exception.py +53 -0
- capo_redshift_data/errors/active_statements_exceeded_exception.py +53 -0
- capo_redshift_data/errors/batch_execute_statement_exception.py +63 -0
- capo_redshift_data/errors/database_connection_exception.py +52 -0
- capo_redshift_data/errors/execute_statement_exception.py +60 -0
- capo_redshift_data/errors/internal_server_exception.py +53 -0
- capo_redshift_data/errors/query_timeout_exception.py +51 -0
- capo_redshift_data/errors/resource_not_found_exception.py +60 -0
- capo_redshift_data/errors/validation_exception.py +52 -0
- capo_redshift_data/py.typed +0 -0
- capo_redshift_data/types/_prelude/blob.py +12 -0
- capo_redshift_data/types/_prelude/timestamp.py +17 -0
- capo_redshift_data/types/batch_execute_statement_input.py +145 -0
- capo_redshift_data/types/batch_execute_statement_output.py +109 -0
- capo_redshift_data/types/blob.py +15 -0
- capo_redshift_data/types/bool.py +5 -0
- capo_redshift_data/types/boxed_boolean.py +5 -0
- capo_redshift_data/types/boxed_double.py +5 -0
- capo_redshift_data/types/boxed_long.py +5 -0
- capo_redshift_data/types/cancel_statement_request.py +31 -0
- capo_redshift_data/types/cancel_statement_response.py +23 -0
- capo_redshift_data/types/client_token.py +5 -0
- capo_redshift_data/types/cluster_identifier_string.py +5 -0
- capo_redshift_data/types/column_list.py +33 -0
- capo_redshift_data/types/column_metadata.py +109 -0
- capo_redshift_data/types/column_metadata_list.py +35 -0
- capo_redshift_data/types/database_list.py +17 -0
- capo_redshift_data/types/db_group_list.py +17 -0
- capo_redshift_data/types/describe_statement_request.py +31 -0
- capo_redshift_data/types/describe_statement_response.py +225 -0
- capo_redshift_data/types/describe_table_request.py +94 -0
- capo_redshift_data/types/describe_table_response.py +51 -0
- capo_redshift_data/types/execute_statement_input.py +137 -0
- capo_redshift_data/types/execute_statement_output.py +109 -0
- capo_redshift_data/types/field.py +105 -0
- capo_redshift_data/types/field_list.py +29 -0
- capo_redshift_data/types/formatted_sql_records.py +33 -0
- capo_redshift_data/types/get_statement_result_request.py +38 -0
- capo_redshift_data/types/get_statement_result_response.py +75 -0
- capo_redshift_data/types/get_statement_result_v2_request.py +38 -0
- capo_redshift_data/types/get_statement_result_v2_response.py +88 -0
- capo_redshift_data/types/integer.py +5 -0
- capo_redshift_data/types/list_databases_request.py +76 -0
- capo_redshift_data/types/list_databases_response.py +47 -0
- capo_redshift_data/types/list_schemas_request.py +88 -0
- capo_redshift_data/types/list_schemas_response.py +43 -0
- capo_redshift_data/types/list_statements_limit.py +5 -0
- capo_redshift_data/types/list_statements_request.py +82 -0
- capo_redshift_data/types/list_statements_response.py +48 -0
- capo_redshift_data/types/list_tables_request.py +94 -0
- capo_redshift_data/types/list_tables_response.py +43 -0
- capo_redshift_data/types/long.py +5 -0
- capo_redshift_data/types/page_size.py +5 -0
- capo_redshift_data/types/parameter_name.py +5 -0
- capo_redshift_data/types/parameter_value.py +5 -0
- capo_redshift_data/types/query_records.py +32 -0
- capo_redshift_data/types/result_format_string.py +5 -0
- capo_redshift_data/types/schema_list.py +17 -0
- capo_redshift_data/types/secret_arn.py +5 -0
- capo_redshift_data/types/session_alive_seconds.py +5 -0
- capo_redshift_data/types/sql_list.py +17 -0
- capo_redshift_data/types/sql_parameter.py +39 -0
- capo_redshift_data/types/sql_parameters_list.py +33 -0
- capo_redshift_data/types/sql_records.py +29 -0
- capo_redshift_data/types/statement_data.py +164 -0
- capo_redshift_data/types/statement_list.py +31 -0
- capo_redshift_data/types/statement_name_string.py +5 -0
- capo_redshift_data/types/statement_status_string.py +5 -0
- capo_redshift_data/types/statement_string.py +5 -0
- capo_redshift_data/types/statement_string_list.py +19 -0
- capo_redshift_data/types/status_string.py +5 -0
- capo_redshift_data/types/string.py +5 -0
- capo_redshift_data/types/sub_statement_data.py +129 -0
- capo_redshift_data/types/sub_statement_list.py +35 -0
- capo_redshift_data/types/table_list.py +29 -0
- capo_redshift_data/types/table_member.py +40 -0
- capo_redshift_data/types/uuid.py +5 -0
- capo_redshift_data/types/workgroup_name_string.py +5 -0
- capo_redshift_data-0.1.0.dist-info/METADATA +101 -0
- capo_redshift_data-0.1.0.dist-info/RECORD +118 -0
- capo_redshift_data-0.1.0.dist-info/WHEEL +5 -0
- capo_redshift_data-0.1.0.dist-info/licenses/LICENSE +21 -0
- capo_redshift_data-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""Generated from Smithy shape ``com.amazonaws.redshiftdata#ListDatabases``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import zapros
|
|
9
|
+
from typing_extensions import Never
|
|
10
|
+
|
|
11
|
+
import capo_redshift_data._auth._signers
|
|
12
|
+
import capo_redshift_data._auth._sigv4
|
|
13
|
+
import capo_redshift_data._protocol.eventstream
|
|
14
|
+
import capo_redshift_data.errors.database_connection_exception
|
|
15
|
+
import capo_redshift_data.errors.internal_server_exception
|
|
16
|
+
import capo_redshift_data.errors.query_timeout_exception
|
|
17
|
+
import capo_redshift_data.errors.resource_not_found_exception
|
|
18
|
+
import capo_redshift_data.errors.validation_exception
|
|
19
|
+
import capo_redshift_data.types.database_list
|
|
20
|
+
import capo_redshift_data.types.list_databases_request
|
|
21
|
+
import capo_redshift_data.types.list_databases_response
|
|
22
|
+
from capo_redshift_data._protocol.errors import parse_error_metadata_json
|
|
23
|
+
from capo_redshift_data._rule_engine._endpoint_rule_set import EndpointParams, resolve
|
|
24
|
+
from capo_redshift_data._services._pipeline import (
|
|
25
|
+
AsyncOperationOptions,
|
|
26
|
+
OperationOptions,
|
|
27
|
+
)
|
|
28
|
+
from capo_redshift_data.errors import UnknownServiceError
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def handle_error(response: zapros.Response) -> Never:
|
|
32
|
+
data = json.loads(response.read())
|
|
33
|
+
code, message = parse_error_metadata_json(response, data)
|
|
34
|
+
match code:
|
|
35
|
+
case "DatabaseConnectionException":
|
|
36
|
+
raise capo_redshift_data.errors.database_connection_exception.DatabaseConnectionException.from_aws_json_1_1(
|
|
37
|
+
data, message
|
|
38
|
+
)
|
|
39
|
+
case "InternalServerException":
|
|
40
|
+
raise capo_redshift_data.errors.internal_server_exception.InternalServerException.from_aws_json_1_1(
|
|
41
|
+
data, message
|
|
42
|
+
)
|
|
43
|
+
case "QueryTimeoutException":
|
|
44
|
+
raise capo_redshift_data.errors.query_timeout_exception.QueryTimeoutException.from_aws_json_1_1(
|
|
45
|
+
data, message
|
|
46
|
+
)
|
|
47
|
+
case "ResourceNotFoundException":
|
|
48
|
+
raise capo_redshift_data.errors.resource_not_found_exception.ResourceNotFoundException.from_aws_json_1_1(
|
|
49
|
+
data, message
|
|
50
|
+
)
|
|
51
|
+
case "ValidationException":
|
|
52
|
+
raise capo_redshift_data.errors.validation_exception.ValidationException.from_aws_json_1_1(
|
|
53
|
+
data, message
|
|
54
|
+
)
|
|
55
|
+
case _:
|
|
56
|
+
raise UnknownServiceError(code=code, message=message, response=response)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def handle_response(
|
|
60
|
+
response: zapros.Response,
|
|
61
|
+
) -> capo_redshift_data.types.list_databases_response.ListDatabasesResponse:
|
|
62
|
+
out: capo_redshift_data.types.list_databases_response.ListDatabasesResponse = (
|
|
63
|
+
capo_redshift_data.types.list_databases_response.deserialize_aws_json_1_1(
|
|
64
|
+
json.loads(response.read())
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
return out
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def async_handle_response(
|
|
71
|
+
response: zapros.Response,
|
|
72
|
+
) -> capo_redshift_data.types.list_databases_response.ListDatabasesResponse:
|
|
73
|
+
out: capo_redshift_data.types.list_databases_response.ListDatabasesResponse = (
|
|
74
|
+
capo_redshift_data.types.list_databases_response.deserialize_aws_json_1_1(
|
|
75
|
+
json.loads(await response.aread())
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
return out
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_signer(
|
|
82
|
+
options: AsyncOperationOptions | OperationOptions,
|
|
83
|
+
auth_schemes: list[dict[str, Any]] | None = None,
|
|
84
|
+
) -> capo_redshift_data._auth._signers.Signer | None:
|
|
85
|
+
name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
|
|
86
|
+
if (
|
|
87
|
+
options.credentials_provider is not None
|
|
88
|
+
and name_to_schema
|
|
89
|
+
and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
|
|
90
|
+
):
|
|
91
|
+
raise RuntimeError(
|
|
92
|
+
"Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
|
|
93
|
+
)
|
|
94
|
+
if options.credentials_provider is not None:
|
|
95
|
+
endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
|
|
96
|
+
"sigv4-s3express"
|
|
97
|
+
)
|
|
98
|
+
if endpoint_scheme is not None or not name_to_schema:
|
|
99
|
+
sigv4_config = capo_redshift_data._auth._sigv4.build_sigv4_auth_scheme(
|
|
100
|
+
"redshift-data", options.region, endpoint_scheme
|
|
101
|
+
)
|
|
102
|
+
if sigv4_config is not None:
|
|
103
|
+
return capo_redshift_data._auth._signers.SigV4Signer(
|
|
104
|
+
options.credentials_provider, auth_scheme=sigv4_config
|
|
105
|
+
)
|
|
106
|
+
raise RuntimeError("Auth was not resolved")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def build_request(
|
|
110
|
+
options: OperationOptions | AsyncOperationOptions,
|
|
111
|
+
input_: capo_redshift_data.types.list_databases_request.ListDatabasesRequest,
|
|
112
|
+
) -> zapros.Request:
|
|
113
|
+
endpoint = resolve(
|
|
114
|
+
EndpointParams(
|
|
115
|
+
Region=options.region,
|
|
116
|
+
UseDualStack=options.use_dual_stack,
|
|
117
|
+
UseFIPS=options.use_fips,
|
|
118
|
+
Endpoint=options.endpoint,
|
|
119
|
+
)
|
|
120
|
+
) # noqa: F841
|
|
121
|
+
url = endpoint.url.rstrip("/") + ""
|
|
122
|
+
params: list[tuple[str, str]] = []
|
|
123
|
+
headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
|
|
124
|
+
headers["X-Amz-Target"] = "RedshiftData.ListDatabases"
|
|
125
|
+
body: bytes | None = json.dumps(
|
|
126
|
+
capo_redshift_data.types.list_databases_request.serialize_aws_json_1_1(input_),
|
|
127
|
+
allow_nan=False,
|
|
128
|
+
).encode()
|
|
129
|
+
headers["content-type"] = "application/x-amz-json-1.1"
|
|
130
|
+
signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
|
|
131
|
+
normalized_url = zapros.URL(url)
|
|
132
|
+
for k, v in params:
|
|
133
|
+
normalized_url.search_params.append(k, v)
|
|
134
|
+
return zapros.Request(
|
|
135
|
+
normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def list_databases(
|
|
140
|
+
options: OperationOptions,
|
|
141
|
+
input_: capo_redshift_data.types.list_databases_request.ListDatabasesRequest,
|
|
142
|
+
) -> tuple[
|
|
143
|
+
capo_redshift_data.types.list_databases_response.ListDatabasesResponse,
|
|
144
|
+
zapros.Response,
|
|
145
|
+
]:
|
|
146
|
+
response = options.client.handler.handle(build_request(options, input_))
|
|
147
|
+
try:
|
|
148
|
+
if response.status >= 300:
|
|
149
|
+
response.read()
|
|
150
|
+
handle_error(response)
|
|
151
|
+
return handle_response(response), response
|
|
152
|
+
except BaseException:
|
|
153
|
+
response.close()
|
|
154
|
+
raise
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
async def async_list_databases(
|
|
158
|
+
options: AsyncOperationOptions,
|
|
159
|
+
input_: capo_redshift_data.types.list_databases_request.ListDatabasesRequest,
|
|
160
|
+
) -> tuple[
|
|
161
|
+
capo_redshift_data.types.list_databases_response.ListDatabasesResponse,
|
|
162
|
+
zapros.Response,
|
|
163
|
+
]:
|
|
164
|
+
response = await options.client.handler.ahandle(build_request(options, input_))
|
|
165
|
+
try:
|
|
166
|
+
if response.status >= 300:
|
|
167
|
+
await response.aread()
|
|
168
|
+
handle_error(response)
|
|
169
|
+
return await async_handle_response(response), response
|
|
170
|
+
except BaseException:
|
|
171
|
+
await response.aclose()
|
|
172
|
+
raise
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Generated from Smithy shape ``com.amazonaws.redshiftdata#ListSchemas``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import zapros
|
|
9
|
+
from typing_extensions import Never
|
|
10
|
+
|
|
11
|
+
import capo_redshift_data._auth._signers
|
|
12
|
+
import capo_redshift_data._auth._sigv4
|
|
13
|
+
import capo_redshift_data._protocol.eventstream
|
|
14
|
+
import capo_redshift_data.errors.database_connection_exception
|
|
15
|
+
import capo_redshift_data.errors.internal_server_exception
|
|
16
|
+
import capo_redshift_data.errors.query_timeout_exception
|
|
17
|
+
import capo_redshift_data.errors.resource_not_found_exception
|
|
18
|
+
import capo_redshift_data.errors.validation_exception
|
|
19
|
+
import capo_redshift_data.types.list_schemas_request
|
|
20
|
+
import capo_redshift_data.types.list_schemas_response
|
|
21
|
+
import capo_redshift_data.types.schema_list
|
|
22
|
+
from capo_redshift_data._protocol.errors import parse_error_metadata_json
|
|
23
|
+
from capo_redshift_data._rule_engine._endpoint_rule_set import EndpointParams, resolve
|
|
24
|
+
from capo_redshift_data._services._pipeline import (
|
|
25
|
+
AsyncOperationOptions,
|
|
26
|
+
OperationOptions,
|
|
27
|
+
)
|
|
28
|
+
from capo_redshift_data.errors import UnknownServiceError
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def handle_error(response: zapros.Response) -> Never:
|
|
32
|
+
data = json.loads(response.read())
|
|
33
|
+
code, message = parse_error_metadata_json(response, data)
|
|
34
|
+
match code:
|
|
35
|
+
case "DatabaseConnectionException":
|
|
36
|
+
raise capo_redshift_data.errors.database_connection_exception.DatabaseConnectionException.from_aws_json_1_1(
|
|
37
|
+
data, message
|
|
38
|
+
)
|
|
39
|
+
case "InternalServerException":
|
|
40
|
+
raise capo_redshift_data.errors.internal_server_exception.InternalServerException.from_aws_json_1_1(
|
|
41
|
+
data, message
|
|
42
|
+
)
|
|
43
|
+
case "QueryTimeoutException":
|
|
44
|
+
raise capo_redshift_data.errors.query_timeout_exception.QueryTimeoutException.from_aws_json_1_1(
|
|
45
|
+
data, message
|
|
46
|
+
)
|
|
47
|
+
case "ResourceNotFoundException":
|
|
48
|
+
raise capo_redshift_data.errors.resource_not_found_exception.ResourceNotFoundException.from_aws_json_1_1(
|
|
49
|
+
data, message
|
|
50
|
+
)
|
|
51
|
+
case "ValidationException":
|
|
52
|
+
raise capo_redshift_data.errors.validation_exception.ValidationException.from_aws_json_1_1(
|
|
53
|
+
data, message
|
|
54
|
+
)
|
|
55
|
+
case _:
|
|
56
|
+
raise UnknownServiceError(code=code, message=message, response=response)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def handle_response(
|
|
60
|
+
response: zapros.Response,
|
|
61
|
+
) -> capo_redshift_data.types.list_schemas_response.ListSchemasResponse:
|
|
62
|
+
out: capo_redshift_data.types.list_schemas_response.ListSchemasResponse = (
|
|
63
|
+
capo_redshift_data.types.list_schemas_response.deserialize_aws_json_1_1(
|
|
64
|
+
json.loads(response.read())
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
return out
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def async_handle_response(
|
|
71
|
+
response: zapros.Response,
|
|
72
|
+
) -> capo_redshift_data.types.list_schemas_response.ListSchemasResponse:
|
|
73
|
+
out: capo_redshift_data.types.list_schemas_response.ListSchemasResponse = (
|
|
74
|
+
capo_redshift_data.types.list_schemas_response.deserialize_aws_json_1_1(
|
|
75
|
+
json.loads(await response.aread())
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
return out
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_signer(
|
|
82
|
+
options: AsyncOperationOptions | OperationOptions,
|
|
83
|
+
auth_schemes: list[dict[str, Any]] | None = None,
|
|
84
|
+
) -> capo_redshift_data._auth._signers.Signer | None:
|
|
85
|
+
name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
|
|
86
|
+
if (
|
|
87
|
+
options.credentials_provider is not None
|
|
88
|
+
and name_to_schema
|
|
89
|
+
and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
|
|
90
|
+
):
|
|
91
|
+
raise RuntimeError(
|
|
92
|
+
"Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
|
|
93
|
+
)
|
|
94
|
+
if options.credentials_provider is not None:
|
|
95
|
+
endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
|
|
96
|
+
"sigv4-s3express"
|
|
97
|
+
)
|
|
98
|
+
if endpoint_scheme is not None or not name_to_schema:
|
|
99
|
+
sigv4_config = capo_redshift_data._auth._sigv4.build_sigv4_auth_scheme(
|
|
100
|
+
"redshift-data", options.region, endpoint_scheme
|
|
101
|
+
)
|
|
102
|
+
if sigv4_config is not None:
|
|
103
|
+
return capo_redshift_data._auth._signers.SigV4Signer(
|
|
104
|
+
options.credentials_provider, auth_scheme=sigv4_config
|
|
105
|
+
)
|
|
106
|
+
raise RuntimeError("Auth was not resolved")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def build_request(
|
|
110
|
+
options: OperationOptions | AsyncOperationOptions,
|
|
111
|
+
input_: capo_redshift_data.types.list_schemas_request.ListSchemasRequest,
|
|
112
|
+
) -> zapros.Request:
|
|
113
|
+
endpoint = resolve(
|
|
114
|
+
EndpointParams(
|
|
115
|
+
Region=options.region,
|
|
116
|
+
UseDualStack=options.use_dual_stack,
|
|
117
|
+
UseFIPS=options.use_fips,
|
|
118
|
+
Endpoint=options.endpoint,
|
|
119
|
+
)
|
|
120
|
+
) # noqa: F841
|
|
121
|
+
url = endpoint.url.rstrip("/") + ""
|
|
122
|
+
params: list[tuple[str, str]] = []
|
|
123
|
+
headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
|
|
124
|
+
headers["X-Amz-Target"] = "RedshiftData.ListSchemas"
|
|
125
|
+
body: bytes | None = json.dumps(
|
|
126
|
+
capo_redshift_data.types.list_schemas_request.serialize_aws_json_1_1(input_),
|
|
127
|
+
allow_nan=False,
|
|
128
|
+
).encode()
|
|
129
|
+
headers["content-type"] = "application/x-amz-json-1.1"
|
|
130
|
+
signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
|
|
131
|
+
normalized_url = zapros.URL(url)
|
|
132
|
+
for k, v in params:
|
|
133
|
+
normalized_url.search_params.append(k, v)
|
|
134
|
+
return zapros.Request(
|
|
135
|
+
normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def list_schemas(
|
|
140
|
+
options: OperationOptions,
|
|
141
|
+
input_: capo_redshift_data.types.list_schemas_request.ListSchemasRequest,
|
|
142
|
+
) -> tuple[
|
|
143
|
+
capo_redshift_data.types.list_schemas_response.ListSchemasResponse, zapros.Response
|
|
144
|
+
]:
|
|
145
|
+
response = options.client.handler.handle(build_request(options, input_))
|
|
146
|
+
try:
|
|
147
|
+
if response.status >= 300:
|
|
148
|
+
response.read()
|
|
149
|
+
handle_error(response)
|
|
150
|
+
return handle_response(response), response
|
|
151
|
+
except BaseException:
|
|
152
|
+
response.close()
|
|
153
|
+
raise
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
async def async_list_schemas(
|
|
157
|
+
options: AsyncOperationOptions,
|
|
158
|
+
input_: capo_redshift_data.types.list_schemas_request.ListSchemasRequest,
|
|
159
|
+
) -> tuple[
|
|
160
|
+
capo_redshift_data.types.list_schemas_response.ListSchemasResponse, zapros.Response
|
|
161
|
+
]:
|
|
162
|
+
response = await options.client.handler.ahandle(build_request(options, input_))
|
|
163
|
+
try:
|
|
164
|
+
if response.status >= 300:
|
|
165
|
+
await response.aread()
|
|
166
|
+
handle_error(response)
|
|
167
|
+
return await async_handle_response(response), response
|
|
168
|
+
except BaseException:
|
|
169
|
+
await response.aclose()
|
|
170
|
+
raise
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""Generated from Smithy shape ``com.amazonaws.redshiftdata#ListStatements``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import zapros
|
|
9
|
+
from typing_extensions import Never
|
|
10
|
+
|
|
11
|
+
import capo_redshift_data._auth._signers
|
|
12
|
+
import capo_redshift_data._auth._sigv4
|
|
13
|
+
import capo_redshift_data._protocol.eventstream
|
|
14
|
+
import capo_redshift_data.errors.internal_server_exception
|
|
15
|
+
import capo_redshift_data.errors.resource_not_found_exception
|
|
16
|
+
import capo_redshift_data.errors.validation_exception
|
|
17
|
+
import capo_redshift_data.types.list_statements_request
|
|
18
|
+
import capo_redshift_data.types.list_statements_response
|
|
19
|
+
import capo_redshift_data.types.statement_list
|
|
20
|
+
from capo_redshift_data._protocol.errors import parse_error_metadata_json
|
|
21
|
+
from capo_redshift_data._rule_engine._endpoint_rule_set import EndpointParams, resolve
|
|
22
|
+
from capo_redshift_data._services._pipeline import (
|
|
23
|
+
AsyncOperationOptions,
|
|
24
|
+
OperationOptions,
|
|
25
|
+
)
|
|
26
|
+
from capo_redshift_data.errors import UnknownServiceError
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def handle_error(response: zapros.Response) -> Never:
|
|
30
|
+
data = json.loads(response.read())
|
|
31
|
+
code, message = parse_error_metadata_json(response, data)
|
|
32
|
+
match code:
|
|
33
|
+
case "InternalServerException":
|
|
34
|
+
raise capo_redshift_data.errors.internal_server_exception.InternalServerException.from_aws_json_1_1(
|
|
35
|
+
data, message
|
|
36
|
+
)
|
|
37
|
+
case "ResourceNotFoundException":
|
|
38
|
+
raise capo_redshift_data.errors.resource_not_found_exception.ResourceNotFoundException.from_aws_json_1_1(
|
|
39
|
+
data, message
|
|
40
|
+
)
|
|
41
|
+
case "ValidationException":
|
|
42
|
+
raise capo_redshift_data.errors.validation_exception.ValidationException.from_aws_json_1_1(
|
|
43
|
+
data, message
|
|
44
|
+
)
|
|
45
|
+
case _:
|
|
46
|
+
raise UnknownServiceError(code=code, message=message, response=response)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def handle_response(
|
|
50
|
+
response: zapros.Response,
|
|
51
|
+
) -> capo_redshift_data.types.list_statements_response.ListStatementsResponse:
|
|
52
|
+
out: capo_redshift_data.types.list_statements_response.ListStatementsResponse = (
|
|
53
|
+
capo_redshift_data.types.list_statements_response.deserialize_aws_json_1_1(
|
|
54
|
+
json.loads(response.read())
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
return out
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def async_handle_response(
|
|
61
|
+
response: zapros.Response,
|
|
62
|
+
) -> capo_redshift_data.types.list_statements_response.ListStatementsResponse:
|
|
63
|
+
out: capo_redshift_data.types.list_statements_response.ListStatementsResponse = (
|
|
64
|
+
capo_redshift_data.types.list_statements_response.deserialize_aws_json_1_1(
|
|
65
|
+
json.loads(await response.aread())
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
return out
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_signer(
|
|
72
|
+
options: AsyncOperationOptions | OperationOptions,
|
|
73
|
+
auth_schemes: list[dict[str, Any]] | None = None,
|
|
74
|
+
) -> capo_redshift_data._auth._signers.Signer | None:
|
|
75
|
+
name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
|
|
76
|
+
if (
|
|
77
|
+
options.credentials_provider is not None
|
|
78
|
+
and name_to_schema
|
|
79
|
+
and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
|
|
80
|
+
):
|
|
81
|
+
raise RuntimeError(
|
|
82
|
+
"Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
|
|
83
|
+
)
|
|
84
|
+
if options.credentials_provider is not None:
|
|
85
|
+
endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
|
|
86
|
+
"sigv4-s3express"
|
|
87
|
+
)
|
|
88
|
+
if endpoint_scheme is not None or not name_to_schema:
|
|
89
|
+
sigv4_config = capo_redshift_data._auth._sigv4.build_sigv4_auth_scheme(
|
|
90
|
+
"redshift-data", options.region, endpoint_scheme
|
|
91
|
+
)
|
|
92
|
+
if sigv4_config is not None:
|
|
93
|
+
return capo_redshift_data._auth._signers.SigV4Signer(
|
|
94
|
+
options.credentials_provider, auth_scheme=sigv4_config
|
|
95
|
+
)
|
|
96
|
+
raise RuntimeError("Auth was not resolved")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def build_request(
|
|
100
|
+
options: OperationOptions | AsyncOperationOptions,
|
|
101
|
+
input_: capo_redshift_data.types.list_statements_request.ListStatementsRequest,
|
|
102
|
+
) -> zapros.Request:
|
|
103
|
+
endpoint = resolve(
|
|
104
|
+
EndpointParams(
|
|
105
|
+
Region=options.region,
|
|
106
|
+
UseDualStack=options.use_dual_stack,
|
|
107
|
+
UseFIPS=options.use_fips,
|
|
108
|
+
Endpoint=options.endpoint,
|
|
109
|
+
)
|
|
110
|
+
) # noqa: F841
|
|
111
|
+
url = endpoint.url.rstrip("/") + ""
|
|
112
|
+
params: list[tuple[str, str]] = []
|
|
113
|
+
headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
|
|
114
|
+
headers["X-Amz-Target"] = "RedshiftData.ListStatements"
|
|
115
|
+
body: bytes | None = json.dumps(
|
|
116
|
+
capo_redshift_data.types.list_statements_request.serialize_aws_json_1_1(input_),
|
|
117
|
+
allow_nan=False,
|
|
118
|
+
).encode()
|
|
119
|
+
headers["content-type"] = "application/x-amz-json-1.1"
|
|
120
|
+
signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
|
|
121
|
+
normalized_url = zapros.URL(url)
|
|
122
|
+
for k, v in params:
|
|
123
|
+
normalized_url.search_params.append(k, v)
|
|
124
|
+
return zapros.Request(
|
|
125
|
+
normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def list_statements(
|
|
130
|
+
options: OperationOptions,
|
|
131
|
+
input_: capo_redshift_data.types.list_statements_request.ListStatementsRequest,
|
|
132
|
+
) -> tuple[
|
|
133
|
+
capo_redshift_data.types.list_statements_response.ListStatementsResponse,
|
|
134
|
+
zapros.Response,
|
|
135
|
+
]:
|
|
136
|
+
response = options.client.handler.handle(build_request(options, input_))
|
|
137
|
+
try:
|
|
138
|
+
if response.status >= 300:
|
|
139
|
+
response.read()
|
|
140
|
+
handle_error(response)
|
|
141
|
+
return handle_response(response), response
|
|
142
|
+
except BaseException:
|
|
143
|
+
response.close()
|
|
144
|
+
raise
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
async def async_list_statements(
|
|
148
|
+
options: AsyncOperationOptions,
|
|
149
|
+
input_: capo_redshift_data.types.list_statements_request.ListStatementsRequest,
|
|
150
|
+
) -> tuple[
|
|
151
|
+
capo_redshift_data.types.list_statements_response.ListStatementsResponse,
|
|
152
|
+
zapros.Response,
|
|
153
|
+
]:
|
|
154
|
+
response = await options.client.handler.ahandle(build_request(options, input_))
|
|
155
|
+
try:
|
|
156
|
+
if response.status >= 300:
|
|
157
|
+
await response.aread()
|
|
158
|
+
handle_error(response)
|
|
159
|
+
return await async_handle_response(response), response
|
|
160
|
+
except BaseException:
|
|
161
|
+
await response.aclose()
|
|
162
|
+
raise
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Generated from Smithy shape ``com.amazonaws.redshiftdata#ListTables``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import zapros
|
|
9
|
+
from typing_extensions import Never
|
|
10
|
+
|
|
11
|
+
import capo_redshift_data._auth._signers
|
|
12
|
+
import capo_redshift_data._auth._sigv4
|
|
13
|
+
import capo_redshift_data._protocol.eventstream
|
|
14
|
+
import capo_redshift_data.errors.database_connection_exception
|
|
15
|
+
import capo_redshift_data.errors.internal_server_exception
|
|
16
|
+
import capo_redshift_data.errors.query_timeout_exception
|
|
17
|
+
import capo_redshift_data.errors.resource_not_found_exception
|
|
18
|
+
import capo_redshift_data.errors.validation_exception
|
|
19
|
+
import capo_redshift_data.types.list_tables_request
|
|
20
|
+
import capo_redshift_data.types.list_tables_response
|
|
21
|
+
import capo_redshift_data.types.table_list
|
|
22
|
+
from capo_redshift_data._protocol.errors import parse_error_metadata_json
|
|
23
|
+
from capo_redshift_data._rule_engine._endpoint_rule_set import EndpointParams, resolve
|
|
24
|
+
from capo_redshift_data._services._pipeline import (
|
|
25
|
+
AsyncOperationOptions,
|
|
26
|
+
OperationOptions,
|
|
27
|
+
)
|
|
28
|
+
from capo_redshift_data.errors import UnknownServiceError
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def handle_error(response: zapros.Response) -> Never:
|
|
32
|
+
data = json.loads(response.read())
|
|
33
|
+
code, message = parse_error_metadata_json(response, data)
|
|
34
|
+
match code:
|
|
35
|
+
case "DatabaseConnectionException":
|
|
36
|
+
raise capo_redshift_data.errors.database_connection_exception.DatabaseConnectionException.from_aws_json_1_1(
|
|
37
|
+
data, message
|
|
38
|
+
)
|
|
39
|
+
case "InternalServerException":
|
|
40
|
+
raise capo_redshift_data.errors.internal_server_exception.InternalServerException.from_aws_json_1_1(
|
|
41
|
+
data, message
|
|
42
|
+
)
|
|
43
|
+
case "QueryTimeoutException":
|
|
44
|
+
raise capo_redshift_data.errors.query_timeout_exception.QueryTimeoutException.from_aws_json_1_1(
|
|
45
|
+
data, message
|
|
46
|
+
)
|
|
47
|
+
case "ResourceNotFoundException":
|
|
48
|
+
raise capo_redshift_data.errors.resource_not_found_exception.ResourceNotFoundException.from_aws_json_1_1(
|
|
49
|
+
data, message
|
|
50
|
+
)
|
|
51
|
+
case "ValidationException":
|
|
52
|
+
raise capo_redshift_data.errors.validation_exception.ValidationException.from_aws_json_1_1(
|
|
53
|
+
data, message
|
|
54
|
+
)
|
|
55
|
+
case _:
|
|
56
|
+
raise UnknownServiceError(code=code, message=message, response=response)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def handle_response(
|
|
60
|
+
response: zapros.Response,
|
|
61
|
+
) -> capo_redshift_data.types.list_tables_response.ListTablesResponse:
|
|
62
|
+
out: capo_redshift_data.types.list_tables_response.ListTablesResponse = (
|
|
63
|
+
capo_redshift_data.types.list_tables_response.deserialize_aws_json_1_1(
|
|
64
|
+
json.loads(response.read())
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
return out
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def async_handle_response(
|
|
71
|
+
response: zapros.Response,
|
|
72
|
+
) -> capo_redshift_data.types.list_tables_response.ListTablesResponse:
|
|
73
|
+
out: capo_redshift_data.types.list_tables_response.ListTablesResponse = (
|
|
74
|
+
capo_redshift_data.types.list_tables_response.deserialize_aws_json_1_1(
|
|
75
|
+
json.loads(await response.aread())
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
return out
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_signer(
|
|
82
|
+
options: AsyncOperationOptions | OperationOptions,
|
|
83
|
+
auth_schemes: list[dict[str, Any]] | None = None,
|
|
84
|
+
) -> capo_redshift_data._auth._signers.Signer | None:
|
|
85
|
+
name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
|
|
86
|
+
if (
|
|
87
|
+
options.credentials_provider is not None
|
|
88
|
+
and name_to_schema
|
|
89
|
+
and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
|
|
90
|
+
):
|
|
91
|
+
raise RuntimeError(
|
|
92
|
+
"Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
|
|
93
|
+
)
|
|
94
|
+
if options.credentials_provider is not None:
|
|
95
|
+
endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
|
|
96
|
+
"sigv4-s3express"
|
|
97
|
+
)
|
|
98
|
+
if endpoint_scheme is not None or not name_to_schema:
|
|
99
|
+
sigv4_config = capo_redshift_data._auth._sigv4.build_sigv4_auth_scheme(
|
|
100
|
+
"redshift-data", options.region, endpoint_scheme
|
|
101
|
+
)
|
|
102
|
+
if sigv4_config is not None:
|
|
103
|
+
return capo_redshift_data._auth._signers.SigV4Signer(
|
|
104
|
+
options.credentials_provider, auth_scheme=sigv4_config
|
|
105
|
+
)
|
|
106
|
+
raise RuntimeError("Auth was not resolved")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def build_request(
|
|
110
|
+
options: OperationOptions | AsyncOperationOptions,
|
|
111
|
+
input_: capo_redshift_data.types.list_tables_request.ListTablesRequest,
|
|
112
|
+
) -> zapros.Request:
|
|
113
|
+
endpoint = resolve(
|
|
114
|
+
EndpointParams(
|
|
115
|
+
Region=options.region,
|
|
116
|
+
UseDualStack=options.use_dual_stack,
|
|
117
|
+
UseFIPS=options.use_fips,
|
|
118
|
+
Endpoint=options.endpoint,
|
|
119
|
+
)
|
|
120
|
+
) # noqa: F841
|
|
121
|
+
url = endpoint.url.rstrip("/") + ""
|
|
122
|
+
params: list[tuple[str, str]] = []
|
|
123
|
+
headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
|
|
124
|
+
headers["X-Amz-Target"] = "RedshiftData.ListTables"
|
|
125
|
+
body: bytes | None = json.dumps(
|
|
126
|
+
capo_redshift_data.types.list_tables_request.serialize_aws_json_1_1(input_),
|
|
127
|
+
allow_nan=False,
|
|
128
|
+
).encode()
|
|
129
|
+
headers["content-type"] = "application/x-amz-json-1.1"
|
|
130
|
+
signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
|
|
131
|
+
normalized_url = zapros.URL(url)
|
|
132
|
+
for k, v in params:
|
|
133
|
+
normalized_url.search_params.append(k, v)
|
|
134
|
+
return zapros.Request(
|
|
135
|
+
normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def list_tables(
|
|
140
|
+
options: OperationOptions,
|
|
141
|
+
input_: capo_redshift_data.types.list_tables_request.ListTablesRequest,
|
|
142
|
+
) -> tuple[
|
|
143
|
+
capo_redshift_data.types.list_tables_response.ListTablesResponse, zapros.Response
|
|
144
|
+
]:
|
|
145
|
+
response = options.client.handler.handle(build_request(options, input_))
|
|
146
|
+
try:
|
|
147
|
+
if response.status >= 300:
|
|
148
|
+
response.read()
|
|
149
|
+
handle_error(response)
|
|
150
|
+
return handle_response(response), response
|
|
151
|
+
except BaseException:
|
|
152
|
+
response.close()
|
|
153
|
+
raise
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
async def async_list_tables(
|
|
157
|
+
options: AsyncOperationOptions,
|
|
158
|
+
input_: capo_redshift_data.types.list_tables_request.ListTablesRequest,
|
|
159
|
+
) -> tuple[
|
|
160
|
+
capo_redshift_data.types.list_tables_response.ListTablesResponse, zapros.Response
|
|
161
|
+
]:
|
|
162
|
+
response = await options.client.handler.ahandle(build_request(options, input_))
|
|
163
|
+
try:
|
|
164
|
+
if response.status >= 300:
|
|
165
|
+
await response.aread()
|
|
166
|
+
handle_error(response)
|
|
167
|
+
return await async_handle_response(response), response
|
|
168
|
+
except BaseException:
|
|
169
|
+
await response.aclose()
|
|
170
|
+
raise
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Runtime helpers for generated paginated ``iter_*`` operation methods."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def resolve_path(obj: Any, path: tuple[str, ...]) -> Any:
|
|
9
|
+
"""Walk ``path`` segments on a nested ``dict`` (TypedDict at runtime).
|
|
10
|
+
|
|
11
|
+
Returns ``None`` as soon as any intermediate value is missing or non-dict —
|
|
12
|
+
the generated iter loop uses a falsy token as the terminate signal, so this
|
|
13
|
+
short-circuit gives the same semantics for dotted paths as for top-level ones.
|
|
14
|
+
"""
|
|
15
|
+
for key in path:
|
|
16
|
+
if not isinstance(obj, dict):
|
|
17
|
+
return None
|
|
18
|
+
obj = obj.get(key)
|
|
19
|
+
if obj is None:
|
|
20
|
+
return None
|
|
21
|
+
return obj
|