Skip to content

Commit 193a459

Browse files
committed
feat: add Explicit bucket schemas API
1 parent b102dc3 commit 193a459

File tree

1 file changed

+36
-28
lines changed

1 file changed

+36
-28
lines changed

influxdb_client/service/bucket_schemas_service.py

+36-28
Original file line numberDiff line numberDiff line change
@@ -35,51 +35,51 @@ def __init__(self, api_client=None): # noqa: E501,D401,D403
3535
CloudOnlyWarning.print_warning('BucketSchemasService',
3636
'https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/') # noqa: E501
3737

38-
def create_measurement_schema(self, bucket_id, **kwargs): # noqa: E501,D401,D403
38+
def create_measurement_schema(self, bucket_id, measurement_schema_create_request, **kwargs): # noqa: E501,D401,D403
3939
"""Create a measurement schema for a bucket.
4040
4141
Creates an _explict_ measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema) for a bucket. _Explicit_ schemas are used to enforce column names, tags, fields, and data types for your data. By default, buckets have an _implicit_ schema-type (`"schemaType": "implicit"`) that conforms to your data. Use this endpoint to create schemas that prevent non-conforming write requests. #### Limitations - Buckets must be created with the "explict" `schemaType` in order to use schemas. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Create a bucket with an explicit schema](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/create-bucket/#create-a-bucket-with-an-explicit-schema)
4242
This method makes a synchronous HTTP request by default. To make an
4343
asynchronous HTTP request, please pass async_req=True
44-
>>> thread = api.create_measurement_schema(bucket_id, async_req=True)
44+
>>> thread = api.create_measurement_schema(bucket_id, measurement_schema_create_request, async_req=True)
4545
>>> result = thread.get()
4646
4747
:param async_req bool
4848
:param str bucket_id: A bucket ID. Adds a schema for the specified bucket. (required)
49+
:param MeasurementSchemaCreateRequest measurement_schema_create_request: (required)
4950
:param str org: An organization name. Specifies the organization that owns the schema.
5051
:param str org_id: An organization ID. Specifies the organization that owns the schema.
51-
:param MeasurementSchemaCreateRequest measurement_schema_create_request:
5252
:return: MeasurementSchema
5353
If the method is called asynchronously,
5454
returns the request thread.
5555
""" # noqa: E501
5656
kwargs['_return_http_data_only'] = True
5757
if kwargs.get('async_req'):
58-
return self.create_measurement_schema_with_http_info(bucket_id, **kwargs) # noqa: E501
58+
return self.create_measurement_schema_with_http_info(bucket_id, measurement_schema_create_request, **kwargs) # noqa: E501
5959
else:
60-
(data) = self.create_measurement_schema_with_http_info(bucket_id, **kwargs) # noqa: E501
60+
(data) = self.create_measurement_schema_with_http_info(bucket_id, measurement_schema_create_request, **kwargs) # noqa: E501
6161
return data
6262

63-
def create_measurement_schema_with_http_info(self, bucket_id, **kwargs): # noqa: E501,D401,D403
63+
def create_measurement_schema_with_http_info(self, bucket_id, measurement_schema_create_request, **kwargs): # noqa: E501,D401,D403
6464
"""Create a measurement schema for a bucket.
6565
6666
Creates an _explict_ measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema) for a bucket. _Explicit_ schemas are used to enforce column names, tags, fields, and data types for your data. By default, buckets have an _implicit_ schema-type (`"schemaType": "implicit"`) that conforms to your data. Use this endpoint to create schemas that prevent non-conforming write requests. #### Limitations - Buckets must be created with the "explict" `schemaType` in order to use schemas. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Create a bucket with an explicit schema](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/create-bucket/#create-a-bucket-with-an-explicit-schema)
6767
This method makes a synchronous HTTP request by default. To make an
6868
asynchronous HTTP request, please pass async_req=True
69-
>>> thread = api.create_measurement_schema_with_http_info(bucket_id, async_req=True)
69+
>>> thread = api.create_measurement_schema_with_http_info(bucket_id, measurement_schema_create_request, async_req=True)
7070
>>> result = thread.get()
7171
7272
:param async_req bool
7373
:param str bucket_id: A bucket ID. Adds a schema for the specified bucket. (required)
74+
:param MeasurementSchemaCreateRequest measurement_schema_create_request: (required)
7475
:param str org: An organization name. Specifies the organization that owns the schema.
7576
:param str org_id: An organization ID. Specifies the organization that owns the schema.
76-
:param MeasurementSchemaCreateRequest measurement_schema_create_request:
7777
:return: MeasurementSchema
7878
If the method is called asynchronously,
7979
returns the request thread.
8080
""" # noqa: E501
8181
local_var_params, path_params, query_params, header_params, body_params = \
82-
self._create_measurement_schema_prepare(bucket_id, **kwargs)
82+
self._create_measurement_schema_prepare(bucket_id, measurement_schema_create_request, **kwargs)
8383

8484
return self.api_client.call_api(
8585
'/api/v2/buckets/{bucketID}/schema/measurements', 'POST',
@@ -98,23 +98,23 @@ def create_measurement_schema_with_http_info(self, bucket_id, **kwargs): # noqa
9898
collection_formats={},
9999
urlopen_kw=kwargs.get('urlopen_kw', None))
100100

101-
async def create_measurement_schema_async(self, bucket_id, **kwargs): # noqa: E501,D401,D403
101+
async def create_measurement_schema_async(self, bucket_id, measurement_schema_create_request, **kwargs): # noqa: E501,D401,D403
102102
"""Create a measurement schema for a bucket.
103103
104104
Creates an _explict_ measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema) for a bucket. _Explicit_ schemas are used to enforce column names, tags, fields, and data types for your data. By default, buckets have an _implicit_ schema-type (`"schemaType": "implicit"`) that conforms to your data. Use this endpoint to create schemas that prevent non-conforming write requests. #### Limitations - Buckets must be created with the "explict" `schemaType` in order to use schemas. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Create a bucket with an explicit schema](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/create-bucket/#create-a-bucket-with-an-explicit-schema)
105105
This method makes an asynchronous HTTP request.
106106
107107
:param async_req bool
108108
:param str bucket_id: A bucket ID. Adds a schema for the specified bucket. (required)
109+
:param MeasurementSchemaCreateRequest measurement_schema_create_request: (required)
109110
:param str org: An organization name. Specifies the organization that owns the schema.
110111
:param str org_id: An organization ID. Specifies the organization that owns the schema.
111-
:param MeasurementSchemaCreateRequest measurement_schema_create_request:
112112
:return: MeasurementSchema
113113
If the method is called asynchronously,
114114
returns the request thread.
115115
""" # noqa: E501
116116
local_var_params, path_params, query_params, header_params, body_params = \
117-
self._create_measurement_schema_prepare(bucket_id, **kwargs)
117+
self._create_measurement_schema_prepare(bucket_id, measurement_schema_create_request, **kwargs)
118118

119119
return await self.api_client.call_api(
120120
'/api/v2/buckets/{bucketID}/schema/measurements', 'POST',
@@ -133,15 +133,19 @@ async def create_measurement_schema_async(self, bucket_id, **kwargs): # noqa: E
133133
collection_formats={},
134134
urlopen_kw=kwargs.get('urlopen_kw', None))
135135

136-
def _create_measurement_schema_prepare(self, bucket_id, **kwargs): # noqa: E501,D401,D403
136+
def _create_measurement_schema_prepare(self, bucket_id, measurement_schema_create_request, **kwargs): # noqa: E501,D401,D403
137137
local_var_params = locals()
138138

139-
all_params = ['bucket_id', 'org', 'org_id', 'measurement_schema_create_request'] # noqa: E501
139+
all_params = ['bucket_id', 'measurement_schema_create_request', 'org', 'org_id'] # noqa: E501
140140
self._check_operation_params('create_measurement_schema', all_params, local_var_params)
141141
# verify the required parameter 'bucket_id' is set
142142
if ('bucket_id' not in local_var_params or
143143
local_var_params['bucket_id'] is None):
144144
raise ValueError("Missing the required parameter `bucket_id` when calling `create_measurement_schema`") # noqa: E501
145+
# verify the required parameter 'measurement_schema_create_request' is set
146+
if ('measurement_schema_create_request' not in local_var_params or
147+
local_var_params['measurement_schema_create_request'] is None):
148+
raise ValueError("Missing the required parameter `measurement_schema_create_request` when calling `create_measurement_schema`") # noqa: E501
145149

146150
path_params = {}
147151
if 'bucket_id' in local_var_params:
@@ -430,53 +434,53 @@ def _get_measurement_schemas_prepare(self, bucket_id, **kwargs): # noqa: E501,D
430434

431435
return local_var_params, path_params, query_params, header_params, body_params
432436

433-
def update_measurement_schema(self, bucket_id, measurement_id, **kwargs): # noqa: E501,D401,D403
437+
def update_measurement_schema(self, bucket_id, measurement_id, measurement_schema_update_request, **kwargs): # noqa: E501,D401,D403
434438
"""Update a measurement schema.
435439
436440
Updates a measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema). Use this endpoint to update the fields (`name`, `type`, and `dataType`) of a measurement schema. #### Limitations - You can't update the `name` of a measurement. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Using bucket schemas](https://www.influxdata.com/blog/new-bucket-schema-option-protect-from-unwanted-schema-changes/).
437441
This method makes a synchronous HTTP request by default. To make an
438442
asynchronous HTTP request, please pass async_req=True
439-
>>> thread = api.update_measurement_schema(bucket_id, measurement_id, async_req=True)
443+
>>> thread = api.update_measurement_schema(bucket_id, measurement_id, measurement_schema_update_request, async_req=True)
440444
>>> result = thread.get()
441445
442446
:param async_req bool
443447
:param str bucket_id: A bucket ID. Specifies the bucket to retrieve schemas for. (required)
444448
:param str measurement_id: A measurement schema ID. Retrieves the specified measurement schema. (required)
449+
:param MeasurementSchemaUpdateRequest measurement_schema_update_request: (required)
445450
:param str org: An organization name. Specifies the organization that owns the schema.
446451
:param str org_id: An organization ID. Specifies the organization that owns the schema.
447-
:param MeasurementSchemaUpdateRequest measurement_schema_update_request:
448452
:return: MeasurementSchema
449453
If the method is called asynchronously,
450454
returns the request thread.
451455
""" # noqa: E501
452456
kwargs['_return_http_data_only'] = True
453457
if kwargs.get('async_req'):
454-
return self.update_measurement_schema_with_http_info(bucket_id, measurement_id, **kwargs) # noqa: E501
458+
return self.update_measurement_schema_with_http_info(bucket_id, measurement_id, measurement_schema_update_request, **kwargs) # noqa: E501
455459
else:
456-
(data) = self.update_measurement_schema_with_http_info(bucket_id, measurement_id, **kwargs) # noqa: E501
460+
(data) = self.update_measurement_schema_with_http_info(bucket_id, measurement_id, measurement_schema_update_request, **kwargs) # noqa: E501
457461
return data
458462

459-
def update_measurement_schema_with_http_info(self, bucket_id, measurement_id, **kwargs): # noqa: E501,D401,D403
463+
def update_measurement_schema_with_http_info(self, bucket_id, measurement_id, measurement_schema_update_request, **kwargs): # noqa: E501,D401,D403
460464
"""Update a measurement schema.
461465
462466
Updates a measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema). Use this endpoint to update the fields (`name`, `type`, and `dataType`) of a measurement schema. #### Limitations - You can't update the `name` of a measurement. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Using bucket schemas](https://www.influxdata.com/blog/new-bucket-schema-option-protect-from-unwanted-schema-changes/).
463467
This method makes a synchronous HTTP request by default. To make an
464468
asynchronous HTTP request, please pass async_req=True
465-
>>> thread = api.update_measurement_schema_with_http_info(bucket_id, measurement_id, async_req=True)
469+
>>> thread = api.update_measurement_schema_with_http_info(bucket_id, measurement_id, measurement_schema_update_request, async_req=True)
466470
>>> result = thread.get()
467471
468472
:param async_req bool
469473
:param str bucket_id: A bucket ID. Specifies the bucket to retrieve schemas for. (required)
470474
:param str measurement_id: A measurement schema ID. Retrieves the specified measurement schema. (required)
475+
:param MeasurementSchemaUpdateRequest measurement_schema_update_request: (required)
471476
:param str org: An organization name. Specifies the organization that owns the schema.
472477
:param str org_id: An organization ID. Specifies the organization that owns the schema.
473-
:param MeasurementSchemaUpdateRequest measurement_schema_update_request:
474478
:return: MeasurementSchema
475479
If the method is called asynchronously,
476480
returns the request thread.
477481
""" # noqa: E501
478482
local_var_params, path_params, query_params, header_params, body_params = \
479-
self._update_measurement_schema_prepare(bucket_id, measurement_id, **kwargs)
483+
self._update_measurement_schema_prepare(bucket_id, measurement_id, measurement_schema_update_request, **kwargs)
480484

481485
return self.api_client.call_api(
482486
'/api/v2/buckets/{bucketID}/schema/measurements/{measurementID}', 'PATCH',
@@ -495,7 +499,7 @@ def update_measurement_schema_with_http_info(self, bucket_id, measurement_id, **
495499
collection_formats={},
496500
urlopen_kw=kwargs.get('urlopen_kw', None))
497501

498-
async def update_measurement_schema_async(self, bucket_id, measurement_id, **kwargs): # noqa: E501,D401,D403
502+
async def update_measurement_schema_async(self, bucket_id, measurement_id, measurement_schema_update_request, **kwargs): # noqa: E501,D401,D403
499503
"""Update a measurement schema.
500504
501505
Updates a measurement [schema](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#schema). Use this endpoint to update the fields (`name`, `type`, and `dataType`) of a measurement schema. #### Limitations - You can't update the `name` of a measurement. #### Related guides - [Manage bucket schemas](https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/). - [Using bucket schemas](https://www.influxdata.com/blog/new-bucket-schema-option-protect-from-unwanted-schema-changes/).
@@ -504,15 +508,15 @@ async def update_measurement_schema_async(self, bucket_id, measurement_id, **kwa
504508
:param async_req bool
505509
:param str bucket_id: A bucket ID. Specifies the bucket to retrieve schemas for. (required)
506510
:param str measurement_id: A measurement schema ID. Retrieves the specified measurement schema. (required)
511+
:param MeasurementSchemaUpdateRequest measurement_schema_update_request: (required)
507512
:param str org: An organization name. Specifies the organization that owns the schema.
508513
:param str org_id: An organization ID. Specifies the organization that owns the schema.
509-
:param MeasurementSchemaUpdateRequest measurement_schema_update_request:
510514
:return: MeasurementSchema
511515
If the method is called asynchronously,
512516
returns the request thread.
513517
""" # noqa: E501
514518
local_var_params, path_params, query_params, header_params, body_params = \
515-
self._update_measurement_schema_prepare(bucket_id, measurement_id, **kwargs)
519+
self._update_measurement_schema_prepare(bucket_id, measurement_id, measurement_schema_update_request, **kwargs)
516520

517521
return await self.api_client.call_api(
518522
'/api/v2/buckets/{bucketID}/schema/measurements/{measurementID}', 'PATCH',
@@ -531,10 +535,10 @@ async def update_measurement_schema_async(self, bucket_id, measurement_id, **kwa
531535
collection_formats={},
532536
urlopen_kw=kwargs.get('urlopen_kw', None))
533537

534-
def _update_measurement_schema_prepare(self, bucket_id, measurement_id, **kwargs): # noqa: E501,D401,D403
538+
def _update_measurement_schema_prepare(self, bucket_id, measurement_id, measurement_schema_update_request, **kwargs): # noqa: E501,D401,D403
535539
local_var_params = locals()
536540

537-
all_params = ['bucket_id', 'measurement_id', 'org', 'org_id', 'measurement_schema_update_request'] # noqa: E501
541+
all_params = ['bucket_id', 'measurement_id', 'measurement_schema_update_request', 'org', 'org_id'] # noqa: E501
538542
self._check_operation_params('update_measurement_schema', all_params, local_var_params)
539543
# verify the required parameter 'bucket_id' is set
540544
if ('bucket_id' not in local_var_params or
@@ -544,6 +548,10 @@ def _update_measurement_schema_prepare(self, bucket_id, measurement_id, **kwargs
544548
if ('measurement_id' not in local_var_params or
545549
local_var_params['measurement_id'] is None):
546550
raise ValueError("Missing the required parameter `measurement_id` when calling `update_measurement_schema`") # noqa: E501
551+
# verify the required parameter 'measurement_schema_update_request' is set
552+
if ('measurement_schema_update_request' not in local_var_params or
553+
local_var_params['measurement_schema_update_request'] is None):
554+
raise ValueError("Missing the required parameter `measurement_schema_update_request` when calling `update_measurement_schema`") # noqa: E501
547555

548556
path_params = {}
549557
if 'bucket_id' in local_var_params:

0 commit comments

Comments
 (0)