1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import json
from moto.core.responses import BaseResponse
from .models import redshiftdata_backends
class RedshiftDataAPIServiceResponse(BaseResponse):
@property
def redshiftdata_backend(self):
return redshiftdata_backends[self.region]
def cancel_statement(self):
statement_id = self._get_param("Id")
status = self.redshiftdata_backend.cancel_statement(statement_id=statement_id)
return 200, {}, json.dumps({"Status": status})
def describe_statement(self):
statement_id = self._get_param("Id")
statement = self.redshiftdata_backend.describe_statement(
statement_id=statement_id
)
return 200, {}, json.dumps(dict(statement))
def execute_statement(self):
cluster_identifier = self._get_param("ClusterIdentifier")
database = self._get_param("Database")
db_user = self._get_param("DbUser")
parameters = self._get_param("Parameters")
secret_arn = self._get_param("SecretArn")
sql = self._get_param("Sql")
statement = self.redshiftdata_backend.execute_statement(
cluster_identifier=cluster_identifier,
database=database,
db_user=db_user,
parameters=parameters,
secret_arn=secret_arn,
sql=sql,
)
return (
200,
{},
json.dumps(
{
"ClusterIdentifier": statement.cluster_identifier,
"CreatedAt": statement.created_at,
"Database": statement.database,
"DbUser": statement.db_user,
"Id": statement.id,
"SecretArn": statement.secret_arn,
}
),
)
def get_statement_result(self):
statement_id = self._get_param("Id")
statement_result = self.redshiftdata_backend.get_statement_result(
statement_id=statement_id
)
return 200, {}, json.dumps(dict(statement_result))
|