@@ -58,6 +58,51 @@ def create_bucket(self, bucket=None, bucket_name=None, org_id=None, retention_ru
58
58
59
59
return self ._buckets_service .post_buckets (post_bucket_request = bucket )
60
60
61
+ def create_database (self , database = None , retention_rules = None ):
62
+ """Create a database at the v1 api (legacy).
63
+
64
+ :param database_name: name of the new database
65
+ :param retention_rules: retention rules array or single BucketRetentionRules
66
+ :return: Tuple (response body, status code, header dict)"""
67
+ if database is None :
68
+ raise ValueError ("Invalid value for `database`, must be defined." )
69
+
70
+ if retention_rules is None :
71
+ retention_rules = []
72
+
73
+ rules = []
74
+
75
+ if isinstance (retention_rules , list ):
76
+ rules .extend (retention_rules )
77
+ else :
78
+ rules .append (retention_rules )
79
+
80
+ # Hedaer and local_var_params for standard procedures only
81
+ header_params = {}
82
+ header_params ['Accept' ] = self ._influxdb_client .api_client .select_header_accept (
83
+ ['application/json' ])
84
+ header_params ['Content-Type' ] = self ._influxdb_client .api_client .select_header_content_type (
85
+ ['application/json' ])
86
+ local_var_params = locals ()
87
+ local_var_params ['kwargs' ] = {}
88
+ all_params = []
89
+ self ._buckets_service ._check_operation_params (
90
+ "create_database" , all_params , local_var_params
91
+ )
92
+
93
+ return self ._influxdb_client .api_client .call_api (
94
+ '/query' , 'POST' ,
95
+ header_params = header_params ,
96
+ path_params = {}, post_params = [],
97
+ files = {}, auth_settings = [], collection_formats = {},
98
+ query_params = {'q' : f'CREATE DATABASE { database } ' },
99
+ async_req = local_var_params .get ('async_req' ),
100
+ _return_http_data_only = local_var_params .get ('_return_http_data_only' ), # noqa: E501
101
+ _preload_content = local_var_params .get ('_preload_content' , True ),
102
+ _request_timeout = local_var_params .get ('_request_timeout' ),
103
+ urlopen_kw = None
104
+ )
105
+
61
106
def update_bucket (self , bucket : Bucket ) -> Bucket :
62
107
"""Update a bucket.
63
108
@@ -83,6 +128,41 @@ def delete_bucket(self, bucket):
83
128
84
129
return self ._buckets_service .delete_buckets_id (bucket_id = bucket_id )
85
130
131
+ def delete_database (self , database = None ):
132
+ """Delete a database at the v1 api (legacy).
133
+
134
+ :param database_name: name of the database to delete
135
+ :param retention_rules: retention rules array or single BucketRetentionRules
136
+ :return: Tuple (response body, status code, header dict)"""
137
+ if database is None :
138
+ raise ValueError ("Invalid value for `database`, must be defined." )
139
+
140
+ # Hedaer and local_var_params for standard procedures only
141
+ header_params = {}
142
+ header_params ['Accept' ] = self ._influxdb_client .api_client .select_header_accept (
143
+ ['application/json' ])
144
+ header_params ['Content-Type' ] = self ._influxdb_client .api_client .select_header_content_type (
145
+ ['application/json' ])
146
+ local_var_params = locals ()
147
+ local_var_params ['kwargs' ] = {}
148
+ all_params = []
149
+ self ._buckets_service ._check_operation_params (
150
+ "drop_database" , all_params , local_var_params
151
+ )
152
+
153
+ return self ._influxdb_client .api_client .call_api (
154
+ '/query' , 'POST' ,
155
+ header_params = header_params ,
156
+ path_params = {}, post_params = [],
157
+ files = {}, auth_settings = [], collection_formats = {},
158
+ query_params = {'q' : f'DROP DATABASE { database } ' },
159
+ async_req = local_var_params .get ('async_req' ),
160
+ _return_http_data_only = local_var_params .get ('_return_http_data_only' ),
161
+ _preload_content = local_var_params .get ('_preload_content' , True ),
162
+ _request_timeout = local_var_params .get ('_request_timeout' ),
163
+ urlopen_kw = None
164
+ )
165
+
86
166
def find_bucket_by_id (self , id ):
87
167
"""Find bucket by ID.
88
168
0 commit comments