From 7a23bdceb4696339b2ab00bf76d2dcf680803e7c Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 7 Mar 2018 00:20:46 +0800 Subject: [PATCH 001/185] renaming for openapi-generator --- README.mustache | 125 ++++++++ __init__api.mustache | 7 + __init__model.mustache | 10 + __init__package.mustache | 17 + __init__test.mustache | 0 api.mustache | 214 +++++++++++++ api_client.mustache | 627 +++++++++++++++++++++++++++++++++++++ api_doc.mustache | 85 +++++ api_test.mustache | 37 +++ asyncio/rest.mustache | 260 +++++++++++++++ configuration.mustache | 260 +++++++++++++++ git_push.sh.mustache | 52 +++ gitignore.mustache | 64 ++++ model.mustache | 219 +++++++++++++ model_doc.mustache | 11 + model_test.mustache | 35 +++ partial_header.mustache | 13 + requirements.mustache | 5 + rest.mustache | 314 +++++++++++++++++++ setup.mustache | 43 +++ test-requirements.mustache | 11 + tornado/rest.mustache | 255 +++++++++++++++ tox.mustache | 20 ++ travis.mustache | 14 + 24 files changed, 2698 insertions(+) create mode 100644 README.mustache create mode 100644 __init__api.mustache create mode 100644 __init__model.mustache create mode 100644 __init__package.mustache create mode 100644 __init__test.mustache create mode 100644 api.mustache create mode 100644 api_client.mustache create mode 100644 api_doc.mustache create mode 100644 api_test.mustache create mode 100644 asyncio/rest.mustache create mode 100644 configuration.mustache create mode 100755 git_push.sh.mustache create mode 100644 gitignore.mustache create mode 100644 model.mustache create mode 100644 model_doc.mustache create mode 100644 model_test.mustache create mode 100644 partial_header.mustache create mode 100644 requirements.mustache create mode 100644 rest.mustache create mode 100644 setup.mustache create mode 100644 test-requirements.mustache create mode 100644 tornado/rest.mustache create mode 100644 tox.mustache create mode 100644 travis.mustache diff --git a/README.mustache b/README.mustache new file mode 100644 index 0000000000..c1355be778 --- /dev/null +++ b/README.mustache @@ -0,0 +1,125 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github + +```sh +pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +{{{packageName}}}.configuration.username = 'YOUR_USERNAME' +{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/__init__api.mustache b/__init__api.mustache new file mode 100644 index 0000000000..db658a10fa --- /dev/null +++ b/__init__api.mustache @@ -0,0 +1,7 @@ +from __future__ import absolute_import + +# flake8: noqa + +# import apis into api package +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} \ No newline at end of file diff --git a/__init__model.mustache b/__init__model.mustache new file mode 100644 index 0000000000..2266b3d17f --- /dev/null +++ b/__init__model.mustache @@ -0,0 +1,10 @@ +# coding: utf-8 + +# flake8: noqa +{{>partial_header}} + +from __future__ import absolute_import + +# import models into model package +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} +{{/models}} diff --git a/__init__package.mustache b/__init__package.mustache new file mode 100644 index 0000000000..cd42506f54 --- /dev/null +++ b/__init__package.mustache @@ -0,0 +1,17 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +# import apis into sdk package +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} +# import ApiClient +from {{packageName}}.api_client import ApiClient +from {{packageName}}.configuration import Configuration +# import models into sdk package +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} +{{/model}}{{/models}} \ No newline at end of file diff --git a/__init__test.mustache b/__init__test.mustache new file mode 100644 index 0000000000..e69de29bb2 diff --git a/api.mustache b/api.mustache new file mode 100644 index 0000000000..a65946f578 --- /dev/null +++ b/api.mustache @@ -0,0 +1,214 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from {{packageName}}.api_client import ApiClient + + +{{#operations}} +class {{classname}}(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client +{{#operation}} + + def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async bool +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/allParams}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async'): + return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 + else: + (data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 + return data + + def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async bool +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} +{{/allParams}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + + all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 + all_params.append('async') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method {{operationId}}" % key + ) + params[key] = val + del params['kwargs'] +{{#allParams}} +{{#required}} + # verify the required parameter '{{paramName}}' is set + if ('{{paramName}}' not in params or + params['{{paramName}}'] is None): + raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 +{{/required}} +{{/allParams}} + +{{#allParams}} +{{#hasValidation}} + {{#maxLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 + {{/maxLength}} + {{#minLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 + {{/minLength}} + {{#maximum}} + if '{{paramName}}' in params and params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 + {{/maximum}} + {{#minimum}} + if '{{paramName}}' in params and params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 + {{/minimum}} + {{#pattern}} + if '{{paramName}}' in params and not re.search('{{{vendorExtensions.x-regex}}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 + {{/pattern}} + {{#maxItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 + {{/maxItems}} + {{#minItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 + {{/minItems}} +{{/hasValidation}} +{{#-last}} +{{/-last}} +{{/allParams}} + collection_formats = {} + + path_params = {} +{{#pathParams}} + if '{{paramName}}' in params: + path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/pathParams}} + + query_params = [] +{{#queryParams}} + if '{{paramName}}' in params: + query_params.append(('{{baseName}}', params['{{paramName}}'])){{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/queryParams}} + + header_params = {} +{{#headerParams}} + if '{{paramName}}' in params: + header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/headerParams}} + + form_params = [] + local_var_files = {} +{{#formParams}} + if '{{paramName}}' in params: + {{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/formParams}} + + body_params = None +{{#bodyParam}} + if '{{paramName}}' in params: + body_params = params['{{paramName}}'] +{{/bodyParam}} + {{#hasProduces}} + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + + {{/hasProduces}} + {{#hasConsumes}} + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + + {{/hasConsumes}} + # Authentication setting + auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + + return self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 + auth_settings=auth_settings, + async=params.get('async'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) +{{/operation}} +{{/operations}} diff --git a/api_client.mustache b/api_client.mustache new file mode 100644 index 0000000000..a6df41b072 --- /dev/null +++ b/api_client.mustache @@ -0,0 +1,627 @@ +# coding: utf-8 +{{>partial_header}} +from __future__ import absolute_import + +import datetime +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote +{{#tornado}} +import tornado.gen +{{/tornado}} + +from {{packageName}}.configuration import Configuration +import {{modelPackage}} +from {{packageName}} import rest + + +class ApiClient(object): + """Generic API client for Swagger client library builds. + + Swagger generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the Swagger + templates. + + NOTE: This class is auto generated by the swagger code generator program. + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + + self.pool = ThreadPool() + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}' + + def __del__(self): + self.pool.close() + self.pool.join() + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + {{#tornado}} + @tornado.gen.coroutine + {{/tornado}} + {{#asyncio}}async {{/asyncio}}def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = self.prepare_post_parameters(post_params, files) + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + url = self.configuration.host + resource_path + + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + + self.last_response = response_data + + return_data = response_data + if _preload_content: + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + +{{^tornado}} + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) +{{/tornado}} +{{#tornado}} + if _return_http_data_only: + raise tornado.gen.Return(return_data) + else: + raise tornado.gen.Return((return_data, response_data.status, + response_data.getheaders())) +{{/tornado}} + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is swagger model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `swagger_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} + + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if type(klass) == str: + if klass.startswith('list['): + sub_kls = re.match('list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('dict('): + sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr({{modelPackage}}, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datatime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async request, set the async parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async bool: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: + If async parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async is False or missing, + then the method will return the response directly. + """ + if not async: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout) + else: + thread = self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, query_params, + header_params, body, + post_params, files, + response_type, auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, _request_timeout)) + return thread + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def prepare_post_parameters(self, post_params=None, files=None): + """Builds form parameters. + + :param post_params: Normal form parameters. + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if post_params: + params = post_params + + if files: + for k, v in six.iteritems(files): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return six.text_type(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return a original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + from dateutil.parser import parse + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datatime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + from dateutil.parser import parse + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + if not klass.swagger_types and not hasattr(klass, + 'get_real_child_model'): + return data + + kwargs = {} + if klass.swagger_types is not None: + for attr, attr_type in six.iteritems(klass.swagger_types): + if (data is not None and + klass.attribute_map[attr] in data and + isinstance(data, (list, dict))): + value = data[klass.attribute_map[attr]] + kwargs[attr] = self.__deserialize(value, attr_type) + + instance = klass(**kwargs) + + if hasattr(instance, 'get_real_child_model'): + klass_name = instance.get_real_child_model(data) + if klass_name: + instance = self.__deserialize(data, klass_name) + return instance diff --git a/api_doc.mustache b/api_doc.mustache new file mode 100644 index 0000000000..32c26d929d --- /dev/null +++ b/api_doc.mustache @@ -0,0 +1,85 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/api_test.mustache b/api_test.mustache new file mode 100644 index 0000000000..90fafc15f3 --- /dev/null +++ b/api_test.mustache @@ -0,0 +1,37 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +import {{packageName}} +from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 +from {{packageName}}.rest import ApiException + + +class {{#operations}}Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + self.api = {{apiPackage}}.{{classVarName}}.{{classname}}() # noqa: E501 + + def tearDown(self): + pass + + {{#operation}} + def test_{{operationId}}(self): + """Test case for {{{operationId}}} + +{{#summary}} + {{{summary}}} # noqa: E501 +{{/summary}} + """ + pass + + {{/operation}} +{{/operations}} + +if __name__ == '__main__': + unittest.main() diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache new file mode 100644 index 0000000000..39003abfbf --- /dev/null +++ b/asyncio/rest.mustache @@ -0,0 +1,260 @@ +# coding: utf-8 + +{{>partial_header}} + +import io +import json +import logging +import re +import ssl + +import aiohttp +import certifi +# python 2 and python 3 compatibility library +from six.moves.urllib.parse import urlencode + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp, data): + self.aiohttp_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = data + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.aiohttp_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.aiohttp_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=4): + # maxsize is number of requests to host that are allowed in parallel + # ca_certs vs cert_file vs key_file + # http://stackoverflow.com/a/23957365/2985775 + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + ssl_context = ssl.create_default_context(cafile=ca_certs) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + + connector = aiohttp.TCPConnector( + limit=maxsize, + ssl_context=ssl_context, + verify_ssl=configuration.verify_ssl + ) + + # https pool manager + if configuration.proxy: + self.pool_manager = aiohttp.ClientSession( + connector=connector, + proxy=configuration.proxy + ) + else: + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) + + async def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Execute request + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: this is a non-applicable field for + the AiohttpClient. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + timeout = _request_timeout or 5 * 60 + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + args = { + "method": method, + "url": url, + "timeout": timeout, + "headers": headers + } + + if query_params: + args["url"] += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body is not None: + body = json.dumps(body) + args["data"] = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + args["data"] = aiohttp.FormData(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by aiohttp + del headers['Content-Type'] + data = aiohttp.FormData() + for param in post_params: + k, v = param + if isinstance(v, tuple) and len(v) == 3: + data.add_field(k, + value=v[1], + filename=v[0], + content_type=v[2]) + else: + data.add_field(k, v) + args["data"] = data + + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + args["data"] = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + async with self.pool_manager.request(**args) as r: + data = await r.text() + r = RESTResponse(r, data) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + async def GET(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def HEAD(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def OPTIONS(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return (await self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def POST(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return (await self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PATCH(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/configuration.mustache b/configuration.mustache new file mode 100644 index 0000000000..84e6ad4d20 --- /dev/null +++ b/configuration.mustache @@ -0,0 +1,260 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import six +from six.moves import http_client as httplib + + +class TypeWithDefault(type): + def __init__(cls, name, bases, dct): + super(TypeWithDefault, cls).__init__(name, bases, dct) + cls._default = None + + def __call__(cls): + if cls._default is None: + cls._default = type.__call__(cls) + return copy.copy(cls._default) + + def set_default(cls, default): + cls._default = copy.copy(default) + + +class Configuration(six.with_metaclass(TypeWithDefault, object)): + """NOTE: This class is auto generated by the swagger code generator program. + + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + """ + + def __init__(self): + """Constructor""" + # Default Base url + self.host = "{{{basePath}}}" + # Temp file folder for downloading files + self.temp_folder_path = None + + # Authentication Settings + # dict to store API key(s) + self.api_key = {} + # dict to store API prefix (e.g. Bearer) + self.api_key_prefix = {} + # Username for HTTP basic authentication + self.username = "" + # Password for HTTP basic authentication + self.password = "" +{{#authMethods}}{{#isOAuth}} + # access token for OAuth + self.access_token = "" +{{/isOAuth}}{{/authMethods}} + # Logging Settings + self.logger = {} + self.logger["package_logger"] = logging.getLogger("{{packageName}}") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + # Log format + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + # Log stream handler + self.logger_stream_handler = None + # Log file handler + self.logger_file_handler = None + # Debug file location + self.logger_file = None + # Debug switch + self.debug = False + + # SSL/TLS verification + # Set this to false to skip verifying SSL certificate when calling API + # from https server. + self.verify_ssl = True + # Set this to customize the certificate file to verify the peer. + self.ssl_ca_cert = None + # client certificate file + self.cert_file = None + # client key file + self.key_file = None + # Set this to True/False to enable/disable SSL hostname verification. + self.assert_hostname = None + + # urllib3 connection pool's maximum number of connections saved + # per pool. urllib3 uses 1 connection as default value, but this is + # not the best value when you are making a lot of possibly parallel + # requests to the same host, which is often the case here. + # cpu_count * 5 is used as default value to increase performance. + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + + # Proxy URL + self.proxy = None + # Safe chars for path_param + self.safe_chars_for_path_param = '' + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_file_handler) + if self.logger_stream_handler: + logger.removeHandler(self.logger_stream_handler) + else: + # If not set logging file, + # then add stream handler and remove file handler. + self.logger_stream_handler = logging.StreamHandler() + self.logger_stream_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_stream_handler) + if self.logger_file_handler: + logger.removeHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :return: The token for api key authentication. + """ + if (self.api_key.get(identifier) and + self.api_key_prefix.get(identifier)): + return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501 + elif self.api_key.get(identifier): + return self.api_key[identifier] + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + return urllib3.util.make_headers( + basic_auth=self.username + ':' + self.password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + return { +{{#authMethods}} +{{#isApiKey}} + '{{name}}': + { + 'type': 'api_key', + 'in': {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix('{{keyParamName}}') + }, +{{/isApiKey}} +{{#isBasic}} + '{{name}}': + { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + }, +{{/isBasic}}{{#isOAuth}} + '{{name}}': + { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + }, +{{/isOAuth}}{{/authMethods}} + } + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: {{version}}\n"\ + "SDK Package Version: {{packageVersion}}".\ + format(env=sys.platform, pyversion=sys.version) diff --git a/git_push.sh.mustache b/git_push.sh.mustache new file mode 100755 index 0000000000..a2d7523483 --- /dev/null +++ b/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/gitignore.mustache b/gitignore.mustache new file mode 100644 index 0000000000..a655050c26 --- /dev/null +++ b/gitignore.mustache @@ -0,0 +1,64 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.python-version + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/model.mustache b/model.mustache new file mode 100644 index 0000000000..5668793b3f --- /dev/null +++ b/model.mustache @@ -0,0 +1,219 @@ +# coding: utf-8 + +{{>partial_header}} + +import pprint +import re # noqa: F401 + +import six +{{#imports}}{{#-first}} +{{/-first}} +{{import}} # noqa: F401,E501 +{{/imports}} + + +{{#models}} +{{#model}} +class {{classname}}(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """{{#allowableValues}} + + """ + allowed enum values + """ +{{#enumVars}} + {{name}} = {{{value}}}{{^-last}} +{{/-last}} +{{/enumVars}}{{/allowableValues}} + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { +{{#vars}} + '{{name}}': '{{{datatype}}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } + + attribute_map = { +{{#vars}} + '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } +{{#discriminator}} + + discriminator_value_class_map = { + {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, + {{/-last}}{{/children}} + } +{{/discriminator}} + + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + """{{classname}} - a model defined in Swagger""" # noqa: E501 +{{#vars}}{{#-first}} +{{/-first}} + self._{{name}} = None +{{/vars}} + self.discriminator = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} +{{#vars}}{{#-first}} +{{/-first}} +{{#required}} + self.{{name}} = {{name}} +{{/required}} +{{^required}} + if {{name}} is not None: + self.{{name}} = {{name}} +{{/required}} +{{/vars}} + +{{#vars}} + @property + def {{name}}(self): + """Gets the {{name}} of this {{classname}}. # noqa: E501 + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :return: The {{name}} of this {{classname}}. # noqa: E501 + :rtype: {{datatype}} + """ + return self._{{name}} + + @{{name}}.setter + def {{name}}(self, {{name}}): + """Sets the {{name}} of this {{classname}}. + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 + :type: {{datatype}} + """ +{{#required}} + if {{name}} is None: + raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 +{{/required}} +{{#isEnum}} +{{#isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 +{{#isListContainer}} + if not set({{{name}}}).issubset(set(allowed_values)): + raise ValueError( + "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isListContainer}} +{{#isMapContainer}} + if not set({{{name}}}.keys()).issubset(set(allowed_values)): + raise ValueError( + "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isMapContainer}} +{{/isContainer}} +{{^isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + if {{{name}}} not in allowed_values: + raise ValueError( + "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 + .format({{{name}}}, allowed_values) + ) +{{/isContainer}} +{{/isEnum}} +{{^isEnum}} +{{#hasValidation}} +{{#maxLength}} + if {{name}} is not None and len({{name}}) > {{maxLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 +{{/maxLength}} +{{#minLength}} + if {{name}} is not None and len({{name}}) < {{minLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 +{{/minLength}} +{{#maximum}} + if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 +{{/maximum}} +{{#minimum}} + if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 +{{/minimum}} +{{#pattern}} + if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 +{{/pattern}} +{{#maxItems}} + if {{name}} is not None and len({{name}}) > {{maxItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 +{{/maxItems}} +{{#minItems}} + if {{name}} is not None and len({{name}}) < {{minItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 +{{/minItems}} +{{/hasValidation}} +{{/isEnum}} + + self._{{name}} = {{name}} + +{{/vars}} +{{#discriminator}} + def get_real_child_model(self, data): + """Returns the real base class specified by the discriminator""" + discriminator_value = data[self.discriminator].lower() + return self.discriminator_value_class_map.get(discriminator_value) + +{{/discriminator}} + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other +{{/model}} +{{/models}} diff --git a/model_doc.mustache b/model_doc.mustache new file mode 100644 index 0000000000..569550df37 --- /dev/null +++ b/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/model_test.mustache b/model_test.mustache new file mode 100644 index 0000000000..765e4f9c2c --- /dev/null +++ b/model_test.mustache @@ -0,0 +1,35 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +{{#models}} +{{#model}} +import {{packageName}} +from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 +from {{packageName}}.rest import ApiException + + +class Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test{{classname}}(self): + """Test {{classname}}""" + # FIXME: construct object with mandatory attributes with example values + # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 + pass + +{{/model}} +{{/models}} + +if __name__ == '__main__': + unittest.main() diff --git a/partial_header.mustache b/partial_header.mustache new file mode 100644 index 0000000000..513ad04cdb --- /dev/null +++ b/partial_header.mustache @@ -0,0 +1,13 @@ +""" +{{#appName}} + {{{appName}}} +{{/appName}} + +{{#appDescription}} + {{{appDescription}}} # noqa: E501 +{{/appDescription}} + + {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" diff --git a/requirements.mustache b/requirements.mustache new file mode 100644 index 0000000000..bafdc07532 --- /dev/null +++ b/requirements.mustache @@ -0,0 +1,5 @@ +certifi >= 14.05.14 +six >= 1.10 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/rest.mustache b/rest.mustache new file mode 100644 index 0000000000..ff9b019dc5 --- /dev/null +++ b/rest.mustache @@ -0,0 +1,314 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import io +import json +import logging +import re +import ssl + +import certifi +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode + +try: + import urllib3 +except ImportError: + raise ImportError('Swagger python client requires urllib3.') + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.getheaders() + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.getheader(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if query_params: + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # In the python 3, the response.data is bytes. + # we need to decode it to string. + if six.PY3: + r.data = r.data.decode('utf8') + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/setup.mustache b/setup.mustache new file mode 100644 index 0000000000..e7107e9be9 --- /dev/null +++ b/setup.mustache @@ -0,0 +1,43 @@ +# coding: utf-8 + +{{>partial_header}} + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "{{{projectName}}}" +VERSION = "{{packageVersion}}" +{{#apiInfo}} +{{#apis}} +{{^hasMore}} +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +{{#asyncio}} +REQUIRES.append("aiohttp") +{{/asyncio}} +{{#tornado}} +REQUIRES.append("tornado") +{{/tornado}} + +setup( + name=NAME, + version=VERSION, + description="{{appName}}", + author_email="{{infoEmail}}", + url="{{packageUrl}}", + keywords=["Swagger", "{{appName}}"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + {{appDescription}} # noqa: E501 + """ +) +{{/hasMore}} +{{/apis}} +{{/apiInfo}} diff --git a/test-requirements.mustache b/test-requirements.mustache new file mode 100644 index 0000000000..31f8d94d99 --- /dev/null +++ b/test-requirements.mustache @@ -0,0 +1,11 @@ +{{^asyncio}} +coverage>=4.0.3 +nose>=1.3.7 +{{/asyncio}} +{{#asyncio}} +pytest>=3.3.1 +pytest-cov>=2.5.1 +{{/asyncio}} +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 diff --git a/tornado/rest.mustache b/tornado/rest.mustache new file mode 100644 index 0000000000..bc74fbc295 --- /dev/null +++ b/tornado/rest.mustache @@ -0,0 +1,255 @@ +# coding: utf-8 + +{{>partial_header}} + +import io +import json +import logging +import re + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode +import tornado +import tornado.gen +from tornado import httpclient +from urllib3.filepost import encode_multipart_formdata + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.tornado_response = resp + self.status = resp.code + self.reason = resp.reason + + if resp.body: + # In Python 3, the response body is utf-8 encoded bytes. + if six.PY3: + self.data = resp.body.decode('utf-8') + else: + self.data = resp.body + else: + self.data = None + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.tornado_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.tornado_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=4): + # maxsize is number of requests to host that are allowed in parallel + + self.ca_certs = configuration.ssl_ca_cert + self.client_key = configuration.key_file + self.client_cert = configuration.cert_file + + self.proxy_port = self.proxy_host = None + + # https pool manager + if configuration.proxy: + self.proxy_port = 80 + self.proxy_host = configuration.proxy + + self.pool_manager = httpclient.AsyncHTTPClient() + + @tornado.gen.coroutine + def request(self, method, url, query_params=None, headers=None, body=None, + post_params=None, _preload_content=True, + _request_timeout=None): + """Execute Request + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: this is a non-applicable field for + the AiohttpClient. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + request = httpclient.HTTPRequest(url) + request.allow_nonstandard_methods = True + request.ca_certs = self.ca_certs + request.client_key = self.client_key + request.client_cert = self.client_cert + request.proxy_host = self.proxy_host + request.proxy_port = self.proxy_port + request.method = method + if headers: + request.headers = headers + if 'Content-Type' not in headers: + request.headers['Content-Type'] = 'application/json' + request.request_timeout = _request_timeout or 5 * 60 + + post_params = post_params or {} + + if query_params: + request.url += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body: + body = json.dumps(body) + request.body = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + request.body = urlencode(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + multipart = encode_multipart_formdata(post_params) + request.body, headers['Content-Type'] = multipart + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + request.body = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + r = yield self.pool_manager.fetch(request, raise_error=False) + + if _preload_content: + + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + raise tornado.gen.Return(r) + + @tornado.gen.coroutine + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + result = yield self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\nReason: {1}\n".format( + self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/tox.mustache b/tox.mustache new file mode 100644 index 0000000000..63d12fdeae --- /dev/null +++ b/tox.mustache @@ -0,0 +1,20 @@ +[tox] +{{^asyncio}} +envlist = py27, py3 +{{/asyncio}} +{{#asyncio}} +envlist = py3 +{{/asyncio}} + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= +{{^asyncio}} + nosetests \ + [] +{{/asyncio}} +{{#asyncio}} + pytest -v --cov petstore_api +{{/asyncio}} diff --git a/travis.mustache b/travis.mustache new file mode 100644 index 0000000000..86211e2d4a --- /dev/null +++ b/travis.mustache @@ -0,0 +1,14 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + #- "3.5-dev" # 3.5 development branch + #- "nightly" # points to the latest development branch e.g. 3.6-dev +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +script: nosetests From 309f429de5831d7f8acc7bad6f468913266d4e18 Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Sat, 14 Apr 2018 16:36:30 +0200 Subject: [PATCH 002/185] Rename projects from swagger-codegen master branch --- README.mustache | 125 ++++++++ __init__api.mustache | 7 + __init__model.mustache | 10 + __init__package.mustache | 17 + __init__test.mustache | 0 api.mustache | 214 +++++++++++++ api_client.mustache | 627 +++++++++++++++++++++++++++++++++++++ api_doc.mustache | 85 +++++ api_test.mustache | 37 +++ asyncio/rest.mustache | 260 +++++++++++++++ configuration.mustache | 260 +++++++++++++++ git_push.sh.mustache | 52 +++ gitignore.mustache | 64 ++++ model.mustache | 219 +++++++++++++ model_doc.mustache | 11 + model_test.mustache | 35 +++ partial_header.mustache | 13 + requirements.mustache | 5 + rest.mustache | 314 +++++++++++++++++++ setup.mustache | 43 +++ test-requirements.mustache | 11 + tornado/rest.mustache | 255 +++++++++++++++ tox.mustache | 20 ++ travis.mustache | 14 + 24 files changed, 2698 insertions(+) create mode 100644 README.mustache create mode 100644 __init__api.mustache create mode 100644 __init__model.mustache create mode 100644 __init__package.mustache create mode 100644 __init__test.mustache create mode 100644 api.mustache create mode 100644 api_client.mustache create mode 100644 api_doc.mustache create mode 100644 api_test.mustache create mode 100644 asyncio/rest.mustache create mode 100644 configuration.mustache create mode 100755 git_push.sh.mustache create mode 100644 gitignore.mustache create mode 100644 model.mustache create mode 100644 model_doc.mustache create mode 100644 model_test.mustache create mode 100644 partial_header.mustache create mode 100644 requirements.mustache create mode 100644 rest.mustache create mode 100644 setup.mustache create mode 100644 test-requirements.mustache create mode 100644 tornado/rest.mustache create mode 100644 tox.mustache create mode 100644 travis.mustache diff --git a/README.mustache b/README.mustache new file mode 100644 index 0000000000..c1355be778 --- /dev/null +++ b/README.mustache @@ -0,0 +1,125 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github + +```sh +pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +{{{packageName}}}.configuration.username = 'YOUR_USERNAME' +{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/__init__api.mustache b/__init__api.mustache new file mode 100644 index 0000000000..db658a10fa --- /dev/null +++ b/__init__api.mustache @@ -0,0 +1,7 @@ +from __future__ import absolute_import + +# flake8: noqa + +# import apis into api package +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} \ No newline at end of file diff --git a/__init__model.mustache b/__init__model.mustache new file mode 100644 index 0000000000..2266b3d17f --- /dev/null +++ b/__init__model.mustache @@ -0,0 +1,10 @@ +# coding: utf-8 + +# flake8: noqa +{{>partial_header}} + +from __future__ import absolute_import + +# import models into model package +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} +{{/models}} diff --git a/__init__package.mustache b/__init__package.mustache new file mode 100644 index 0000000000..cd42506f54 --- /dev/null +++ b/__init__package.mustache @@ -0,0 +1,17 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +# import apis into sdk package +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} +# import ApiClient +from {{packageName}}.api_client import ApiClient +from {{packageName}}.configuration import Configuration +# import models into sdk package +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} +{{/model}}{{/models}} \ No newline at end of file diff --git a/__init__test.mustache b/__init__test.mustache new file mode 100644 index 0000000000..e69de29bb2 diff --git a/api.mustache b/api.mustache new file mode 100644 index 0000000000..a65946f578 --- /dev/null +++ b/api.mustache @@ -0,0 +1,214 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from {{packageName}}.api_client import ApiClient + + +{{#operations}} +class {{classname}}(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client +{{#operation}} + + def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async bool +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/allParams}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async'): + return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 + else: + (data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 + return data + + def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() + + :param async bool +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} +{{/allParams}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + + all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 + all_params.append('async') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method {{operationId}}" % key + ) + params[key] = val + del params['kwargs'] +{{#allParams}} +{{#required}} + # verify the required parameter '{{paramName}}' is set + if ('{{paramName}}' not in params or + params['{{paramName}}'] is None): + raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 +{{/required}} +{{/allParams}} + +{{#allParams}} +{{#hasValidation}} + {{#maxLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 + {{/maxLength}} + {{#minLength}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minLength}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 + {{/minLength}} + {{#maximum}} + if '{{paramName}}' in params and params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 + {{/maximum}} + {{#minimum}} + if '{{paramName}}' in params and params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 + {{/minimum}} + {{#pattern}} + if '{{paramName}}' in params and not re.search('{{{vendorExtensions.x-regex}}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 + {{/pattern}} + {{#maxItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) > {{maxItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 + {{/maxItems}} + {{#minItems}} + if ('{{paramName}}' in params and + len(params['{{paramName}}']) < {{minItems}}): + raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 + {{/minItems}} +{{/hasValidation}} +{{#-last}} +{{/-last}} +{{/allParams}} + collection_formats = {} + + path_params = {} +{{#pathParams}} + if '{{paramName}}' in params: + path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/pathParams}} + + query_params = [] +{{#queryParams}} + if '{{paramName}}' in params: + query_params.append(('{{baseName}}', params['{{paramName}}'])){{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/queryParams}} + + header_params = {} +{{#headerParams}} + if '{{paramName}}' in params: + header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/headerParams}} + + form_params = [] + local_var_files = {} +{{#formParams}} + if '{{paramName}}' in params: + {{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/formParams}} + + body_params = None +{{#bodyParam}} + if '{{paramName}}' in params: + body_params = params['{{paramName}}'] +{{/bodyParam}} + {{#hasProduces}} + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + + {{/hasProduces}} + {{#hasConsumes}} + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + + {{/hasConsumes}} + # Authentication setting + auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + + return self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 + auth_settings=auth_settings, + async=params.get('async'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) +{{/operation}} +{{/operations}} diff --git a/api_client.mustache b/api_client.mustache new file mode 100644 index 0000000000..a6df41b072 --- /dev/null +++ b/api_client.mustache @@ -0,0 +1,627 @@ +# coding: utf-8 +{{>partial_header}} +from __future__ import absolute_import + +import datetime +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote +{{#tornado}} +import tornado.gen +{{/tornado}} + +from {{packageName}}.configuration import Configuration +import {{modelPackage}} +from {{packageName}} import rest + + +class ApiClient(object): + """Generic API client for Swagger client library builds. + + Swagger generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the Swagger + templates. + + NOTE: This class is auto generated by the swagger code generator program. + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + + self.pool = ThreadPool() + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}' + + def __del__(self): + self.pool.close() + self.pool.join() + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + {{#tornado}} + @tornado.gen.coroutine + {{/tornado}} + {{#asyncio}}async {{/asyncio}}def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = self.prepare_post_parameters(post_params, files) + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + url = self.configuration.host + resource_path + + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + + self.last_response = response_data + + return_data = response_data + if _preload_content: + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + +{{^tornado}} + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) +{{/tornado}} +{{#tornado}} + if _return_http_data_only: + raise tornado.gen.Return(return_data) + else: + raise tornado.gen.Return((return_data, response_data.status, + response_data.getheaders())) +{{/tornado}} + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is swagger model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `swagger_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} + + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if type(klass) == str: + if klass.startswith('list['): + sub_kls = re.match('list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('dict('): + sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr({{modelPackage}}, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datatime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async request, set the async parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async bool: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: + If async parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async is False or missing, + then the method will return the response directly. + """ + if not async: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout) + else: + thread = self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, query_params, + header_params, body, + post_params, files, + response_type, auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, _request_timeout)) + return thread + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def prepare_post_parameters(self, post_params=None, files=None): + """Builds form parameters. + + :param post_params: Normal form parameters. + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if post_params: + params = post_params + + if files: + for k, v in six.iteritems(files): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return six.text_type(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return a original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + from dateutil.parser import parse + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datatime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + from dateutil.parser import parse + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + if not klass.swagger_types and not hasattr(klass, + 'get_real_child_model'): + return data + + kwargs = {} + if klass.swagger_types is not None: + for attr, attr_type in six.iteritems(klass.swagger_types): + if (data is not None and + klass.attribute_map[attr] in data and + isinstance(data, (list, dict))): + value = data[klass.attribute_map[attr]] + kwargs[attr] = self.__deserialize(value, attr_type) + + instance = klass(**kwargs) + + if hasattr(instance, 'get_real_child_model'): + klass_name = instance.get_real_child_model(data) + if klass_name: + instance = self.__deserialize(data, klass_name) + return instance diff --git a/api_doc.mustache b/api_doc.mustache new file mode 100644 index 0000000000..32c26d929d --- /dev/null +++ b/api_doc.mustache @@ -0,0 +1,85 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/api_test.mustache b/api_test.mustache new file mode 100644 index 0000000000..90fafc15f3 --- /dev/null +++ b/api_test.mustache @@ -0,0 +1,37 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +import {{packageName}} +from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 +from {{packageName}}.rest import ApiException + + +class {{#operations}}Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + self.api = {{apiPackage}}.{{classVarName}}.{{classname}}() # noqa: E501 + + def tearDown(self): + pass + + {{#operation}} + def test_{{operationId}}(self): + """Test case for {{{operationId}}} + +{{#summary}} + {{{summary}}} # noqa: E501 +{{/summary}} + """ + pass + + {{/operation}} +{{/operations}} + +if __name__ == '__main__': + unittest.main() diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache new file mode 100644 index 0000000000..39003abfbf --- /dev/null +++ b/asyncio/rest.mustache @@ -0,0 +1,260 @@ +# coding: utf-8 + +{{>partial_header}} + +import io +import json +import logging +import re +import ssl + +import aiohttp +import certifi +# python 2 and python 3 compatibility library +from six.moves.urllib.parse import urlencode + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp, data): + self.aiohttp_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = data + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.aiohttp_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.aiohttp_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=4): + # maxsize is number of requests to host that are allowed in parallel + # ca_certs vs cert_file vs key_file + # http://stackoverflow.com/a/23957365/2985775 + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + ssl_context = ssl.create_default_context(cafile=ca_certs) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + + connector = aiohttp.TCPConnector( + limit=maxsize, + ssl_context=ssl_context, + verify_ssl=configuration.verify_ssl + ) + + # https pool manager + if configuration.proxy: + self.pool_manager = aiohttp.ClientSession( + connector=connector, + proxy=configuration.proxy + ) + else: + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) + + async def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Execute request + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: this is a non-applicable field for + the AiohttpClient. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + timeout = _request_timeout or 5 * 60 + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + args = { + "method": method, + "url": url, + "timeout": timeout, + "headers": headers + } + + if query_params: + args["url"] += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body is not None: + body = json.dumps(body) + args["data"] = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + args["data"] = aiohttp.FormData(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by aiohttp + del headers['Content-Type'] + data = aiohttp.FormData() + for param in post_params: + k, v = param + if isinstance(v, tuple) and len(v) == 3: + data.add_field(k, + value=v[1], + filename=v[0], + content_type=v[2]) + else: + data.add_field(k, v) + args["data"] = data + + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + args["data"] = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + async with self.pool_manager.request(**args) as r: + data = await r.text() + r = RESTResponse(r, data) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + async def GET(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def HEAD(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def OPTIONS(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return (await self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def POST(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return (await self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PATCH(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/configuration.mustache b/configuration.mustache new file mode 100644 index 0000000000..84e6ad4d20 --- /dev/null +++ b/configuration.mustache @@ -0,0 +1,260 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import six +from six.moves import http_client as httplib + + +class TypeWithDefault(type): + def __init__(cls, name, bases, dct): + super(TypeWithDefault, cls).__init__(name, bases, dct) + cls._default = None + + def __call__(cls): + if cls._default is None: + cls._default = type.__call__(cls) + return copy.copy(cls._default) + + def set_default(cls, default): + cls._default = copy.copy(default) + + +class Configuration(six.with_metaclass(TypeWithDefault, object)): + """NOTE: This class is auto generated by the swagger code generator program. + + Ref: https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + """ + + def __init__(self): + """Constructor""" + # Default Base url + self.host = "{{{basePath}}}" + # Temp file folder for downloading files + self.temp_folder_path = None + + # Authentication Settings + # dict to store API key(s) + self.api_key = {} + # dict to store API prefix (e.g. Bearer) + self.api_key_prefix = {} + # Username for HTTP basic authentication + self.username = "" + # Password for HTTP basic authentication + self.password = "" +{{#authMethods}}{{#isOAuth}} + # access token for OAuth + self.access_token = "" +{{/isOAuth}}{{/authMethods}} + # Logging Settings + self.logger = {} + self.logger["package_logger"] = logging.getLogger("{{packageName}}") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + # Log format + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + # Log stream handler + self.logger_stream_handler = None + # Log file handler + self.logger_file_handler = None + # Debug file location + self.logger_file = None + # Debug switch + self.debug = False + + # SSL/TLS verification + # Set this to false to skip verifying SSL certificate when calling API + # from https server. + self.verify_ssl = True + # Set this to customize the certificate file to verify the peer. + self.ssl_ca_cert = None + # client certificate file + self.cert_file = None + # client key file + self.key_file = None + # Set this to True/False to enable/disable SSL hostname verification. + self.assert_hostname = None + + # urllib3 connection pool's maximum number of connections saved + # per pool. urllib3 uses 1 connection as default value, but this is + # not the best value when you are making a lot of possibly parallel + # requests to the same host, which is often the case here. + # cpu_count * 5 is used as default value to increase performance. + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + + # Proxy URL + self.proxy = None + # Safe chars for path_param + self.safe_chars_for_path_param = '' + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_file_handler) + if self.logger_stream_handler: + logger.removeHandler(self.logger_stream_handler) + else: + # If not set logging file, + # then add stream handler and remove file handler. + self.logger_stream_handler = logging.StreamHandler() + self.logger_stream_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_stream_handler) + if self.logger_file_handler: + logger.removeHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :return: The token for api key authentication. + """ + if (self.api_key.get(identifier) and + self.api_key_prefix.get(identifier)): + return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501 + elif self.api_key.get(identifier): + return self.api_key[identifier] + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + return urllib3.util.make_headers( + basic_auth=self.username + ':' + self.password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + return { +{{#authMethods}} +{{#isApiKey}} + '{{name}}': + { + 'type': 'api_key', + 'in': {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix('{{keyParamName}}') + }, +{{/isApiKey}} +{{#isBasic}} + '{{name}}': + { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + }, +{{/isBasic}}{{#isOAuth}} + '{{name}}': + { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + }, +{{/isOAuth}}{{/authMethods}} + } + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: {{version}}\n"\ + "SDK Package Version: {{packageVersion}}".\ + format(env=sys.platform, pyversion=sys.version) diff --git a/git_push.sh.mustache b/git_push.sh.mustache new file mode 100755 index 0000000000..a2d7523483 --- /dev/null +++ b/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/gitignore.mustache b/gitignore.mustache new file mode 100644 index 0000000000..a655050c26 --- /dev/null +++ b/gitignore.mustache @@ -0,0 +1,64 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.python-version + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/model.mustache b/model.mustache new file mode 100644 index 0000000000..5668793b3f --- /dev/null +++ b/model.mustache @@ -0,0 +1,219 @@ +# coding: utf-8 + +{{>partial_header}} + +import pprint +import re # noqa: F401 + +import six +{{#imports}}{{#-first}} +{{/-first}} +{{import}} # noqa: F401,E501 +{{/imports}} + + +{{#models}} +{{#model}} +class {{classname}}(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """{{#allowableValues}} + + """ + allowed enum values + """ +{{#enumVars}} + {{name}} = {{{value}}}{{^-last}} +{{/-last}} +{{/enumVars}}{{/allowableValues}} + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { +{{#vars}} + '{{name}}': '{{{datatype}}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } + + attribute_map = { +{{#vars}} + '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } +{{#discriminator}} + + discriminator_value_class_map = { + {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, + {{/-last}}{{/children}} + } +{{/discriminator}} + + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + """{{classname}} - a model defined in Swagger""" # noqa: E501 +{{#vars}}{{#-first}} +{{/-first}} + self._{{name}} = None +{{/vars}} + self.discriminator = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} +{{#vars}}{{#-first}} +{{/-first}} +{{#required}} + self.{{name}} = {{name}} +{{/required}} +{{^required}} + if {{name}} is not None: + self.{{name}} = {{name}} +{{/required}} +{{/vars}} + +{{#vars}} + @property + def {{name}}(self): + """Gets the {{name}} of this {{classname}}. # noqa: E501 + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :return: The {{name}} of this {{classname}}. # noqa: E501 + :rtype: {{datatype}} + """ + return self._{{name}} + + @{{name}}.setter + def {{name}}(self, {{name}}): + """Sets the {{name}} of this {{classname}}. + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 + :type: {{datatype}} + """ +{{#required}} + if {{name}} is None: + raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 +{{/required}} +{{#isEnum}} +{{#isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 +{{#isListContainer}} + if not set({{{name}}}).issubset(set(allowed_values)): + raise ValueError( + "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isListContainer}} +{{#isMapContainer}} + if not set({{{name}}}.keys()).issubset(set(allowed_values)): + raise ValueError( + "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isMapContainer}} +{{/isContainer}} +{{^isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + if {{{name}}} not in allowed_values: + raise ValueError( + "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 + .format({{{name}}}, allowed_values) + ) +{{/isContainer}} +{{/isEnum}} +{{^isEnum}} +{{#hasValidation}} +{{#maxLength}} + if {{name}} is not None and len({{name}}) > {{maxLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 +{{/maxLength}} +{{#minLength}} + if {{name}} is not None and len({{name}}) < {{minLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 +{{/minLength}} +{{#maximum}} + if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 +{{/maximum}} +{{#minimum}} + if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 +{{/minimum}} +{{#pattern}} + if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 +{{/pattern}} +{{#maxItems}} + if {{name}} is not None and len({{name}}) > {{maxItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 +{{/maxItems}} +{{#minItems}} + if {{name}} is not None and len({{name}}) < {{minItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 +{{/minItems}} +{{/hasValidation}} +{{/isEnum}} + + self._{{name}} = {{name}} + +{{/vars}} +{{#discriminator}} + def get_real_child_model(self, data): + """Returns the real base class specified by the discriminator""" + discriminator_value = data[self.discriminator].lower() + return self.discriminator_value_class_map.get(discriminator_value) + +{{/discriminator}} + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other +{{/model}} +{{/models}} diff --git a/model_doc.mustache b/model_doc.mustache new file mode 100644 index 0000000000..569550df37 --- /dev/null +++ b/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/model_test.mustache b/model_test.mustache new file mode 100644 index 0000000000..765e4f9c2c --- /dev/null +++ b/model_test.mustache @@ -0,0 +1,35 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +{{#models}} +{{#model}} +import {{packageName}} +from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 +from {{packageName}}.rest import ApiException + + +class Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test{{classname}}(self): + """Test {{classname}}""" + # FIXME: construct object with mandatory attributes with example values + # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 + pass + +{{/model}} +{{/models}} + +if __name__ == '__main__': + unittest.main() diff --git a/partial_header.mustache b/partial_header.mustache new file mode 100644 index 0000000000..513ad04cdb --- /dev/null +++ b/partial_header.mustache @@ -0,0 +1,13 @@ +""" +{{#appName}} + {{{appName}}} +{{/appName}} + +{{#appDescription}} + {{{appDescription}}} # noqa: E501 +{{/appDescription}} + + {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" diff --git a/requirements.mustache b/requirements.mustache new file mode 100644 index 0000000000..bafdc07532 --- /dev/null +++ b/requirements.mustache @@ -0,0 +1,5 @@ +certifi >= 14.05.14 +six >= 1.10 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/rest.mustache b/rest.mustache new file mode 100644 index 0000000000..ff9b019dc5 --- /dev/null +++ b/rest.mustache @@ -0,0 +1,314 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import io +import json +import logging +import re +import ssl + +import certifi +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode + +try: + import urllib3 +except ImportError: + raise ImportError('Swagger python client requires urllib3.') + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.getheaders() + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.getheader(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if query_params: + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # In the python 3, the response.data is bytes. + # we need to decode it to string. + if six.PY3: + r.data = r.data.decode('utf8') + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/setup.mustache b/setup.mustache new file mode 100644 index 0000000000..e7107e9be9 --- /dev/null +++ b/setup.mustache @@ -0,0 +1,43 @@ +# coding: utf-8 + +{{>partial_header}} + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "{{{projectName}}}" +VERSION = "{{packageVersion}}" +{{#apiInfo}} +{{#apis}} +{{^hasMore}} +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +{{#asyncio}} +REQUIRES.append("aiohttp") +{{/asyncio}} +{{#tornado}} +REQUIRES.append("tornado") +{{/tornado}} + +setup( + name=NAME, + version=VERSION, + description="{{appName}}", + author_email="{{infoEmail}}", + url="{{packageUrl}}", + keywords=["Swagger", "{{appName}}"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + {{appDescription}} # noqa: E501 + """ +) +{{/hasMore}} +{{/apis}} +{{/apiInfo}} diff --git a/test-requirements.mustache b/test-requirements.mustache new file mode 100644 index 0000000000..31f8d94d99 --- /dev/null +++ b/test-requirements.mustache @@ -0,0 +1,11 @@ +{{^asyncio}} +coverage>=4.0.3 +nose>=1.3.7 +{{/asyncio}} +{{#asyncio}} +pytest>=3.3.1 +pytest-cov>=2.5.1 +{{/asyncio}} +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 diff --git a/tornado/rest.mustache b/tornado/rest.mustache new file mode 100644 index 0000000000..bc74fbc295 --- /dev/null +++ b/tornado/rest.mustache @@ -0,0 +1,255 @@ +# coding: utf-8 + +{{>partial_header}} + +import io +import json +import logging +import re + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode +import tornado +import tornado.gen +from tornado import httpclient +from urllib3.filepost import encode_multipart_formdata + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.tornado_response = resp + self.status = resp.code + self.reason = resp.reason + + if resp.body: + # In Python 3, the response body is utf-8 encoded bytes. + if six.PY3: + self.data = resp.body.decode('utf-8') + else: + self.data = resp.body + else: + self.data = None + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.tornado_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.tornado_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=4): + # maxsize is number of requests to host that are allowed in parallel + + self.ca_certs = configuration.ssl_ca_cert + self.client_key = configuration.key_file + self.client_cert = configuration.cert_file + + self.proxy_port = self.proxy_host = None + + # https pool manager + if configuration.proxy: + self.proxy_port = 80 + self.proxy_host = configuration.proxy + + self.pool_manager = httpclient.AsyncHTTPClient() + + @tornado.gen.coroutine + def request(self, method, url, query_params=None, headers=None, body=None, + post_params=None, _preload_content=True, + _request_timeout=None): + """Execute Request + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: this is a non-applicable field for + the AiohttpClient. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ValueError( + "body parameter cannot be used with post_params parameter." + ) + + request = httpclient.HTTPRequest(url) + request.allow_nonstandard_methods = True + request.ca_certs = self.ca_certs + request.client_key = self.client_key + request.client_cert = self.client_cert + request.proxy_host = self.proxy_host + request.proxy_port = self.proxy_port + request.method = method + if headers: + request.headers = headers + if 'Content-Type' not in headers: + request.headers['Content-Type'] = 'application/json' + request.request_timeout = _request_timeout or 5 * 60 + + post_params = post_params or {} + + if query_params: + request.url += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body: + body = json.dumps(body) + request.body = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + request.body = urlencode(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + multipart = encode_multipart_formdata(post_params) + request.body, headers['Content-Type'] = multipart + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + request.body = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + r = yield self.pool_manager.fetch(request, raise_error=False) + + if _preload_content: + + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + raise tornado.gen.Return(r) + + @tornado.gen.coroutine + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + result = yield self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + +class ApiException(Exception): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\nReason: {1}\n".format( + self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message diff --git a/tox.mustache b/tox.mustache new file mode 100644 index 0000000000..63d12fdeae --- /dev/null +++ b/tox.mustache @@ -0,0 +1,20 @@ +[tox] +{{^asyncio}} +envlist = py27, py3 +{{/asyncio}} +{{#asyncio}} +envlist = py3 +{{/asyncio}} + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= +{{^asyncio}} + nosetests \ + [] +{{/asyncio}} +{{#asyncio}} + pytest -v --cov petstore_api +{{/asyncio}} diff --git a/travis.mustache b/travis.mustache new file mode 100644 index 0000000000..86211e2d4a --- /dev/null +++ b/travis.mustache @@ -0,0 +1,14 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + #- "3.5-dev" # 3.5 development branch + #- "nightly" # points to the latest development branch e.g. 3.6-dev +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +script: nosetests From 092c6f0b7acda2a64f53c2257796096b4e8c92aa Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Tue, 17 Apr 2018 09:19:10 +0200 Subject: [PATCH 003/185] Add OpenAPI spec 3.0 support (beta) Co-authored-by: Akihito Nakano Co-authored-by: Jeremie Bresson Co-authored-by: Jim Schubert Co-authored-by: Martin Delille Co-authored-by: Tomasz Prus Co-authored-by: William Cheng --- api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.mustache b/api.mustache index a65946f578..512d2570b1 100644 --- a/api.mustache +++ b/api.mustache @@ -171,7 +171,7 @@ class {{classname}}(object): local_var_files = {} {{#formParams}} if '{{paramName}}' in params: - {{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + {{^isFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/formParams}} From 1d0decf44f33b9514284566238a951b5db4f550a Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 19 Apr 2018 15:02:22 +0800 Subject: [PATCH 004/185] update discriminator to discriminatorName (#142) --- model.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model.mustache b/model.mustache index 5668793b3f..7184f4192a 100644 --- a/model.mustache +++ b/model.mustache @@ -60,7 +60,7 @@ class {{classname}}(object): {{/-first}} self._{{name}} = None {{/vars}} - self.discriminator = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} + self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} {{#vars}}{{#-first}} {{/-first}} {{#required}} From ae4219847a2b8ea69e0ddad2fe4566afbf9a9977 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Sat, 21 Apr 2018 05:54:40 +0200 Subject: [PATCH 005/185] fix: python clients (#136) * fix: python client * fix: regenerate petstore samples for python-asyncio/tornado * fix: python-asyncio tests * fix: python-tornado tests * chore: update python samples * fix: enable tests for python-tornado * fix: discriminator property * fix: file type * python: regenerate samples * fix: define file as generic type --- setup.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.mustache b/setup.mustache index e7107e9be9..597136a8d1 100644 --- a/setup.mustache +++ b/setup.mustache @@ -21,7 +21,7 @@ REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] REQUIRES.append("aiohttp") {{/asyncio}} {{#tornado}} -REQUIRES.append("tornado") +REQUIRES.append("tornado>=4.2,<5") {{/tornado}} setup( From 8b0eb01650fabb67592135f9ec43e345dd595020 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 2 May 2018 01:12:32 +0800 Subject: [PATCH 006/185] update default user agent (#284) --- api_client.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index a6df41b072..0339fbd81a 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -67,7 +67,7 @@ class ApiClient(object): self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}' + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' def __del__(self): self.pool.close() From e154b6d70f7c4f3fd5d919a0b64afb37d0eadfc4 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 3 May 2018 20:12:24 +0800 Subject: [PATCH 007/185] Update wordings (#301) * update wordings * update git_push wordings * update git clone * update homepage url * update meta-codegen sample --- README.mustache | 2 +- api.mustache | 4 ++-- api_client.mustache | 4 ++-- configuration.mustache | 4 ++-- git_push.sh.mustache | 2 +- model.mustache | 2 +- partial_header.mustache | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.mustache b/README.mustache index c1355be778..184dbdc61d 100644 --- a/README.mustache +++ b/README.mustache @@ -3,7 +3,7 @@ {{{appDescription}}} {{/appDescription}} -This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: {{appVersion}} - Package version: {{packageVersion}} diff --git a/api.mustache b/api.mustache index 512d2570b1..1925d4d164 100644 --- a/api.mustache +++ b/api.mustache @@ -14,10 +14,10 @@ from {{packageName}}.api_client import ApiClient {{#operations}} class {{classname}}(object): - """NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen + Ref: https://openapi-generator.tech """ def __init__(self, api_client=None): diff --git a/api_client.mustache b/api_client.mustache index 0339fbd81a..4b7b2bf86a 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -30,8 +30,8 @@ class ApiClient(object): the methods and models for each application are generated from the Swagger templates. - NOTE: This class is auto generated by the swagger code generator program. - Ref: https://github.com/swagger-api/swagger-codegen + NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + Ref: https://openapi-generator.tech Do not edit the class manually. :param configuration: .Configuration object for this client diff --git a/configuration.mustache b/configuration.mustache index 84e6ad4d20..72702d8d1f 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -29,9 +29,9 @@ class TypeWithDefault(type): class Configuration(six.with_metaclass(TypeWithDefault, object)): - """NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - Ref: https://github.com/swagger-api/swagger-codegen + Ref: https://openapi-generator.tech Do not edit the class manually. """ diff --git a/git_push.sh.mustache b/git_push.sh.mustache index a2d7523483..8a32e53995 100755 --- a/git_push.sh.mustache +++ b/git_push.sh.mustache @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/model.mustache b/model.mustache index 7184f4192a..9d7a6f9a6b 100644 --- a/model.mustache +++ b/model.mustache @@ -15,7 +15,7 @@ import six {{#models}} {{#model}} class {{classname}}(object): - """NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. """{{#allowableValues}} diff --git a/partial_header.mustache b/partial_header.mustache index 513ad04cdb..929e512e08 100644 --- a/partial_header.mustache +++ b/partial_header.mustache @@ -9,5 +9,5 @@ {{#version}}OpenAPI spec version: {{{version}}}{{/version}} {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} - Generated by: https://github.com/swagger-api/swagger-codegen.git + Generated by: https://openapi-generator.tech """ From 512ddfcb739a20c3f6356229112ba34a722307e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bresson?= Date: Sat, 5 May 2018 16:40:52 +0200 Subject: [PATCH 008/185] Merge 'master' branch of 'swagger-codegen' into 'openapi-generator' (#327) --- README.mustache | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.mustache b/README.mustache index 184dbdc61d..cf92dc583d 100644 --- a/README.mustache +++ b/README.mustache @@ -60,17 +60,21 @@ from {{{packageName}}}.rest import ApiException from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} # Configure HTTP basic authorization: {{{name}}} -{{{packageName}}}.configuration.username = 'YOUR_USERNAME' -{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} -{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} # Configure OAuth2 access token for authorization: {{{name}}} -{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} + # create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}() +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} From 30b63c01b3561175e57ff3b7234e26dcba749b08 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 8 May 2018 01:23:49 +0800 Subject: [PATCH 009/185] Update python default value (#360) * update pythong default value * fix example, update python sample * update python petstore sample (asyncio, tornado) --- api.mustache | 1 - api_client.mustache | 19 +++++++++---------- model.mustache | 8 ++++---- partial_header.mustache | 8 ++++++-- rest.mustache | 2 +- setup.mustache | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/api.mustache b/api.mustache index 1925d4d164..ebafd266e9 100644 --- a/api.mustache +++ b/api.mustache @@ -17,7 +17,6 @@ class {{classname}}(object): """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. - Ref: https://openapi-generator.tech """ def __init__(self, api_client=None): diff --git a/api_client.mustache b/api_client.mustache index 4b7b2bf86a..bd72c76769 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -23,15 +23,14 @@ from {{packageName}} import rest class ApiClient(object): - """Generic API client for Swagger client library builds. + """Generic API client for OpenAPI client library builds. - Swagger generic API client. This client handles the client- + OpenAPI generic API client. This client handles the client- server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the Swagger + the methods and models for each application are generated from the OpenAPI templates. NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - Ref: https://openapi-generator.tech Do not edit the class manually. :param configuration: .Configuration object for this client @@ -183,7 +182,7 @@ class ApiClient(object): convert to string in iso8601 format. If obj is list, sanitize each element in the list. If obj is dict, return the dict. - If obj is swagger model, return the properties dict. + If obj is OpenAPI model, return the properties dict. :param obj: The data to serialize. :return: The serialized form of data. @@ -205,12 +204,12 @@ class ApiClient(object): obj_dict = obj else: # Convert model obj to dict except - # attributes `swagger_types`, `attribute_map` + # attributes `openapi_types`, `attribute_map` # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.swagger_types) + for attr, _ in six.iteritems(obj.openapi_types) if getattr(obj, attr) is not None} return {key: self.sanitize_for_serialization(val) @@ -605,13 +604,13 @@ class ApiClient(object): :return: model object. """ - if not klass.swagger_types and not hasattr(klass, + if not klass.openapi_types and not hasattr(klass, 'get_real_child_model'): return data kwargs = {} - if klass.swagger_types is not None: - for attr, attr_type in six.iteritems(klass.swagger_types): + if klass.openapi_types is not None: + for attr, attr_type in six.iteritems(klass.openapi_types): if (data is not None and klass.attribute_map[attr] in data and isinstance(data, (list, dict))): diff --git a/model.mustache b/model.mustache index 9d7a6f9a6b..3d69ce83b1 100644 --- a/model.mustache +++ b/model.mustache @@ -30,12 +30,12 @@ class {{classname}}(object): """ Attributes: - swagger_types (dict): The key is attribute name + openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { + openapi_types = { {{#vars}} '{{name}}': '{{{datatype}}}'{{#hasMore}},{{/hasMore}} {{/vars}} @@ -55,7 +55,7 @@ class {{classname}}(object): {{/discriminator}} def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 - """{{classname}} - a model defined in Swagger""" # noqa: E501 + """{{classname}} - a model defined in OpenAPI""" # noqa: E501 {{#vars}}{{#-first}} {{/-first}} self._{{name}} = None @@ -177,7 +177,7 @@ class {{classname}}(object): """Returns the model properties as a dict""" result = {} - for attr, _ in six.iteritems(self.swagger_types): + for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( diff --git a/partial_header.mustache b/partial_header.mustache index 929e512e08..b83479cdbb 100644 --- a/partial_header.mustache +++ b/partial_header.mustache @@ -7,7 +7,11 @@ {{{appDescription}}} # noqa: E501 {{/appDescription}} - {{#version}}OpenAPI spec version: {{{version}}}{{/version}} - {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + {{#version}} + OpenAPI spec version: {{{version}}} + {{/version}} + {{#infoEmail}} + Contact: {{{infoEmail}}} + {{/infoEmail}} Generated by: https://openapi-generator.tech """ diff --git a/rest.mustache b/rest.mustache index ff9b019dc5..8418ec2a0f 100644 --- a/rest.mustache +++ b/rest.mustache @@ -18,7 +18,7 @@ from six.moves.urllib.parse import urlencode try: import urllib3 except ImportError: - raise ImportError('Swagger python client requires urllib3.') + raise ImportError('OpenAPI Python client requires urllib3.') logger = logging.getLogger(__name__) diff --git a/setup.mustache b/setup.mustache index 597136a8d1..15d2450471 100644 --- a/setup.mustache +++ b/setup.mustache @@ -30,7 +30,7 @@ setup( description="{{appName}}", author_email="{{infoEmail}}", url="{{packageUrl}}", - keywords=["Swagger", "{{appName}}"], + keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], install_requires=REQUIRES, packages=find_packages(), include_package_data=True, From 604c88b98f2b041a2713f463e43886354e1acec6 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 12 May 2018 09:54:19 +0800 Subject: [PATCH 010/185] Update python test (#426) * update python test folders * update python template * update python samples * fix python comment too long * update ruby test case --- api.mustache | 3 ++- api_client.mustache | 3 ++- configuration.mustache | 2 +- model.mustache | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api.mustache b/api.mustache index ebafd266e9..60ec9ff0a4 100644 --- a/api.mustache +++ b/api.mustache @@ -14,7 +14,8 @@ from {{packageName}}.api_client import ApiClient {{#operations}} class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech Do not edit the class manually. """ diff --git a/api_client.mustache b/api_client.mustache index bd72c76769..b044229828 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -30,7 +30,8 @@ class ApiClient(object): the methods and models for each application are generated from the OpenAPI templates. - NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech Do not edit the class manually. :param configuration: .Configuration object for this client diff --git a/configuration.mustache b/configuration.mustache index 72702d8d1f..398c1d3dab 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -29,7 +29,7 @@ class TypeWithDefault(type): class Configuration(six.with_metaclass(TypeWithDefault, object)): - """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. diff --git a/model.mustache b/model.mustache index 3d69ce83b1..a2f899eeea 100644 --- a/model.mustache +++ b/model.mustache @@ -15,7 +15,8 @@ import six {{#models}} {{#model}} class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech Do not edit the class manually. """{{#allowableValues}} From 3ca216f935061b4cd2972c8b17da2bae443c5d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bresson?= Date: Fri, 18 May 2018 18:06:37 +0200 Subject: [PATCH 011/185] Rename datatype to dataType in CodegenProperty (#69) --- model.mustache | 6 +++--- model_doc.mustache | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/model.mustache b/model.mustache index a2f899eeea..acac422fd6 100644 --- a/model.mustache +++ b/model.mustache @@ -38,7 +38,7 @@ class {{classname}}(object): """ openapi_types = { {{#vars}} - '{{name}}': '{{{datatype}}}'{{#hasMore}},{{/hasMore}} + '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} {{/vars}} } @@ -83,7 +83,7 @@ class {{classname}}(object): {{/description}} :return: The {{name}} of this {{classname}}. # noqa: E501 - :rtype: {{datatype}} + :rtype: {{dataType}} """ return self._{{name}} @@ -96,7 +96,7 @@ class {{classname}}(object): {{/description}} :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type: {{datatype}} + :type: {{dataType}} """ {{#required}} if {{name}} is None: diff --git a/model_doc.mustache b/model_doc.mustache index 569550df37..0216a3372c 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} {{/vars}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) From 719ab23beabdee87de680d525d286af678c0dc16 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Thu, 24 May 2018 17:10:07 +0200 Subject: [PATCH 012/185] [python] asyncio supports _preload_content; remove unsed imports (#107) * chore: update python samples * feat: python/asyncio support for _preload_content * feat: remove unused imports from python clients; fix discriminator --- asyncio/rest.mustache | 16 +++++++++++----- model.mustache | 6 +----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 39003abfbf..8c9d49dc14 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -10,6 +10,7 @@ import ssl import aiohttp import certifi +import asyncio # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode @@ -70,6 +71,9 @@ class RESTClientObject(object): connector=connector ) + def __del__(self): + asyncio.ensure_future(self.pool_manager.close()) + async def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): @@ -152,15 +156,17 @@ class RESTClientObject(object): declared content type.""" raise ApiException(status=0, reason=msg) - async with self.pool_manager.request(**args) as r: + r = await self.pool_manager.request(**args) + if _preload_content: + data = await r.text() r = RESTResponse(r, data) - # log response body - logger.debug("response body: %s", r.data) + # log response body + logger.debug("response body: %s", r.data) - if not 200 <= r.status <= 299: - raise ApiException(http_resp=r) + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) return r diff --git a/model.mustache b/model.mustache index acac422fd6..123577adb8 100644 --- a/model.mustache +++ b/model.mustache @@ -6,10 +6,6 @@ import pprint import re # noqa: F401 import six -{{#imports}}{{#-first}} -{{/-first}} -{{import}} # noqa: F401,E501 -{{/imports}} {{#models}} @@ -170,7 +166,7 @@ class {{classname}}(object): {{#discriminator}} def get_real_child_model(self, data): """Returns the real base class specified by the discriminator""" - discriminator_value = data[self.discriminator].lower() + discriminator_value = data[self.discriminator] return self.discriminator_value_class_map.get(discriminator_value) {{/discriminator}} From d4895f437a3b8287293d545f9350507959b0d9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 16 Jun 2018 19:49:01 +0300 Subject: [PATCH 013/185] Grammar and spelling fixes (#329) --- api_client.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index b044229828..61807efaec 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -552,7 +552,7 @@ class ApiClient(object): return data def __deserialize_object(self, value): - """Return a original value. + """Return an original value. :return: object. """ From 87a87314b0d4dd92368482ac158ea2b6d9f275de Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 10 Jul 2018 22:12:09 +0800 Subject: [PATCH 014/185] Improve logging in Python client (#480) * improve logging in python client * update samples --- configuration.mustache | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 398c1d3dab..8077c1ccf0 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -125,17 +125,6 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): self.logger_file_handler.setFormatter(self.logger_formatter) for _, logger in six.iteritems(self.logger): logger.addHandler(self.logger_file_handler) - if self.logger_stream_handler: - logger.removeHandler(self.logger_stream_handler) - else: - # If not set logging file, - # then add stream handler and remove file handler. - self.logger_stream_handler = logging.StreamHandler() - self.logger_stream_handler.setFormatter(self.logger_formatter) - for _, logger in six.iteritems(self.logger): - logger.addHandler(self.logger_stream_handler) - if self.logger_file_handler: - logger.removeHandler(self.logger_file_handler) @property def debug(self): From 0480fa141923aa576a48783978825df857aac7eb Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Thu, 12 Jul 2018 15:30:57 +0200 Subject: [PATCH 015/185] feat: use local_var_params to avoid collision with api parameters (#521) --- api.mustache | 63 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/api.mustache b/api.mustache index 60ec9ff0a4..5d937ec32a 100644 --- a/api.mustache +++ b/api.mustache @@ -82,26 +82,27 @@ class {{classname}}(object): returns the request thread. """ + local_var_params = locals() + all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') - params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method {{operationId}}" % key ) - params[key] = val - del params['kwargs'] + local_var_params[key] = val + del local_var_params['kwargs'] {{#allParams}} {{#required}} # verify the required parameter '{{paramName}}' is set - if ('{{paramName}}' not in params or - params['{{paramName}}'] is None): + if ('{{paramName}}' not in local_var_params or + local_var_params['{{paramName}}'] is None): raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 {{/required}} {{/allParams}} @@ -109,35 +110,35 @@ class {{classname}}(object): {{#allParams}} {{#hasValidation}} {{#maxLength}} - if ('{{paramName}}' in params and - len(params['{{paramName}}']) > {{maxLength}}): + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) > {{maxLength}}): raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 {{/maxLength}} {{#minLength}} - if ('{{paramName}}' in params and - len(params['{{paramName}}']) < {{minLength}}): + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) < {{minLength}}): raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 {{/minLength}} {{#maximum}} - if '{{paramName}}' in params and params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 {{/maximum}} {{#minimum}} - if '{{paramName}}' in params and params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if '{{paramName}}' in params and not re.search('{{{vendorExtensions.x-regex}}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + if '{{paramName}}' in local_var_params and not re.search('{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} - if ('{{paramName}}' in params and - len(params['{{paramName}}']) > {{maxItems}}): + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) > {{maxItems}}): raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 {{/maxItems}} {{#minItems}} - if ('{{paramName}}' in params and - len(params['{{paramName}}']) < {{minItems}}): + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) < {{minItems}}): raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 {{/minItems}} {{/hasValidation}} @@ -148,37 +149,37 @@ class {{classname}}(object): path_params = {} {{#pathParams}} - if '{{paramName}}' in params: - path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + if '{{paramName}}' in local_var_params: + path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/pathParams}} query_params = [] {{#queryParams}} - if '{{paramName}}' in params: - query_params.append(('{{baseName}}', params['{{paramName}}'])){{#isListContainer}} # noqa: E501 + if '{{paramName}}' in local_var_params: + query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/queryParams}} header_params = {} {{#headerParams}} - if '{{paramName}}' in params: - header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}} # noqa: E501 + if '{{paramName}}' in local_var_params: + header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/headerParams}} form_params = [] local_var_files = {} {{#formParams}} - if '{{paramName}}' in params: - {{^isFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + if '{{paramName}}' in local_var_params: + {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/formParams}} body_params = None {{#bodyParam}} - if '{{paramName}}' in params: - body_params = params['{{paramName}}'] + if '{{paramName}}' in local_var_params: + body_params = local_var_params['{{paramName}}'] {{/bodyParam}} {{#hasProduces}} # HTTP header `Accept` @@ -205,10 +206,10 @@ class {{classname}}(object): files=local_var_files, response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 auth_settings=auth_settings, - async=params.get('async'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), + async=local_var_params.get('async'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats) {{/operation}} {{/operations}} From 00acbc9df8b8a390b2ab889a8ddebd8a41a3c246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Mon, 16 Jul 2018 09:49:08 +0200 Subject: [PATCH 016/185] [Python][Client] pure library client package (#470) * Python client pure library package * check onlyPackage CLI option * run /bin/python-petstore.sh, update the python samples for CI * onlyPackage local variable instead of classp property * fix CI: __future__ absolute_import must be first in file * update samples * generateSourceCodeOnly * updated samples --- README.mustache | 76 +------------------------------------ README_onlypackage.mustache | 44 +++++++++++++++++++++ __init__package.mustache | 2 + common_README.mustache | 75 ++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 75 deletions(-) create mode 100644 README_onlypackage.mustache create mode 100644 common_README.mustache diff --git a/README.mustache b/README.mustache index cf92dc583d..be83533906 100644 --- a/README.mustache +++ b/README.mustache @@ -52,78 +52,4 @@ import {{{packageName}}} Please follow the [installation procedure](#installation--usage) and then run the following: -```python -from __future__ import print_function -import time -import {{{packageName}}} -from {{{packageName}}}.rest import ApiException -from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} -# Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.username = 'YOUR_USERNAME' -configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} -# Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} -# Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} -{{/hasAuthMethods}} - -# create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} - -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} -``` - -## Documentation for API Endpoints - -All URIs are relative to *{{basePath}}* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - -## Documentation For Models - -{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) -{{/model}}{{/models}} - -## Documentation For Authorization - -{{^authMethods}} All endpoints do not require authorization. -{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} -{{#authMethods}}## {{{name}}} - -{{#isApiKey}}- **Type**: API key -- **API key parameter name**: {{{keyParamName}}} -- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} -{{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication -{{/isBasic}} -{{#isOAuth}}- **Type**: OAuth -- **Flow**: {{{flow}}} -- **Authorization URL**: {{{authorizationUrl}}} -- **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - **{{{scope}}}**: {{{description}}} -{{/scopes}} -{{/isOAuth}} - -{{/authMethods}} - -## Author - -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} +{{> common_README }} diff --git a/README_onlypackage.mustache b/README_onlypackage.mustache new file mode 100644 index 0000000000..826454b1ea --- /dev/null +++ b/README_onlypackage.mustache @@ -0,0 +1,44 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage + +This python library package is generated without supporting files like setup.py or requirements files + +To be able to use it, you will need these dependencies in your own package that uses this library: + +* urllib3 >= 1.15 +* six >= 1.10 +* certifi +* python-dateutil +{{#asyncio}} +* aiohttp +{{/asyncio}} +{{#tornado}} +* tornado>=4.2,<5 +{{/tornado}} + +## Getting Started + +In your own code, to use this library to connect and interact with {{{projectName}}}, +you can run the following: + +{{> common_README }} diff --git a/__init__package.mustache b/__init__package.mustache index cd42506f54..a21c6dbac9 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -6,6 +6,8 @@ from __future__ import absolute_import +__version__ = "{{packageVersion}}" + # import apis into sdk package {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} {{/apis}}{{/apiInfo}} diff --git a/common_README.mustache b/common_README.mustache new file mode 100644 index 0000000000..f203456f20 --- /dev/null +++ b/common_README.mustache @@ -0,0 +1,75 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} From 80f5fa7b6babcde2102b74c6189f03d440da562d Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Fri, 20 Jul 2018 16:14:18 +0200 Subject: [PATCH 017/185] Support for python 3.7 by renaming `async` to `async_req` (#519) * feat: support for python 3.7 * fix: regenerate other sample clients --- api.mustache | 22 +++++++++++----------- api_client.mustache | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api.mustache b/api.mustache index 5d937ec32a..ff4835b3b1 100644 --- a/api.mustache +++ b/api.mustache @@ -33,16 +33,16 @@ class {{classname}}(object): {{{notes}}} # noqa: E501 {{/notes}} This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True + asynchronous HTTP request, please pass async_req=True {{#sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} {{^sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async bool + :param async_req bool {{#allParams}} :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} {{/allParams}} @@ -51,7 +51,7 @@ class {{classname}}(object): returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async'): + if kwargs.get('async_req'): return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 else: (data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 @@ -64,16 +64,16 @@ class {{classname}}(object): {{{notes}}} # noqa: E501 {{/notes}} This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True + asynchronous HTTP request, please pass async_req=True {{#sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True) + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} {{^sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True) + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async bool + :param async_req bool {{#allParams}} :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} {{/allParams}} @@ -85,7 +85,7 @@ class {{classname}}(object): local_var_params = locals() all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 - all_params.append('async') + all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') @@ -206,7 +206,7 @@ class {{classname}}(object): files=local_var_files, response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 auth_settings=auth_settings, - async=local_var_params.get('async'), + async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), diff --git a/api_client.mustache b/api_client.mustache index 61807efaec..659d267a2d 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -280,12 +280,12 @@ class ApiClient(object): def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async=None, + response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None): """Makes the HTTP request (synchronous) and returns deserialized data. - To make an async request, set the async parameter. + To make an async_req request, set the async_req parameter. :param resource_path: Path to method endpoint. :param method: Method to call. @@ -300,7 +300,7 @@ class ApiClient(object): :param response: Response data type. :param files dict: key -> filename, value -> filepath, for `multipart/form-data`. - :param async bool: execute request asynchronously + :param async_req bool: execute request asynchronously :param _return_http_data_only: response data without head status code and headers :param collection_formats: dict of collection formats for path, query, @@ -313,13 +313,13 @@ class ApiClient(object): timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: - If async parameter is True, + If async_req parameter is True, the request will be called asynchronously. The method will return the request thread. - If parameter async is False or missing, + If parameter async_req is False or missing, then the method will return the response directly. """ - if not async: + if not async_req: return self.__call_api(resource_path, method, path_params, query_params, header_params, body, post_params, files, From 51305f2f25119e5dff3d0e4aca50f2912c5267f4 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Fri, 24 Aug 2018 03:43:32 +0200 Subject: [PATCH 018/185] fix: python-asyncio/aiohttp with disabled ssl verification (#891) --- asyncio/rest.mustache | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 8c9d49dc14..528e550d74 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -38,21 +38,24 @@ class RESTClientObject(object): def __init__(self, configuration, pools_size=4, maxsize=4): # maxsize is number of requests to host that are allowed in parallel - # ca_certs vs cert_file vs key_file - # http://stackoverflow.com/a/23957365/2985775 - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() + if configuration.verify_ssl: - ssl_context = ssl.create_default_context(cafile=ca_certs) - if configuration.cert_file: - ssl_context.load_cert_chain( - configuration.cert_file, keyfile=configuration.key_file - ) + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + ssl_context = ssl.create_default_context(cafile=ca_certs) + + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + else: + ssl_context = None connector = aiohttp.TCPConnector( limit=maxsize, From 9a83d8862fce8ed448cf06b52e5df9293eb09d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Fri, 31 Aug 2018 15:35:37 +0200 Subject: [PATCH 019/185] [PYTHON] Api doc python with multiple authentications (#928) * [PYTHON] better code snippet for API usage with authentication * update python samples --- api_doc.mustache | 43 +++++----------------------------------- api_doc_example.mustache | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 api_doc_example.mustache diff --git a/api_doc.mustache b/api_doc.mustache index 32c26d929d..c16779a5f9 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -18,47 +18,14 @@ Method | HTTP request | Description {{{notes}}}{{/notes}} ### Example -```python -from __future__ import print_function -import time -import {{{packageName}}} -from {{{packageName}}}.rest import ApiException -from pprint import pprint -{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} -# Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.username = 'YOUR_USERNAME' -configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} -# Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} -# Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() -configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} - -# create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +{{#hasAuthMethods}}{{#authMethods}} +{{#isBasic}}* Basic Authentication ({{name}}): {{/isBasic }}{{#isApiKey}}* Api Key Authentication ({{name}}): {{/isApiKey }}{{#isOAuth}}* OAuth Authentication ({{name}}): {{/isOAuth }} +{{> api_doc_example }} +{{/authMethods}} {{/hasAuthMethods}} {{^hasAuthMethods}} - -# create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}() -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +{{> api_doc_example }} {{/hasAuthMethods}} - -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -``` - ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes diff --git a/api_doc_example.mustache b/api_doc_example.mustache new file mode 100644 index 0000000000..42e0f32bf7 --- /dev/null +++ b/api_doc_example.mustache @@ -0,0 +1,40 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration() +configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +``` From af07b4c2be49a151fe22b0918df40072c7a2507b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 29 Sep 2018 17:01:13 +0800 Subject: [PATCH 020/185] Add nullable support to Python client (#1073) * add nullable support to python client * update PR template --- api.mustache | 2 ++ model.mustache | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/api.mustache b/api.mustache index ff4835b3b1..cfdf88cf09 100644 --- a/api.mustache +++ b/api.mustache @@ -99,12 +99,14 @@ class {{classname}}(object): local_var_params[key] = val del local_var_params['kwargs'] {{#allParams}} +{{^isNullable}} {{#required}} # verify the required parameter '{{paramName}}' is set if ('{{paramName}}' not in local_var_params or local_var_params['{{paramName}}'] is None): raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 {{/required}} +{{/isNullable}} {{/allParams}} {{#allParams}} diff --git a/model.mustache b/model.mustache index 123577adb8..2652a3090e 100644 --- a/model.mustache +++ b/model.mustache @@ -64,8 +64,13 @@ class {{classname}}(object): self.{{name}} = {{name}} {{/required}} {{^required}} +{{#isNullable}} + self.{{name}} = {{name}} +{{/isNullable}} +{{^isNullable}} if {{name}} is not None: self.{{name}} = {{name}} +{{/isNullable}} {{/required}} {{/vars}} @@ -94,10 +99,12 @@ class {{classname}}(object): :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 :type: {{dataType}} """ +{{^isNullable}} {{#required}} if {{name}} is None: raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 {{/required}} +{{/isNullable}} {{#isEnum}} {{#isContainer}} allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 From 633170aa28e892fa262e9407e7fec7dbd14d4bb1 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Fri, 12 Oct 2018 11:05:01 +0200 Subject: [PATCH 021/185] fix: python/asyncio no-ssl-verify affects verification of server certs only (#1211) Bug fix: python/asyncio no-ssl-verify affects verification of server certs --- asyncio/rest.mustache | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 528e550d74..9c1a0cc81d 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -39,28 +39,26 @@ class RESTClientObject(object): def __init__(self, configuration, pools_size=4, maxsize=4): # maxsize is number of requests to host that are allowed in parallel - if configuration.verify_ssl: - - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() - ssl_context = ssl.create_default_context(cafile=ca_certs) + ssl_context = ssl.create_default_context(cafile=ca_certs) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) - if configuration.cert_file: - ssl_context.load_cert_chain( - configuration.cert_file, keyfile=configuration.key_file - ) - else: - ssl_context = None + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE connector = aiohttp.TCPConnector( limit=maxsize, - ssl_context=ssl_context, - verify_ssl=configuration.verify_ssl + ssl_context=ssl_context ) # https pool manager From e4d88532bdbaed12f3d2bb6b413f89ad9e8a33c9 Mon Sep 17 00:00:00 2001 From: micw523 Date: Sat, 27 Oct 2018 22:16:54 -0500 Subject: [PATCH 022/185] Fix W605 Warning and reenable flake8 (#1334) --- api.mustache | 6 +++--- api_client.mustache | 4 ++-- model.mustache | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api.mustache b/api.mustache index cfdf88cf09..1109aaebdc 100644 --- a/api.mustache +++ b/api.mustache @@ -27,7 +27,7 @@ class {{classname}}(object): {{#operation}} def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 - """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} {{{notes}}} # noqa: E501 @@ -58,7 +58,7 @@ class {{classname}}(object): return data def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 - """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} {{{notes}}} # noqa: E501 @@ -130,7 +130,7 @@ class {{classname}}(object): raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if '{{paramName}}' in local_var_params and not re.search('{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} diff --git a/api_client.mustache b/api_client.mustache index 659d267a2d..4e630dc34b 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -251,12 +251,12 @@ class ApiClient(object): if type(klass) == str: if klass.startswith('list['): - sub_kls = re.match('list\[(.*)\]', klass).group(1) + sub_kls = re.match(r'list\[(.*)\]', klass).group(1) return [self.__deserialize(sub_data, sub_kls) for sub_data in data] if klass.startswith('dict('): - sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2) + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) return {k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data)} diff --git a/model.mustache b/model.mustache index 2652a3090e..cde5cb3718 100644 --- a/model.mustache +++ b/model.mustache @@ -153,8 +153,8 @@ class {{classname}}(object): raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 + if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} if {{name}} is not None and len({{name}}) > {{maxItems}}: From 3f328472f9bd68b1f7771b8b37c9f834b4dadc42 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 8 Nov 2018 17:39:20 +0800 Subject: [PATCH 023/185] [python] Avoid creating unused ThreadPools (#1387) * Avoid creating unused ThreadPools Instead, create ApiClient.pool on first request for .pool property. avoids spawning n-cpus threads (the default for ThreadPool) at instantiation of every ApiClient * update doc * set pool_thread to None --- api_client.mustache | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 4e630dc34b..b89911d51d 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -40,6 +40,8 @@ class ApiClient(object): the API. :param cookie: a cookie to include in the header when making calls to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. """ PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types @@ -53,14 +55,15 @@ class ApiClient(object): 'datetime': datetime.datetime, 'object': object, } + _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None): + cookie=None, pool_threads=None): if configuration is None: configuration = Configuration() self.configuration = configuration + self.pool_threads = pool_threads - self.pool = ThreadPool() self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} if header_name is not None: @@ -70,8 +73,19 @@ class ApiClient(object): self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' def __del__(self): - self.pool.close() - self.pool.join() + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + self._pool = ThreadPool(self.pool_threads) + return self._pool @property def user_agent(self): From 41140be176471d8cb9b642784901bdc853b38209 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 9 Nov 2018 23:44:47 +0800 Subject: [PATCH 024/185] change python pool_thread default to 1 (#1403) --- api_client.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index b89911d51d..b0976ba9f2 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -58,7 +58,7 @@ class ApiClient(object): _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=None): + cookie=None, pool_threads=1): if configuration is None: configuration = Configuration() self.configuration = configuration From 11e8658fc555ea0abad49503b7fd86ee99d8baed Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Fri, 21 Dec 2018 02:52:27 +0100 Subject: [PATCH 025/185] feat: [python/asyncio] use ssl argument instead of ssl_context (deprecated from aiohttp>=3.0.0) (#1724) --- asyncio/rest.mustache | 2 +- setup.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 9c1a0cc81d..727dfae423 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -58,7 +58,7 @@ class RESTClientObject(object): connector = aiohttp.TCPConnector( limit=maxsize, - ssl_context=ssl_context + ssl=ssl_context ) # https pool manager diff --git a/setup.mustache b/setup.mustache index 15d2450471..201b79e217 100644 --- a/setup.mustache +++ b/setup.mustache @@ -18,7 +18,7 @@ VERSION = "{{packageVersion}}" REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] {{#asyncio}} -REQUIRES.append("aiohttp") +REQUIRES.append("aiohttp >= 3.0.0") {{/asyncio}} {{#tornado}} REQUIRES.append("tornado>=4.2,<5") From 24ef7989fec06f1d09c1c914c0b7ac629b2f6a2b Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 8 Jan 2019 19:18:35 -0800 Subject: [PATCH 026/185] [python-client] Add model default values (#1776) * Adds two models to the v2.0 spec, uses examples as defaults in python client * Adds array default and type_holder_default and type_holder_example tests * Re-generated python security client with ./bin/security/python-petstore.sh * Changes comment text, rebased master * Updates client + server samples * Adds missing samples updates * Changes python client to look for true or false with booleans in toDefaultValue * Changes boolean casting to use Boolean.valueOf * Adds deserialization fix for python tests * Changes Mock to namedtuple in python deserialization tests * Actually remove unittest.mock --- model.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model.mustache b/model.mustache index cde5cb3718..c3ab5cb020 100644 --- a/model.mustache +++ b/model.mustache @@ -173,7 +173,8 @@ class {{classname}}(object): {{#discriminator}} def get_real_child_model(self, data): """Returns the real base class specified by the discriminator""" - discriminator_value = data[self.discriminator] + discriminator_key = self.attribute_map[self.discriminator] + discriminator_value = data[discriminator_key] return self.discriminator_value_class_map.get(discriminator_value) {{/discriminator}} From 34bb18001a84bc33306d566adeb1ba2d933edb75 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Fri, 11 Jan 2019 05:15:03 -0600 Subject: [PATCH 027/185] Python: Update api_doc_example for multiple auth (#1870) APIs may more than one auth method (for example both an app key and basic auth). This changes the example to only initialize the config option once instead of once per auth method. --- api_doc_example.mustache | 6 ++---- common_README.mustache | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/api_doc_example.mustache b/api_doc_example.mustache index 42e0f32bf7..282bacf69c 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -4,18 +4,16 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint -{{#hasAuthMethods}}{{#isBasic}} +{{#hasAuthMethods}} +configuration = {{{packageName}}}.Configuration(){{#isBasic}} # Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.username = 'YOUR_USERNAME' configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} # Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}} # create an instance of the API class diff --git a/common_README.mustache b/common_README.mustache index f203456f20..194fb14b59 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -4,18 +4,16 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}} +configuration = {{{packageName}}}.Configuration(){{#isBasic}} # Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.username = 'YOUR_USERNAME' configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} # Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} From f7d300cd94f92e59c3c1291fb6d8d8f452f9eee9 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sat, 26 Jan 2019 01:26:38 -0800 Subject: [PATCH 028/185] [Spec] adds XmlItem model and route for xml testing (#1883) * Adds xmlitem model and route, rest-assured Api suffix fix, updates pytest and pytest-cov versions * Adds python client sample files * Adds samples update * Adds rest-assured sample client update * Adds sample updates in ensure-up-to-date * Changes rest-assured files back to master version, removes fix for issue #13 * Updates samples --- test-requirements.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-requirements.mustache b/test-requirements.mustache index 31f8d94d99..d9e3f20b53 100644 --- a/test-requirements.mustache +++ b/test-requirements.mustache @@ -3,8 +3,8 @@ coverage>=4.0.3 nose>=1.3.7 {{/asyncio}} {{#asyncio}} -pytest>=3.3.1 -pytest-cov>=2.5.1 +pytest>=3.6.0 +pytest-cov>=2.6.1 {{/asyncio}} pluggy>=0.3.1 py>=1.4.31 From fc3247e0066dcf30e3807b0641251d99f0babdda Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jan 2019 11:24:48 +0800 Subject: [PATCH 029/185] Add multiple servers support to Python client (#1969) * add multiple server support to python client * various fixes * minor fixes, add tests * test oas2 python first * fix tests * fix issues reported by flake8 * update code format * add python petstore to ensure up-to-date * rearrange test * fix E501 * fix tests * add new files * fix script permission * fix index check * update samples --- configuration.mustache | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index 8077c1ccf0..562c036e9f 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -247,3 +247,77 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): "Version of the API: {{version}}\n"\ "SDK Package Version: {{packageVersion}}".\ format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + {{#servers}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }{{^-last}},{{/-last}} + {{/servers}} + ] + + def get_host_from_settings(self, index, variables={}): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :return: URL based on host settings + """ + + servers = self.get_host_settings() + + # check array index out of bound + if index < 0 or index >= len(servers): + raise ValueError( + "Invalid index {} when selecting the host settings. Must be less than {}" # noqa: E501 + .format(index, len(servers))) + + server = servers[index] + url = server['url'] + + # go through variable and assign a value + for variable_name in server['variables']: + if variable_name in variables: + if variables[variable_name] in server['variables'][ + variable_name]['enum_values']: + url = url.replace("{" + variable_name + "}", + variables[variable_name]) + else: + raise ValueError( + "The variable `{}` in the host URL has invalid value {}. Must be {}." # noqa: E501 + .format( + variable_name, variables[variable_name], + server['variables'][variable_name]['enum_values'])) + else: + # use default value + url = url.replace( + "{" + variable_name + "}", + server['variables'][variable_name]['default_value']) + + return url From 8c057335e07ec056ff105fa5a07972487b4435e9 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 30 Jan 2019 22:16:53 +0800 Subject: [PATCH 030/185] Add Bearer authentication support to Python client (#1999) * add bearer auth support to python * add bearer auth support to python * update python oas2 petstore samples * update samples * add bearer format * update php symfony samle --- api_doc.mustache | 19 ++++++++++++++-- api_doc_example.mustache | 13 +---------- common_README.mustache | 38 ++++++++++++++++---------------- configuration.mustache | 32 ++++++++++++++++++++++----- python_doc_auth_partial.mustache | 26 ++++++++++++++++++++++ 5 files changed, 90 insertions(+), 38 deletions(-) create mode 100644 python_doc_auth_partial.mustache diff --git a/api_doc.mustache b/api_doc.mustache index c16779a5f9..210ac86d2e 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -18,8 +18,23 @@ Method | HTTP request | Description {{{notes}}}{{/notes}} ### Example -{{#hasAuthMethods}}{{#authMethods}} -{{#isBasic}}* Basic Authentication ({{name}}): {{/isBasic }}{{#isApiKey}}* Api Key Authentication ({{name}}): {{/isApiKey }}{{#isOAuth}}* OAuth Authentication ({{name}}): {{/isOAuth }} + +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +{{^isBasicBearer}} +* Basic Authentication ({{name}}): +{{/isBasicBearer}} +{{#isBasicBearer}} +* Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} +* Api Key Authentication ({{name}}): +{{/isApiKey }} +{{#isOAuth}} +* OAuth Authentication ({{name}}): +{{/isOAuth }} {{> api_doc_example }} {{/authMethods}} {{/hasAuthMethods}} diff --git a/api_doc_example.mustache b/api_doc_example.mustache index 282bacf69c..c8f0d8b554 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -4,25 +4,14 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint +{{> python_doc_auth_partial}} {{#hasAuthMethods}} -configuration = {{{packageName}}}.Configuration(){{#isBasic}} -# Configure HTTP basic authorization: {{{name}}} -configuration.username = 'YOUR_USERNAME' -configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} -# Configure API key authorization: {{{name}}} -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} -# Configure OAuth2 access token for authorization: {{{name}}} -configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}} - # create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} - # create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}() {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} diff --git a/common_README.mustache b/common_README.mustache index 194fb14b59..d8e9f94c58 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -4,19 +4,8 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}} -configuration = {{{packageName}}}.Configuration(){{#isBasic}} -# Configure HTTP basic authorization: {{{name}}} -configuration.username = 'YOUR_USERNAME' -configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} -# Configure API key authorization: {{{name}}} -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} -# Configure OAuth2 access token for authorization: {{{name}}} -configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} -{{/hasAuthMethods}} - +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{> python_doc_auth_partial}} # create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} @@ -47,17 +36,28 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -{{^authMethods}} All endpoints do not require authorization. -{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} -{{#authMethods}}## {{{name}}} +{{^authMethods}} + All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +## {{{name}}} -{{#isApiKey}}- **Type**: API key +{{#isApiKey}} +- **Type**: API key - **API key parameter name**: {{{keyParamName}}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication +{{#isBasic}} +{{^isBasicBearer}} +- **Type**: HTTP basic authentication +{{/isBasicBearer}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} {{/isBasic}} -{{#isOAuth}}- **Type**: OAuth +{{#isOAuth}} +- **Type**: OAuth - **Flow**: {{{flow}}} - **Authorization URL**: {{{authorizationUrl}}} - **Scopes**: {{^scopes}}N/A{{/scopes}} diff --git a/configuration.mustache b/configuration.mustache index 562c036e9f..2aaf9851d7 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -51,10 +51,16 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): self.username = "" # Password for HTTP basic authentication self.password = "" -{{#authMethods}}{{#isOAuth}} - # access token for OAuth +{{#hasOAuthMethods}} + # access token for OAuth/Bearer self.access_token = "" -{{/isOAuth}}{{/authMethods}} +{{/hasOAuthMethods}} +{{^hasOAuthMethods}} +{{#hasBearerMethods}} + # access token for OAuth/Bearer + self.access_token = "" +{{/hasBearerMethods}} +{{/hasOAuthMethods}} # Logging Settings self.logger = {} self.logger["package_logger"] = logging.getLogger("{{packageName}}") @@ -218,6 +224,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): }, {{/isApiKey}} {{#isBasic}} + {{^isBasicBearer}} '{{name}}': { 'type': 'basic', @@ -225,7 +232,21 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): 'key': 'Authorization', 'value': self.get_basic_auth_token() }, -{{/isBasic}}{{#isOAuth}} + {{/isBasicBearer}} + {{#isBasicBearer}} + '{{name}}': + { + 'type': 'bearer', + 'in': 'header', + {{#bearerFormat}} + 'format': '{{{.}}}', + {{/bearerFormat}} + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + }, + {{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} '{{name}}': { 'type': 'oauth2', @@ -233,7 +254,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): 'key': 'Authorization', 'value': 'Bearer ' + self.access_token }, -{{/isOAuth}}{{/authMethods}} +{{/isOAuth}} +{{/authMethods}} } def to_debug_report(self): diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache new file mode 100644 index 0000000000..899e4b58b9 --- /dev/null +++ b/python_doc_auth_partial.mustache @@ -0,0 +1,26 @@ +{{#hasAuthMethods}} +{{#authMethods}} +configuration = {{{packageName}}}.Configuration() +{{#isBasic}} +{{^isBasicBearer}} +# Configure HTTP basic authorization: {{{name}}} +configuration.username = 'YOUR_USERNAME' +configuration.password = 'YOUR_PASSWORD' +{{/isBasicBearer}} +{{#isBasicBearer}} +# Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} +configuration.access_token = 'YOUR_BEARER_TOKEN' +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} +# Configure API key authorization: {{{name}}} +configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer' +{{/isApiKey}} +{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +configuration.access_token = 'YOUR_ACCESS_TOKEN' +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} From 3650fb973c0153e3aca3f96546b63c0577e22bd8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 8 Feb 2019 11:48:37 +0800 Subject: [PATCH 031/185] [Python] Add "servers" support in path, operation (#2052) * add servers to path, operation * add path/operation server support to python client * update python samples * fix index * fix python code style --- api.mustache | 13 ++++++++++++- api_client.mustache | 16 +++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/api.mustache b/api.mustache index 1109aaebdc..5e8027e839 100644 --- a/api.mustache +++ b/api.mustache @@ -82,6 +82,14 @@ class {{classname}}(object): returns the request thread. """ + {{#servers.0}} + local_var_hosts = [{{#servers}}'{{{url}}}'{{^-last}}, {{/-last}}{{/servers}}] # noqa: E501 + local_var_host = local_var_hosts[0] + if kwargs.get('_host_index'): + if int(kwags.get('_host_index')) < 0 or int(kawgs.get('_host_index')) >= len(local_var_hosts): + raise ValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) + local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] + {{/servers.0}} local_var_params = locals() all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 @@ -91,7 +99,7 @@ class {{classname}}(object): all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: raise TypeError( "Got an unexpected keyword argument '%s'" " to method {{operationId}}" % key @@ -212,6 +220,9 @@ class {{classname}}(object): _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), + {{#servers.0}} + _host=local_var_host, + {{/servers.0}} collection_formats=collection_formats) {{/operation}} {{/operations}} diff --git a/api_client.mustache b/api_client.mustache index b0976ba9f2..5325a63cfa 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -107,7 +107,7 @@ class ApiClient(object): query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + _preload_content=True, _request_timeout=None, _host=None): config = self.configuration @@ -154,7 +154,11 @@ class ApiClient(object): body = self.sanitize_for_serialization(body) # request url - url = self.configuration.host + resource_path + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path # perform request and return response response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( @@ -296,7 +300,7 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + _preload_content=True, _request_timeout=None, _host=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -339,7 +343,7 @@ class ApiClient(object): body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout) + _preload_content, _request_timeout, _host) else: thread = self.pool.apply_async(self.__call_api, (resource_path, method, path_params, query_params, @@ -348,7 +352,9 @@ class ApiClient(object): response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout)) + _preload_content, + _request_timeout, + _host)) return thread def request(self, method, url, query_params=None, headers=None, From 7937a0fff5eb6a09fb0ec53a316d8daa72518dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sat, 9 Feb 2019 15:08:47 +0100 Subject: [PATCH 032/185] [Python] handle nullable parameters with None added to allowed_values (#2034) * handle nullable parameters with None added to allowed_values * update samples * spec for testing enum with null/nullable --- model.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.mustache b/model.mustache index c3ab5cb020..16c8dadbf6 100644 --- a/model.mustache +++ b/model.mustache @@ -107,7 +107,7 @@ class {{classname}}(object): {{/isNullable}} {{#isEnum}} {{#isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 {{#isListContainer}} if not set({{{name}}}).issubset(set(allowed_values)): raise ValueError( @@ -126,7 +126,7 @@ class {{classname}}(object): {{/isMapContainer}} {{/isContainer}} {{^isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 if {{{name}}} not in allowed_values: raise ValueError( "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 From a47a1e640c2cc765091d7aa4be15215730ec6b11 Mon Sep 17 00:00:00 2001 From: Tom Ghyselinck Date: Thu, 14 Mar 2019 09:33:35 +0100 Subject: [PATCH 033/185] Python apikey cookie (#2367) * The `ApiClient` will now have support to store and use HTTP Cookies (as APIKey auth). * Use Cookie authentication for user management. * - Updated Python related samples. --- api_client.mustache | 2 ++ configuration.mustache | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index 5325a63cfa..84f6716131 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -523,6 +523,8 @@ class ApiClient(object): if auth_setting: if not auth_setting['value']: continue + elif auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': diff --git a/configuration.mustache b/configuration.mustache index 2aaf9851d7..25eb5dd054 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -218,7 +218,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): '{{name}}': { 'type': 'api_key', - 'in': {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, 'key': '{{keyParamName}}', 'value': self.get_api_key_with_prefix('{{keyParamName}}') }, From 118afc75d7173deb795ab3e59e4a05f2de48aef1 Mon Sep 17 00:00:00 2001 From: Gaurav Yadav Date: Fri, 22 Mar 2019 05:54:23 +0530 Subject: [PATCH 034/185] Adding retries option to override default value 3 of urllib3 (#2460) * adding retries option to override default value 3 of urllib3 * running petstore for python * adding files for samples in petstore run * running ensure-up-to-date --- configuration.mustache | 2 ++ rest.mustache | 3 +++ 2 files changed, 5 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index 25eb5dd054..b6219f987c 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -100,6 +100,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): self.proxy = None # Safe chars for path_param self.safe_chars_for_path_param = '' + # Adding retries to override urllib3 default value 3 + self.retries = None @property def logger_file(self): diff --git a/rest.mustache b/rest.mustache index 8418ec2a0f..d1580e1c22 100644 --- a/rest.mustache +++ b/rest.mustache @@ -67,6 +67,9 @@ class RESTClientObject(object): if configuration.assert_hostname is not None: addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + if maxsize is None: if configuration.connection_pool_maxsize is not None: maxsize = configuration.connection_pool_maxsize From 780e7901240a17e640c7d9cdb2b38a5294fcaebf Mon Sep 17 00:00:00 2001 From: Justin Black Date: Thu, 21 Mar 2019 19:40:32 -0700 Subject: [PATCH 035/185] Adds exceptions module to python clients (#2393) * Adds python client exceptions module and updates samples * Adds python style updates, detects integers in exception paths with six * Updates to ruby samples which circleci needs * Removes petstore-security-tests samples * readme char removal (triggers ci tests) * Readme fix, triggers CI tests * Updates python client sample --- __init__package.mustache | 7 ++- api.mustache | 24 +++++---- api_client.mustache | 5 +- asyncio/rest.mustache | 31 ++--------- exceptions.mustache | 112 +++++++++++++++++++++++++++++++++++++++ rest.mustache | 36 ++----------- tornado/rest.mustache | 32 ++--------- 7 files changed, 144 insertions(+), 103 deletions(-) create mode 100644 exceptions.mustache diff --git a/__init__package.mustache b/__init__package.mustache index a21c6dbac9..72376acdc3 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -14,6 +14,11 @@ __version__ = "{{packageVersion}}" # import ApiClient from {{packageName}}.api_client import ApiClient from {{packageName}}.configuration import Configuration +from {{packageName}}.exceptions import OpenApiException +from {{packageName}}.exceptions import ApiTypeError +from {{packageName}}.exceptions import ApiValueError +from {{packageName}}.exceptions import ApiKeyError +from {{packageName}}.exceptions import ApiException # import models into sdk package {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} -{{/model}}{{/models}} \ No newline at end of file +{{/model}}{{/models}} diff --git a/api.mustache b/api.mustache index 5e8027e839..e1f9f53dca 100644 --- a/api.mustache +++ b/api.mustache @@ -10,6 +10,10 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient +from {{packageName}}.exceptions import ( + ApiTypeError, + ApiValueError +) {{#operations}} @@ -87,7 +91,7 @@ class {{classname}}(object): local_var_host = local_var_hosts[0] if kwargs.get('_host_index'): if int(kwags.get('_host_index')) < 0 or int(kawgs.get('_host_index')) >= len(local_var_hosts): - raise ValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) + raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] {{/servers.0}} local_var_params = locals() @@ -100,7 +104,7 @@ class {{classname}}(object): for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: - raise TypeError( + raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method {{operationId}}" % key ) @@ -112,7 +116,7 @@ class {{classname}}(object): # verify the required parameter '{{paramName}}' is set if ('{{paramName}}' not in local_var_params or local_var_params['{{paramName}}'] is None): - raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 + raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 {{/required}} {{/isNullable}} {{/allParams}} @@ -122,34 +126,34 @@ class {{classname}}(object): {{#maxLength}} if ('{{paramName}}' in local_var_params and len(local_var_params['{{paramName}}']) > {{maxLength}}): - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 {{/maxLength}} {{#minLength}} if ('{{paramName}}' in local_var_params and len(local_var_params['{{paramName}}']) < {{minLength}}): - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 {{/minLength}} {{#maximum}} if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 {{/maximum}} {{#minimum}} if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} if ('{{paramName}}' in local_var_params and len(local_var_params['{{paramName}}']) > {{maxItems}}): - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 {{/maxItems}} {{#minItems}} if ('{{paramName}}' in local_var_params and len(local_var_params['{{paramName}}']) < {{minItems}}): - raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 {{/minItems}} {{/hasValidation}} {{#-last}} diff --git a/api_client.mustache b/api_client.mustache index 84f6716131..34021481bf 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -20,6 +20,7 @@ import tornado.gen from {{packageName}}.configuration import Configuration import {{modelPackage}} from {{packageName}} import rest +from {{packageName}}.exceptions import ApiValueError class ApiClient(object): @@ -413,7 +414,7 @@ class ApiClient(object): _request_timeout=_request_timeout, body=body) else: - raise ValueError( + raise ApiValueError( "http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`." ) @@ -530,7 +531,7 @@ class ApiClient(object): elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: - raise ValueError( + raise ApiValueError( 'Authentication token must be in `query` or `header`' ) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 727dfae423..36b061f8f4 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -14,6 +14,8 @@ import asyncio # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode +from {{packageName}}.exceptions import ApiException, ApiValueError + logger = logging.getLogger(__name__) @@ -100,7 +102,7 @@ class RESTClientObject(object): 'PATCH', 'OPTIONS'] if post_params and body: - raise ValueError( + raise ApiValueError( "body parameter cannot be used with post_params parameter." ) @@ -238,30 +240,3 @@ class RESTClientObject(object): _preload_content=_preload_content, _request_timeout=_request_timeout, body=body)) - - -class ApiException(Exception): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message diff --git a/exceptions.mustache b/exceptions.mustache new file mode 100644 index 0000000000..dd012f34a0 --- /dev/null +++ b/exceptions.mustache @@ -0,0 +1,112 @@ +# coding: utf-8 + +{{>partial_header}} + +import six + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, six.integer_types): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/rest.mustache b/rest.mustache index d1580e1c22..0ce998c5f9 100644 --- a/rest.mustache +++ b/rest.mustache @@ -14,11 +14,9 @@ import certifi # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode +import urllib3 -try: - import urllib3 -except ImportError: - raise ImportError('OpenAPI Python client requires urllib3.') +from {{packageName}}.exceptions import ApiException, ApiValueError logger = logging.getLogger(__name__) @@ -125,7 +123,7 @@ class RESTClientObject(object): 'PATCH', 'OPTIONS'] if post_params and body: - raise ValueError( + raise ApiValueError( "body parameter cannot be used with post_params parameter." ) @@ -287,31 +285,3 @@ class RESTClientObject(object): _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) - - -class ApiException(Exception): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message diff --git a/tornado/rest.mustache b/tornado/rest.mustache index bc74fbc295..e7a760f370 100644 --- a/tornado/rest.mustache +++ b/tornado/rest.mustache @@ -15,6 +15,8 @@ import tornado.gen from tornado import httpclient from urllib3.filepost import encode_multipart_formdata +from {{packageName}}.exceptions import ApiException, ApiValueError + logger = logging.getLogger(__name__) @@ -87,7 +89,7 @@ class RESTClientObject(object): 'PATCH', 'OPTIONS'] if post_params and body: - raise ValueError( + raise ApiValueError( "body parameter cannot be used with post_params parameter." ) @@ -225,31 +227,3 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) raise tornado.gen.Return(result) - - -class ApiException(Exception): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\nReason: {1}\n".format( - self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message From 35a841e7b89d554cc1e736af61c9fd0beff7f191 Mon Sep 17 00:00:00 2001 From: Gaurav Yadav Date: Fri, 22 Mar 2019 08:52:10 +0530 Subject: [PATCH 036/185] Added proxy headers option for urllib3 (#2467) * adding headers option to pass in rest client * running ensure uptodate --- configuration.mustache | 2 ++ rest.mustache | 1 + 2 files changed, 3 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index b6219f987c..a1a7e9babf 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -98,6 +98,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): # Proxy URL self.proxy = None + # Proxy headers + self.proxy_headers = None # Safe chars for path_param self.safe_chars_for_path_param = '' # Adding retries to override urllib3 default value 3 diff --git a/rest.mustache b/rest.mustache index 0ce998c5f9..98f2c502a9 100644 --- a/rest.mustache +++ b/rest.mustache @@ -84,6 +84,7 @@ class RESTClientObject(object): cert_file=configuration.cert_file, key_file=configuration.key_file, proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, **addition_pool_args ) else: From 2841f1207a148ed2511954f8582a10080aa1aab6 Mon Sep 17 00:00:00 2001 From: Sebastien Arod Date: Fri, 26 Apr 2019 19:45:34 +0200 Subject: [PATCH 037/185] [Bug][Python]Support body as bytes when Content-Type is unknown (#2626) * Support body as bytes when Content-Type is unknownfix #2623 * Revert unwanted import changes * update samples/openapi3 --- rest.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest.mustache b/rest.mustache index 98f2c502a9..772efe91b3 100644 --- a/rest.mustache +++ b/rest.mustache @@ -181,7 +181,7 @@ class RESTClientObject(object): # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form - elif isinstance(body, str): + elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( method, url, From 70479dcb83a608ac11a27bceb5967857a9f3671e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Tue, 7 May 2019 15:27:01 +0200 Subject: [PATCH 038/185] python: api_client: add the multipart files after sanitization (#2122) * python: api_client: add the multipart files after sanitization * simplify prepare_post_parameters * fix case of both post params and files set * update samples * update samples --- api_client.mustache | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 34021481bf..768b8d973f 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -142,10 +142,11 @@ class ApiClient(object): # post parameters if post_params or files: - post_params = self.prepare_post_parameters(post_params, files) + post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) post_params = self.parameters_to_tuples(post_params, collection_formats) + post_params.extend(self.files_parameters(files)) # auth setting self.update_params_for_auth(header_params, query_params, auth_settings) @@ -449,18 +450,14 @@ class ApiClient(object): new_params.append((k, v)) return new_params - def prepare_post_parameters(self, post_params=None, files=None): + def files_parameters(self, files=None): """Builds form parameters. - :param post_params: Normal form parameters. :param files: File parameters. :return: Form parameters with files. """ params = [] - if post_params: - params = post_params - if files: for k, v in six.iteritems(files): if not v: From 6cf06582d33ab5c3de25a2d78cf3e82ca4dba5a9 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 13 May 2019 15:59:59 +0800 Subject: [PATCH 039/185] Minor wording change (#2875) * better wording for version of openapi doc * update petstore samples --- partial_header.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partial_header.mustache b/partial_header.mustache index b83479cdbb..c52fbceb13 100644 --- a/partial_header.mustache +++ b/partial_header.mustache @@ -8,7 +8,7 @@ {{/appDescription}} {{#version}} - OpenAPI spec version: {{{version}}} + The version of the OpenAPI document: {{{version}}} {{/version}} {{#infoEmail}} Contact: {{{infoEmail}}} From 3636d86966089522db75bf6eaf20d976fdf95837 Mon Sep 17 00:00:00 2001 From: Shenghan Gao Date: Fri, 24 May 2019 09:10:11 -0700 Subject: [PATCH 040/185] [Python] Remove unnecessary if else. (#2985) * Remove Unnecessary `if else` * update samples --- api.mustache | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/api.mustache b/api.mustache index e1f9f53dca..4e0612d87d 100644 --- a/api.mustache +++ b/api.mustache @@ -55,11 +55,7 @@ class {{classname}}(object): returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 - else: - (data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 - return data + return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 From c4e8a40ee08b99bd9825717928312bd1f3c029a5 Mon Sep 17 00:00:00 2001 From: Sai Giridhar P Date: Wed, 29 May 2019 17:08:42 +0530 Subject: [PATCH 041/185] [Python] ModuleNotFoundError when packagename contains dots (#2992) * feat(python): Support package names with dots * feat(python): Fixing tests * feat(python): Adding comment * fix(python): Fixing indentation * fix(python): Fixing indentation --- __init__test.mustache => __init__.mustache | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename __init__test.mustache => __init__.mustache (100%) diff --git a/__init__test.mustache b/__init__.mustache similarity index 100% rename from __init__test.mustache rename to __init__.mustache From d440913526ad980b58eb84579af1094cac64dfd8 Mon Sep 17 00:00:00 2001 From: Sai Giridhar P Date: Wed, 29 May 2019 22:20:26 +0530 Subject: [PATCH 042/185] [python] Adding constructor parameters to Configuration and improving documentation (#3002) * feat(python): Updated configuration's constructor and documentation * feat(python): Updated documentation * feat(python): Updated pet project * feat(python): Updated pet project * feat(python): Fixing host * feat(python): Updating pet project * feat(python): Fixing indentation --- api.mustache | 22 ++++++-- api_doc.mustache | 9 ++++ configuration.mustache | 112 ++++++++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 43 deletions(-) diff --git a/api.mustache b/api.mustache index 4e0612d87d..590299dc5f 100644 --- a/api.mustache +++ b/api.mustache @@ -46,10 +46,17 @@ class {{classname}}(object): {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async_req bool + :param async_req bool: execute request asynchronously {{#allParams}} :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} {{/allParams}} + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} If the method is called asynchronously, returns the request thread. @@ -73,11 +80,20 @@ class {{classname}}(object): {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async_req bool + :param async_req bool: execute request asynchronously {{#allParams}} :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} {{/allParams}} - :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}} If the method is called asynchronously, returns the request thread. """ diff --git a/api_doc.mustache b/api_doc.mustache index 210ac86d2e..1df5389c5c 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -61,6 +61,15 @@ Name | Type | Description | Notes - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} +{{#responses.0}} +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +{{#responses}} +**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}}
{{/headers}}{{^headers.0}} - {{/headers.0}} | +{{/responses}} +{{/responses.0}} + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) {{/operation}} diff --git a/configuration.mustache b/configuration.mustache index a1a7e9babf..b6c134aa1c 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -19,9 +19,9 @@ class TypeWithDefault(type): super(TypeWithDefault, cls).__init__(name, bases, dct) cls._default = None - def __call__(cls): + def __call__(cls, **kwargs): if cls._default is None: - cls._default = type.__call__(cls) + cls._default = type.__call__(cls, **kwargs) return copy.copy(cls._default) def set_default(cls, default): @@ -33,77 +33,109 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): Ref: https://openapi-generator.tech Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s) + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication """ - def __init__(self): - """Constructor""" - # Default Base url - self.host = "{{{basePath}}}" - # Temp file folder for downloading files + def __init__(self, host="{{{basePath}}}", + api_key={}, api_key_prefix={}, + username="", password=""): + """Constructor + """ + self.host = host + """Default Base url + """ self.temp_folder_path = None - + """Temp file folder for downloading files + """ # Authentication Settings - # dict to store API key(s) - self.api_key = {} - # dict to store API prefix (e.g. Bearer) - self.api_key_prefix = {} - # Username for HTTP basic authentication - self.username = "" - # Password for HTTP basic authentication - self.password = "" + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ {{#hasOAuthMethods}} - # access token for OAuth/Bearer self.access_token = "" + """access token for OAuth/Bearer + """ {{/hasOAuthMethods}} {{^hasOAuthMethods}} {{#hasBearerMethods}} - # access token for OAuth/Bearer self.access_token = "" + """access token for OAuth/Bearer + """ {{/hasBearerMethods}} {{/hasOAuthMethods}} - # Logging Settings self.logger = {} + """Logging Settings + """ self.logger["package_logger"] = logging.getLogger("{{packageName}}") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - # Log format self.logger_format = '%(asctime)s %(levelname)s %(message)s' - # Log stream handler + """Log format + """ self.logger_stream_handler = None - # Log file handler + """Log stream handler + """ self.logger_file_handler = None - # Debug file location + """Log file handler + """ self.logger_file = None - # Debug switch + """Debug file location + """ self.debug = False + """Debug switch + """ - # SSL/TLS verification - # Set this to false to skip verifying SSL certificate when calling API - # from https server. self.verify_ssl = True - # Set this to customize the certificate file to verify the peer. + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ self.ssl_ca_cert = None - # client certificate file + """Set this to customize the certificate file to verify the peer. + """ self.cert_file = None - # client key file + """client certificate file + """ self.key_file = None - # Set this to True/False to enable/disable SSL hostname verification. + """client key file + """ self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ - # urllib3 connection pool's maximum number of connections saved - # per pool. urllib3 uses 1 connection as default value, but this is - # not the best value when you are making a lot of possibly parallel - # requests to the same host, which is often the case here. - # cpu_count * 5 is used as default value to increase performance. self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ - # Proxy URL self.proxy = None - # Proxy headers + """Proxy URL + """ self.proxy_headers = None - # Safe chars for path_param + """Proxy headers + """ self.safe_chars_for_path_param = '' - # Adding retries to override urllib3 default value 3 + """Safe chars for path_param + """ self.retries = None + """Adding retries to override urllib3 default value 3 + """ @property def logger_file(self): From 08aa948ef02e0768645427aac6ab0be8223701c2 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Tue, 25 Jun 2019 08:13:43 +0200 Subject: [PATCH 043/185] feat: configurable limit of simultaneous connections (python/asyncio) (#3200) * feat: configurable limit of simultaneous connections (python/asyncio) * fix: remove unused import (python/asyncio) --- asyncio/rest.mustache | 5 ++++- configuration.mustache | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 36b061f8f4..4585f1c6ad 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -38,8 +38,11 @@ class RESTResponse(io.IOBase): class RESTClientObject(object): - def __init__(self, configuration, pools_size=4, maxsize=4): + def __init__(self, configuration, pools_size=4, maxsize=None): + # maxsize is number of requests to host that are allowed in parallel + if maxsize is None: + maxsize = configuration.connection_pool_maxsize # ca_certs if configuration.ssl_ca_cert: diff --git a/configuration.mustache b/configuration.mustache index b6c134aa1c..6d0d5c62e1 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -6,7 +6,9 @@ from __future__ import absolute_import import copy import logging +{{^asyncio}} import multiprocessing +{{/asyncio}} import sys import urllib3 @@ -116,6 +118,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): """Set this to True/False to enable/disable SSL hostname verification. """ + {{#asyncio}} + self.connection_pool_maxsize = 100 + """This value is passed to the aiohttp to limit simultaneous connections. + Default values is 100, None means no-limit. + """ + {{/asyncio}} + {{^asyncio}} self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 """urllib3 connection pool's maximum number of connections saved per pool. urllib3 uses 1 connection as default value, but this is @@ -123,6 +132,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): requests to the same host, which is often the case here. cpu_count * 5 is used as default value to increase performance. """ + {{/asyncio}} self.proxy = None """Proxy URL From 8f5b42adcd7429391da4c0a3bc454d365b6889df Mon Sep 17 00:00:00 2001 From: Sai Giridhar P Date: Fri, 28 Jun 2019 15:23:25 +0530 Subject: [PATCH 044/185] [python] : Make example code snippet compilable (#3148) * feat(python): Making example compilable * feat(python): Updating pet project * feat(python): Updating comments * feat(documentation): Fixing comments style * feat(documentation): Updating documentation * feat(documentation): Fixing comments style --- api_doc_example.mustache | 6 ++++-- common_README.mustache | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api_doc_example.mustache b/api_doc_example.mustache index c8f0d8b554..f2d6117a7c 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -6,13 +6,15 @@ from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} {{#hasAuthMethods}} -# create an instance of the API class +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} -# create an instance of the API class +# Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}() {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} diff --git a/common_README.mustache b/common_README.mustache index d8e9f94c58..7238703c4b 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -6,7 +6,9 @@ from {{{packageName}}}.rest import ApiException from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{> python_doc_auth_partial}} -# create an instance of the API class +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} From 33aee95af93122bf14c825dcf0ce3c44c541be52 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 31 Jul 2019 06:18:30 -0700 Subject: [PATCH 045/185] [python-experimental] automatically use values for enums of length1 (#3118) * Update python client java generator * Updates python generator mustache files * Python sample regenerated * Switches from getfullargspec to getargspec for python2 compatibility * Uses getattr to get model class init method to correctly see its arguments, linting fixes to pass python tests * Updates comment in python centerator to restart CI tests * Adds bin/windows/python-experimental-petstore.bat * CHanges spec update to apply to the python-experimental spec * Moves new python templates to python-experimental * Moves generator python java code to python-experimental * Reverts python generator mustache files * Regenerates python, v3 python, python-experimental samples * Test moved to python-experimental, unused python files removed --- python-experimental/api.mustache | 294 ++++++++ python-experimental/api_client.mustache | 665 +++++++++++++++++++ python-experimental/api_doc.mustache | 78 +++ python-experimental/api_doc_example.mustache | 58 ++ python-experimental/model.mustache | 241 +++++++ python-experimental/model_doc.mustache | 13 + 6 files changed, 1349 insertions(+) create mode 100644 python-experimental/api.mustache create mode 100644 python-experimental/api_client.mustache create mode 100644 python-experimental/api_doc.mustache create mode 100644 python-experimental/api_doc_example.mustache create mode 100644 python-experimental/model.mustache create mode 100644 python-experimental/model_doc.mustache diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache new file mode 100644 index 0000000000..edf76be03b --- /dev/null +++ b/python-experimental/api.mustache @@ -0,0 +1,294 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from {{packageName}}.api_client import ApiClient +from {{packageName}}.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +{{#operations}} +class {{classname}}(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client +{{#operation}} + + def {{operationId}}(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}={{{defaultValue}}}{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) + >>> result = thread.get() + +{{#requiredParams}} +{{^hasMore}} + Args: +{{/hasMore}} +{{/requiredParams}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} + + Keyword Args:{{#optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + async_req (bool): execute request asynchronously + param _preload_content (bool): if False, the urllib3.HTTPResponse + object will be returned without reading/decoding response data. + Default is True. + param _request_timeout (float/tuple): timeout setting for this + request. If one number provided, it will be total request + timeout. It can also be a pair (tuple) of (connection, read) + timeouts. + + Returns: + {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 + else: + (data) = self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 + return data + + def {{operationId}}_with_http_info(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}=None{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}async_req=True) + >>> result = thread.get() + +{{#requiredParams}} +{{^hasMore}} + Args: +{{/hasMore}} +{{/requiredParams}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} + + Keyword Args:{{#optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + async_req (bool): execute request asynchronously + param _preload_content (bool): if False, the urllib3.HTTPResponse + object will be returned without reading/decoding response data. + Default is True. + param _request_timeout (float/tuple): timeout setting for this + request. If one number provided, it will be total request + timeout. It can also be a pair (tuple) of (connection, read) + timeouts. + + Returns: + {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: + """ + + {{#servers.0}} + local_var_hosts = [{{#servers}} + '{{{url}}}'{{^-last}},{{/-last}}{{/servers}} + ] + local_var_host = local_var_hosts[0] + if kwargs.get('_host_index'): + if (int(kwargs.get('_host_index')) < 0 or + int(kwargs.get('_host_index')) >= len(local_var_hosts)): + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(local_var_host) + ) + local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] + {{/servers.0}} + local_var_params = locals() + + all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method {{operationId}}" % key + ) + local_var_params[key] = val + del local_var_params['kwargs'] +{{#allParams}} +{{^isNullable}} +{{#required}} + # verify the required parameter '{{paramName}}' is set + if ('{{paramName}}' not in local_var_params or + local_var_params['{{paramName}}'] is None): + raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 +{{/required}} +{{/isNullable}} +{{#-last}} +{{/-last}} +{{/allParams}} +{{#allParams}} +{{#isEnum}} +{{#isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 +{{#isListContainer}} + if ('{{{paramName}}}' in local_var_params and + not set(local_var_params['{{{paramName}}}']).issubset(set(allowed_values))): # noqa: E501 + raise ValueError( + "Invalid values for `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set(local_var_params['{{{paramName}}}']) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isListContainer}} +{{#isMapContainer}} + if ('{{{paramName}}}' in local_var_params and + not set(local_var_params['{{{paramName}}}'].keys()).issubset(set(allowed_values))): + raise ValueError( + "Invalid keys in `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set(local_var_params['{{{paramName}}}'].keys()) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isMapContainer}} +{{/isContainer}} +{{^isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + if ('{{{paramName}}}' in local_var_params and + local_var_params['{{{paramName}}}'] not in allowed_values): + raise ValueError( + "Invalid value for `{{{paramName}}}` ({0}), must be one of {1}" # noqa: E501 + .format(local_var_params['{{{paramName}}}'], allowed_values) + ) +{{/isContainer}} +{{/isEnum}} +{{/allParams}} +{{#allParams}} +{{#hasValidation}} + {{#maxLength}} + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) > {{maxLength}}): + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 + {{/maxLength}} + {{#minLength}} + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) < {{minLength}}): + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 + {{/minLength}} + {{#maximum}} + if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 + {{/maximum}} + {{#minimum}} + if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 + {{/minimum}} + {{#pattern}} + if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 + {{/pattern}} + {{#maxItems}} + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) > {{maxItems}}): + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 + {{/maxItems}} + {{#minItems}} + if ('{{paramName}}' in local_var_params and + len(local_var_params['{{paramName}}']) < {{minItems}}): + raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 + {{/minItems}} +{{/hasValidation}} +{{/allParams}} + + collection_formats = {} + + path_params = {} +{{#pathParams}} + if '{{paramName}}' in local_var_params: + path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/pathParams}} + + query_params = [] +{{#queryParams}} + if '{{paramName}}' in local_var_params: + query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/queryParams}} + + header_params = {} +{{#headerParams}} + if '{{paramName}}' in local_var_params: + header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/headerParams}} + + form_params = [] + local_var_files = {} +{{#formParams}} + if '{{paramName}}' in local_var_params: + {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 +{{/formParams}} + + body_params = None +{{#bodyParam}} + if '{{paramName}}' in local_var_params: + body_params = local_var_params['{{paramName}}'] +{{/bodyParam}} + {{#hasProduces}} + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + + {{/hasProduces}} + {{#hasConsumes}} + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + + {{/hasConsumes}} + # Authentication setting + auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + + return self.api_client.call_api( + '{{{path}}}', '{{httpMethod}}', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + {{#servers.0}} + _host=local_var_host, + {{/servers.0}} + collection_formats=collection_formats) +{{/operation}} +{{/operations}} diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache new file mode 100644 index 0000000000..e955eb0570 --- /dev/null +++ b/python-experimental/api_client.mustache @@ -0,0 +1,665 @@ +# coding: utf-8 +{{>partial_header}} +from __future__ import absolute_import + +import datetime +import inspect +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote +{{#tornado}} +import tornado.gen +{{/tornado}} + +from {{packageName}}.configuration import Configuration +import {{modelPackage}} +from {{packageName}} import rest +from {{packageName}}.exceptions import ApiValueError + + +class ApiClient(object): + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' + + def __del__(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + {{#tornado}} + @tornado.gen.coroutine + {{/tornado}} + {{#asyncio}}async {{/asyncio}}def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + + self.last_response = response_data + + return_data = response_data + if _preload_content: + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + +{{^tornado}} + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) +{{/tornado}} +{{#tornado}} + if _return_http_data_only: + raise tornado.gen.Return(return_data) + else: + raise tornado.gen.Return((return_data, response_data.status, + response_data.getheaders())) +{{/tornado}} + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.openapi_types) + if getattr(obj, attr) is not None} + + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if type(klass) == str: + if klass.startswith('list['): + sub_kls = re.match(r'list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('dict('): + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr({{modelPackage}}, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datatime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async_req=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host) + else: + thread = self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, query_params, + header_params, body, + post_params, files, + response_type, auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host)) + return thread + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in six.iteritems(files): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return six.text_type(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + from dateutil.parser import parse + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datatime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + from dateutil.parser import parse + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + if not klass.openapi_types and not hasattr(klass, + 'get_real_child_model'): + return data + + used_data = data + if not isinstance(data, (list, dict)): + used_data = [data] + keyword_args = {} + positional_args = [] + if klass.openapi_types is not None: + for attr, attr_type in six.iteritems(klass.openapi_types): + if (data is not None and + klass.attribute_map[attr] in used_data): + value = used_data[klass.attribute_map[attr]] + keyword_args[attr] = self.__deserialize(value, attr_type) + + end_index = None + argspec = inspect.getargspec(getattr(klass, '__init__')) + if argspec.defaults: + end_index = -len(argspec.defaults) + required_positional_args = argspec.args[1:end_index] + + for index, req_positional_arg in enumerate(required_positional_args): + if keyword_args and req_positional_arg in keyword_args: + positional_args.append(keyword_args[req_positional_arg]) + del keyword_args[req_positional_arg] + elif (not keyword_args and index < len(used_data) and + isinstance(used_data, list)): + positional_args.append(used_data[index]) + + instance = klass(*positional_args, **keyword_args) + + if hasattr(instance, 'get_real_child_model'): + klass_name = instance.get_real_child_model(data) + if klass_name: + instance = self.__deserialize(data, klass_name) + return instance diff --git a/python-experimental/api_doc.mustache b/python-experimental/api_doc.mustache new file mode 100644 index 0000000000..5cc638a2eb --- /dev/null +++ b/python-experimental/api_doc.mustache @@ -0,0 +1,78 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example + +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +{{^isBasicBearer}} +* Basic Authentication ({{name}}): +{{/isBasicBearer}} +{{#isBasicBearer}} +* Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} +* Api Key Authentication ({{name}}): +{{/isApiKey }} +{{#isOAuth}} +* OAuth Authentication ({{name}}): +{{/isOAuth }} +{{> api_doc_example }} +{{/authMethods}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} +{{> api_doc_example }} +{{/hasAuthMethods}} +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | +{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | defaults to {{{.}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{#responses.0}} +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +{{#responses}} +**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}}
{{/headers}}{{^headers.0}} - {{/headers.0}} | +{{/responses}} +{{/responses.0}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache new file mode 100644 index 0000000000..e5eeee6b0e --- /dev/null +++ b/python-experimental/api_doc_example.mustache @@ -0,0 +1,58 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{> python_doc_auth_partial}} +{{#hasAuthMethods}} +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{/hasAuthMethods}} +{{^hasAuthMethods}} +# Create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{/hasAuthMethods}} +{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} +{{/optionalParams}} + +{{#requiredParams}} +{{^hasMore}} +# example passing only required values which don't have defaults set +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/hasMore}} +{{/requiredParams}} + +{{#optionalParams}} +{{^hasMore}} +# example passing only required values which don't have defaults set +# and optional values +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/hasMore}} +{{/optionalParams}} + +{{^requiredParams}} +{{^optionalParams}} +# example, this endpoint has no required or optional parameters +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/optionalParams}} +{{/requiredParams}} +``` diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache new file mode 100644 index 0000000000..7dc8e01fa6 --- /dev/null +++ b/python-experimental/model.mustache @@ -0,0 +1,241 @@ +# coding: utf-8 + +{{>partial_header}} + +import pprint +import re # noqa: F401 + +import six + + +{{#models}} +{{#model}} +class {{classname}}(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """{{#allowableValues}} + + """ + allowed enum values + """ +{{#enumVars}} + {{name}} = {{{value}}}{{^-last}} +{{/-last}} +{{/enumVars}}{{/allowableValues}} + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { +{{#requiredVars}} + '{{name}}': '{{{dataType}}}', +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{{dataType}}}', +{{/optionalVars}} + } + + attribute_map = { +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} + } +{{#discriminator}} + + discriminator_value_class_map = { + {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, + {{/-last}}{{/children}} + } +{{/discriminator}} + + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}, {{name}}=None{{/optionalVars}}): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} + {{name}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}} + + Keyword Args:{{#requiredVars}}{{#defaultValue}} + {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}} # noqa: E501{{/requiredVars}}{{#optionalVars}} + {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + """ +{{#vars}}{{#-first}} +{{/-first}} + self._{{name}} = None +{{/vars}} + self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} +{{#vars}}{{#-first}} +{{/-first}} +{{#required}} + self.{{name}} = {{name}} +{{/required}} +{{^required}} +{{#isNullable}} + self.{{name}} = {{name}} +{{/isNullable}} +{{^isNullable}} + if {{name}} is not None: + self.{{name}} = {{name}} # noqa: E501 +{{/isNullable}} +{{/required}} +{{/vars}} + +{{#vars}} + @property + def {{name}}(self): + """Gets the {{name}} of this {{classname}}. # noqa: E501 + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :return: The {{name}} of this {{classname}}. # noqa: E501 + :rtype: {{dataType}} + """ + return self._{{name}} + + @{{name}}.setter + def {{name}}( + self, + {{name}}): + """Sets the {{name}} of this {{classname}}. + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 + :type: {{dataType}} + """ +{{^isNullable}} +{{#required}} + if {{name}} is None: + raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 +{{/required}} +{{/isNullable}} +{{#isEnum}} +{{#isContainer}} + allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 +{{#isListContainer}} + if not set({{{name}}}).issubset(set(allowed_values)): + raise ValueError( + "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isListContainer}} +{{#isMapContainer}} + if not set({{{name}}}.keys()).issubset(set(allowed_values)): + raise ValueError( + "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 + ", ".join(map(str, allowed_values))) + ) +{{/isMapContainer}} +{{/isContainer}} +{{^isContainer}} + allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 + if {{{name}}} not in allowed_values: + raise ValueError( + "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 + .format({{{name}}}, allowed_values) + ) +{{/isContainer}} +{{/isEnum}} +{{^isEnum}} +{{#hasValidation}} +{{#maxLength}} + if {{name}} is not None and len({{name}}) > {{maxLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 +{{/maxLength}} +{{#minLength}} + if {{name}} is not None and len({{name}}) < {{minLength}}: + raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 +{{/minLength}} +{{#maximum}} + if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 +{{/maximum}} +{{#minimum}} + if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 +{{/minimum}} +{{#pattern}} + if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 +{{/pattern}} +{{#maxItems}} + if {{name}} is not None and len({{name}}) > {{maxItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 +{{/maxItems}} +{{#minItems}} + if {{name}} is not None and len({{name}}) < {{minItems}}: + raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 +{{/minItems}} +{{/hasValidation}} +{{/isEnum}} + + self._{{name}} = ( + {{name}}) + +{{/vars}} +{{#discriminator}} + def get_real_child_model(self, data): + """Returns the real base class specified by the discriminator""" + discriminator_key = self.attribute_map[self.discriminator] + discriminator_value = data[discriminator_key] + return self.discriminator_value_class_map.get(discriminator_value) + +{{/discriminator}} + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other +{{/model}} +{{/models}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache new file mode 100644 index 0000000000..b6e1b263fc --- /dev/null +++ b/python-experimental/model_doc.mustache @@ -0,0 +1,13 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#requiredVars}}{{^defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#readOnly}}[readonly] {{/readOnly}} +{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalVars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} From fbb5a181635d5ef3ada6d69fbb1571537448e130 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 12 Aug 2019 22:55:45 -0700 Subject: [PATCH 046/185] [Python] avoid unnecessary dictionary lookup in get_api_key method (#3592) --- configuration.mustache | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 6d0d5c62e1..b82ff7db89 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -238,11 +238,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): :param identifier: The identifier of apiKey. :return: The token for api key authentication. """ - if (self.api_key.get(identifier) and - self.api_key_prefix.get(identifier)): - return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501 - elif self.api_key.get(identifier): - return self.api_key[identifier] + key = self.api_key.get(identifier) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key def get_basic_auth_token(self): """Gets HTTP basic authentication header (string). From 8218fa2546d51d050f330ad8061d2b9f69a9acdc Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Thu, 15 Aug 2019 07:06:36 -0700 Subject: [PATCH 047/185] [Python] support api key refresh in configuration module (#3594) --- configuration.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index b82ff7db89..2afcb7478e 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -61,6 +61,9 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): self.api_key_prefix = api_key_prefix """dict to store API prefix (e.g. Bearer) """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ self.username = username """Username for HTTP basic authentication """ @@ -238,6 +241,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): :param identifier: The identifier of apiKey. :return: The token for api key authentication. """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) key = self.api_key.get(identifier) if key: prefix = self.api_key_prefix.get(identifier) From 91d4c6eb3aaf5f06b4732ce3a43e3ad1ae99510a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4gi?= Date: Sun, 25 Aug 2019 11:59:38 +0200 Subject: [PATCH 048/185] Exclude "test" from packages so that it is not installed as top-level package when "pip installing" the generated sdk (#3731) --- setup.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.mustache b/setup.mustache index 201b79e217..588851cc7b 100644 --- a/setup.mustache +++ b/setup.mustache @@ -32,7 +32,7 @@ setup( url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], install_requires=REQUIRES, - packages=find_packages(), + packages=find_packages(exclude=["test", "tests"]), include_package_data=True, long_description="""\ {{appDescription}} # noqa: E501 From e8a3a27447a400357f89ab361a81ca8f0e94f992 Mon Sep 17 00:00:00 2001 From: Quim Muntal Date: Tue, 3 Sep 2019 15:35:49 +0200 Subject: [PATCH 049/185] Support custom git repository (#3757) * add gitHost param to GeneratorSettings and related * parameterize gitHost in READMEs * parameterize gitHost in go.mod * parameterize gitHost in git_push * update petstore samples * run ./bin/utils/export_docs_generators.sh * run meta-codehen.sh * Revert "run meta-codehen.sh" This reverts commit d6d579f6159186531257cdfdd73b9caf9e9ffeba. * Revert "run ./bin/utils/export_docs_generators.sh" This reverts commit 1b81538198d4319fd1b4e97447303e3cc0e8dc99. * Revert "update petstore samples" This reverts commit f513add88396707f6991ae2e4920359583ec88f1. * run ensure-up-to-date --- README.mustache | 6 +++--- git_push.sh.mustache | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.mustache b/README.mustache index be83533906..144f72427e 100644 --- a/README.mustache +++ b/README.mustache @@ -22,12 +22,12 @@ Python 2.7 and 3.4+ ## Installation & Usage ### pip install -If the python package is hosted on Github, you can install directly from Github +If the python package is hosted on a repository, you can install directly using: ```sh -pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git +pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git ``` -(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) +(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) Then import the package: ```python diff --git a/git_push.sh.mustache b/git_push.sh.mustache index 8a32e53995..8b3f689c91 100755 --- a/git_push.sh.mustache +++ b/git_push.sh.mustache @@ -1,11 +1,17 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="{{{gitHost}}}" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="{{{gitUserId}}}" @@ -28,7 +34,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' From 9af5c1ace36150bf663052cb0d52fa72bb4125ae Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 24 Sep 2019 03:44:28 -0700 Subject: [PATCH 050/185] [python-experimental] generate model if type != object if enums/validations exist (#2757) * Python-experimental adds model_utils module, refactors python api class * Fixes python-experimental so the sample sare generated in the petstore_api folder * FIxes python samples tests * Updates python and python-experimental tests * Fixes python-experimental tests * Adds newlines back to python templates + samples * Reverts files with newline tweaks back to master branch versions * Fixes indentation errors in python-experimental api_client * Removes unused files * Python files now generated in correct folders * Adds logging when the user tries to set generateAliasAsModel in python-experimental * Fixes typo --- python-experimental/api.mustache | 589 +++++++++++------- python-experimental/api_client.mustache | 25 +- python-experimental/model.mustache | 250 +------- .../model_templates/classvar_allowed.mustache | 16 + .../classvar_openapi_validations.mustache | 25 + .../docstring_allowed.mustache | 4 + .../docstring_openapi_validations.mustache | 7 + .../methods_init_properties.mustache | 76 +++ .../model_templates/model_normal.mustache | 83 +++ .../model_templates/model_simple.mustache | 34 + python-experimental/model_utils.mustache | 175 ++++++ 11 files changed, 813 insertions(+), 471 deletions(-) create mode 100644 python-experimental/model_templates/classvar_allowed.mustache create mode 100644 python-experimental/model_templates/classvar_openapi_validations.mustache create mode 100644 python-experimental/model_templates/docstring_allowed.mustache create mode 100644 python-experimental/model_templates/docstring_openapi_validations.mustache create mode 100644 python-experimental/model_templates/methods_init_properties.mustache create mode 100644 python-experimental/model_templates/model_normal.mustache create mode 100644 python-experimental/model_templates/model_simple.mustache create mode 100644 python-experimental/model_utils.mustache diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index edf76be03b..dd650b37d7 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -10,10 +10,14 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( # noqa: F401 +from {{packageName}}.exceptions import ( ApiTypeError, ApiValueError ) +from {{packageName}}.model_utils import ( + check_allowed_values, + check_validations +) {{#operations}} @@ -30,265 +34,384 @@ class {{classname}}(object): self.api_client = api_client {{#operation}} - def {{operationId}}(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}={{{defaultValue}}}{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + def __{{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} - {{{notes}}} # noqa: E501 + {{{notes}}} # noqa: E501 {{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) - >>> result = thread.get() - -{{#requiredParams}} -{{^hasMore}} - Args: -{{/hasMore}} -{{/requiredParams}} -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() - Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param async_req bool: execute request asynchronously +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/allParams}} + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 - else: - (data) = self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 - return data - - def {{operationId}}_with_http_info(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}=None{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 - -{{#notes}} - {{{notes}}} # noqa: E501 -{{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}async_req=True) - >>> result = thread.get() - + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) {{#requiredParams}} -{{^hasMore}} - Args: -{{/hasMore}} + kwargs['{{paramName}}'] = {{paramName}} {{/requiredParams}} -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} - - Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: - """ + return self.call_with_http_info(**kwargs) - {{#servers.0}} - local_var_hosts = [{{#servers}} - '{{{url}}}'{{^-last}},{{/-last}}{{/servers}} - ] - local_var_host = local_var_hosts[0] - if kwargs.get('_host_index'): - if (int(kwargs.get('_host_index')) < 0 or - int(kwargs.get('_host_index')) >= len(local_var_hosts)): - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" % - len(local_var_host) - ) - local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] - {{/servers.0}} - local_var_params = locals() - - all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method {{operationId}}" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] + self.{{operationId}} = Endpoint( + settings={ + 'response_type': {{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, +{{#authMethods}} +{{#-first}} + 'auth': [ +{{/-first}} + '{{name}}'{{#hasMore}}, {{/hasMore}} +{{#-last}} + ], +{{/-last}} +{{/authMethods}} +{{^authMethods}} + 'auth': [], +{{/authMethods}} + 'endpoint_path': '{{{path}}}', + 'operation_id': '{{operationId}}', + 'http_method': '{{httpMethod}}', +{{#servers}} +{{#-first}} + 'servers': [ +{{/-first}} + '{{{url}}}'{{^-last}},{{/-last}} +{{#-last}} + ] +{{/-last}} +{{/servers}} +{{^servers}} + 'servers': [], +{{/servers}} + }, + params_map={ + 'all': [ {{#allParams}} -{{^isNullable}} -{{#required}} - # verify the required parameter '{{paramName}}' is set - if ('{{paramName}}' not in local_var_params or - local_var_params['{{paramName}}'] is None): - raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 -{{/required}} -{{/isNullable}} + '{{paramName}}', +{{/allParams}} + ], +{{#requiredParams}} +{{#-first}} + 'required': [ +{{/-first}} + '{{paramName}}', {{#-last}} + ], {{/-last}} +{{/requiredParams}} +{{^requiredParams}} + 'required': [], +{{/requiredParams}} + 'nullable': [ +{{#allParams}} +{{#isNullable}} + '{{paramName}}', +{{/isNullable}} {{/allParams}} + ], + 'enum': [ {{#allParams}} {{#isEnum}} -{{#isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 -{{#isListContainer}} - if ('{{{paramName}}}' in local_var_params and - not set(local_var_params['{{{paramName}}}']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['{{{paramName}}}']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isListContainer}} -{{#isMapContainer}} - if ('{{{paramName}}}' in local_var_params and - not set(local_var_params['{{{paramName}}}'].keys()).issubset(set(allowed_values))): - raise ValueError( - "Invalid keys in `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['{{{paramName}}}'].keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isMapContainer}} -{{/isContainer}} -{{^isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if ('{{{paramName}}}' in local_var_params and - local_var_params['{{{paramName}}}'] not in allowed_values): - raise ValueError( - "Invalid value for `{{{paramName}}}` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['{{{paramName}}}'], allowed_values) - ) -{{/isContainer}} + '{{paramName}}', {{/isEnum}} {{/allParams}} + ], + 'validation': [ {{#allParams}} {{#hasValidation}} - {{#maxLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxLength}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 - {{/maxLength}} - {{#minLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minLength}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 - {{/minLength}} - {{#maximum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 - {{/maximum}} - {{#minimum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 - {{/minimum}} - {{#pattern}} - if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 - {{/pattern}} - {{#maxItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxItems}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 - {{/maxItems}} - {{#minItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minItems}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 - {{/minItems}} + '{{paramName}}', {{/hasValidation}} {{/allParams}} + ] + }, + root_map={ + 'validations': { +{{#allParams}} +{{#hasValidation}} + ('{{paramName}}',): { +{{#maxLength}} + 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} + 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} + 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} + 'min_items': {{minItems}},{{/minItems}}{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + },{{/pattern}} + }, +{{/hasValidation}} +{{/allParams}} + }, + 'allowed_values': { +{{#allParams}} +{{#isEnum}} + ('{{paramName}}',): { +{{#isNullable}} + 'None': None,{{/isNullable}}{{#allowableValues}}{{#enumVars}} + "{{name}}": {{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + }, +{{/isEnum}} +{{/allParams}} + }, + 'openapi_types': { +{{#allParams}} + '{{paramName}}': '{{dataType}}', +{{/allParams}} + }, + 'attribute_map': { +{{#allParams}} +{{^isBodyParam}} + '{{paramName}}': '{{baseName}}', +{{/isBodyParam}} +{{/allParams}} + }, + 'location_map': { +{{#allParams}} + '{{paramName}}': '{{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isCookieParam}}cookie{{/isCookieParam}}{{#isBodyParam}}body{{/isBodyParam}}', +{{/allParams}} + }, + 'collection_format_map': { +{{#allParams}} +{{#collectionFormat}} + '{{paramName}}': '{{collectionFormat}}', +{{/collectionFormat}} +{{/allParams}} + } + }, + headers_map={ +{{#hasProduces}} + 'accept': [ +{{#produces}} + '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} +{{/produces}} + ], +{{/hasProduces}} +{{^hasProduces}} + 'accept': [], +{{/hasProduces}} +{{#hasConsumes}} + 'content_type': [ +{{#consumes}} + '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} +{{/consumes}} + ] +{{/hasConsumes}} +{{^hasConsumes}} + 'content_type': [], +{{/hasConsumes}} + }, + api_client=api_client, + callable=__{{operationId}} + ) +{{/operation}} +{{/operations}} + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called + """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations + ) + + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] + ) + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } - collection_formats = {} + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format - path_params = {} -{{#pathParams}} - if '{{paramName}}' in local_var_params: - path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/pathParams}} + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + else: + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - query_params = [] -{{#queryParams}} - if '{{paramName}}' in local_var_params: - query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/queryParams}} + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: + raise ApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) - header_params = {} -{{#headerParams}} - if '{{paramName}}' in local_var_params: - header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/headerParams}} + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - form_params = [] - local_var_files = {} -{{#formParams}} - if '{{paramName}}' in local_var_params: - {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/formParams}} + self.__validate_inputs(kwargs) - body_params = None -{{#bodyParam}} - if '{{paramName}}' in local_var_params: - body_params = local_var_params['{{paramName}}'] -{{/bodyParam}} - {{#hasProduces}} - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + params = self.__gather_params(kwargs) - {{/hasProduces}} - {{#hasConsumes}} - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - {{/hasConsumes}} - # Authentication setting - auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '{{{path}}}', '{{httpMethod}}', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - {{#servers.0}} - _host=local_var_host, - {{/servers.0}} - collection_formats=collection_formats) -{{/operation}} -{{/operations}} + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index e955eb0570..0f02b445df 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -18,9 +18,13 @@ from six.moves.urllib.parse import quote import tornado.gen {{/tornado}} -from {{packageName}}.configuration import Configuration import {{modelPackage}} from {{packageName}} import rest +from {{packageName}}.configuration import Configuration +from {{packageName}}.model_utils import ( + ModelNormal, + ModelSimple +) from {{packageName}}.exceptions import ApiValueError @@ -224,7 +228,7 @@ class ApiClient(object): if isinstance(obj, dict): obj_dict = obj - else: + elif isinstance(obj, ModelNormal): # Convert model obj to dict except # attributes `openapi_types`, `attribute_map` # and attributes which value is not None. @@ -233,6 +237,8 @@ class ApiClient(object): obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) for attr, _ in six.iteritems(obj.openapi_types) if getattr(obj, attr) is not None} + elif isinstance(obj, ModelSimple): + return self.sanitize_for_serialization(obj.value) return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)} @@ -571,6 +577,8 @@ class ApiClient(object): return six.text_type(data) except TypeError: return data + except ValueError as exc: + raise ApiValueError(str(exc)) def __deserialize_object(self, value): """Return an original value. @@ -622,14 +630,15 @@ class ApiClient(object): """Deserializes list or dict to model. :param data: dict, list. - :param klass: class literal. + :param klass: class literal, ModelSimple or ModelNormal :return: model object. """ - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): - return data + if issubclass(klass, ModelSimple): + value = self.__deserialize(data, klass.openapi_types['value']) + return klass(value) + # code to handle ModelNormal used_data = data if not isinstance(data, (list, dict)): used_data = [data] @@ -641,13 +650,11 @@ class ApiClient(object): klass.attribute_map[attr] in used_data): value = used_data[klass.attribute_map[attr]] keyword_args[attr] = self.__deserialize(value, attr_type) - end_index = None argspec = inspect.getargspec(getattr(klass, '__init__')) if argspec.defaults: end_index = -len(argspec.defaults) required_positional_args = argspec.args[1:end_index] - for index, req_positional_arg in enumerate(required_positional_args): if keyword_args and req_positional_arg in keyword_args: positional_args.append(keyword_args[req_positional_arg]) @@ -655,9 +662,7 @@ class ApiClient(object): elif (not keyword_args and index < len(used_data) and isinstance(used_data, list)): positional_args.append(used_data[index]) - instance = klass(*positional_args, **keyword_args) - if hasattr(instance, 'get_real_child_model'): klass_name = instance.get_real_child_model(data) if klass_name: diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 7dc8e01fa6..082f4bddc4 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -2,240 +2,34 @@ {{>partial_header}} -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 + +from {{packageName}}.exceptions import ApiValueError # noqa: F401 +from {{packageName}}.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) {{#models}} {{#model}} -class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """{{#allowableValues}} - - """ - allowed enum values - """ -{{#enumVars}} - {{name}} = {{{value}}}{{^-last}} +{{^interfaces}} +{{#isAlias}} +{{> python-experimental/model_templates/model_simple }} +{{/isAlias}} +{{^isAlias}} +{{> python-experimental/model_templates/model_normal }} +{{/isAlias}} +{{/interfaces}} +{{#interfaces}} +{{#-last}} +{{> python-experimental/model_templates/model_normal }} {{/-last}} -{{/enumVars}}{{/allowableValues}} - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { -{{#requiredVars}} - '{{name}}': '{{{dataType}}}', -{{/requiredVars}} -{{#optionalVars}} - '{{name}}': '{{{dataType}}}', -{{/optionalVars}} - } - - attribute_map = { -{{#requiredVars}} - '{{name}}': '{{baseName}}', # noqa: E501 -{{/requiredVars}} -{{#optionalVars}} - '{{name}}': '{{baseName}}', # noqa: E501 -{{/optionalVars}} - } -{{#discriminator}} - - discriminator_value_class_map = { - {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, - {{/-last}}{{/children}} - } -{{/discriminator}} - - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}, {{name}}=None{{/optionalVars}}): # noqa: E501 - """{{classname}} - a model defined in OpenAPI - -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}} - - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}} # noqa: E501{{/requiredVars}}{{#optionalVars}} - {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ -{{#vars}}{{#-first}} -{{/-first}} - self._{{name}} = None -{{/vars}} - self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} -{{#vars}}{{#-first}} -{{/-first}} -{{#required}} - self.{{name}} = {{name}} -{{/required}} -{{^required}} -{{#isNullable}} - self.{{name}} = {{name}} -{{/isNullable}} -{{^isNullable}} - if {{name}} is not None: - self.{{name}} = {{name}} # noqa: E501 -{{/isNullable}} -{{/required}} -{{/vars}} - -{{#vars}} - @property - def {{name}}(self): - """Gets the {{name}} of this {{classname}}. # noqa: E501 - -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - :return: The {{name}} of this {{classname}}. # noqa: E501 - :rtype: {{dataType}} - """ - return self._{{name}} - - @{{name}}.setter - def {{name}}( - self, - {{name}}): - """Sets the {{name}} of this {{classname}}. - -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type: {{dataType}} - """ -{{^isNullable}} -{{#required}} - if {{name}} is None: - raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 -{{/required}} -{{/isNullable}} -{{#isEnum}} -{{#isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 -{{#isListContainer}} - if not set({{{name}}}).issubset(set(allowed_values)): - raise ValueError( - "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isListContainer}} -{{#isMapContainer}} - if not set({{{name}}}.keys()).issubset(set(allowed_values)): - raise ValueError( - "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isMapContainer}} -{{/isContainer}} -{{^isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if {{{name}}} not in allowed_values: - raise ValueError( - "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 - .format({{{name}}}, allowed_values) - ) -{{/isContainer}} -{{/isEnum}} -{{^isEnum}} -{{#hasValidation}} -{{#maxLength}} - if {{name}} is not None and len({{name}}) > {{maxLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 -{{/maxLength}} -{{#minLength}} - if {{name}} is not None and len({{name}}) < {{minLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 -{{/minLength}} -{{#maximum}} - if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 -{{/maximum}} -{{#minimum}} - if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 -{{/minimum}} -{{#pattern}} - if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 -{{/pattern}} -{{#maxItems}} - if {{name}} is not None and len({{name}}) > {{maxItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 -{{/maxItems}} -{{#minItems}} - if {{name}} is not None and len({{name}}) < {{minItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 -{{/minItems}} -{{/hasValidation}} -{{/isEnum}} - - self._{{name}} = ( - {{name}}) - -{{/vars}} -{{#discriminator}} - def get_real_child_model(self, data): - """Returns the real base class specified by the discriminator""" - discriminator_key = self.attribute_map[self.discriminator] - discriminator_value = data[discriminator_key] - return self.discriminator_value_class_map.get(discriminator_value) - -{{/discriminator}} - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other +{{/interfaces}} {{/model}} {{/models}} diff --git a/python-experimental/model_templates/classvar_allowed.mustache b/python-experimental/model_templates/classvar_allowed.mustache new file mode 100644 index 0000000000..6ed39521f6 --- /dev/null +++ b/python-experimental/model_templates/classvar_allowed.mustache @@ -0,0 +1,16 @@ + allowed_values = { +{{#vars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/vars}} + } \ No newline at end of file diff --git a/python-experimental/model_templates/classvar_openapi_validations.mustache b/python-experimental/model_templates/classvar_openapi_validations.mustache new file mode 100644 index 0000000000..7e89f83ef2 --- /dev/null +++ b/python-experimental/model_templates/classvar_openapi_validations.mustache @@ -0,0 +1,25 @@ + openapi_types = { +{{#vars}} + '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } + + validations = { +{{#vars}} +{{#hasValidation}} + ('{{name}}',): { +{{#maxLength}} + 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} + 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} + 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} + 'min_items': {{minItems}},{{/minItems}}{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + },{{/pattern}} + }, +{{/hasValidation}} +{{/vars}} + } \ No newline at end of file diff --git a/python-experimental/model_templates/docstring_allowed.mustache b/python-experimental/model_templates/docstring_allowed.mustache new file mode 100644 index 0000000000..ab20932b28 --- /dev/null +++ b/python-experimental/model_templates/docstring_allowed.mustache @@ -0,0 +1,4 @@ + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. \ No newline at end of file diff --git a/python-experimental/model_templates/docstring_openapi_validations.mustache b/python-experimental/model_templates/docstring_openapi_validations.mustache new file mode 100644 index 0000000000..46dc1afefc --- /dev/null +++ b/python-experimental/model_templates/docstring_openapi_validations.mustache @@ -0,0 +1,7 @@ + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. \ No newline at end of file diff --git a/python-experimental/model_templates/methods_init_properties.mustache b/python-experimental/model_templates/methods_init_properties.mustache new file mode 100644 index 0000000000..447aa22cac --- /dev/null +++ b/python-experimental/model_templates/methods_init_properties.mustache @@ -0,0 +1,76 @@ + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + """{{classname}} - a model defined in OpenAPI""" # noqa: E501 +{{#vars}}{{#-first}} +{{/-first}} + self._{{name}} = None +{{/vars}} + self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} +{{#vars}}{{#-first}} +{{/-first}} +{{#required}} + self.{{name}} = {{name}} +{{/required}} +{{^required}} +{{#isNullable}} + self.{{name}} = {{name}} +{{/isNullable}} +{{^isNullable}} + if {{name}} is not None: + self.{{name}} = ( + {{name}} + ) +{{/isNullable}} +{{/required}} +{{/vars}} +{{#vars}} + + @property + def {{name}}(self): + """Gets the {{name}} of this {{classname}}. # noqa: E501 + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :return: The {{name}} of this {{classname}}. # noqa: E501 + :rtype: {{dataType}} + """ + return self._{{name}} + + @{{name}}.setter + def {{name}}(self, {{name}}): # noqa: E501 + """Sets the {{name}} of this {{classname}}. + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 + :type: {{dataType}} + """ +{{^isNullable}} +{{#required}} + if {{name}} is None: + raise ApiValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 +{{/required}} +{{/isNullable}} +{{#isEnum}} + check_allowed_values( + self.allowed_values, + ('{{name}}',), + {{name}}, + self.validations + ) +{{/isEnum}} +{{#hasValidation}} + check_validations( + self.validations, + ('{{name}}',), + {{name}} + ) +{{/hasValidation}} + + self._{{name}} = ( + {{name}} + ) +{{/vars}} \ No newline at end of file diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache new file mode 100644 index 0000000000..bd1eaddcb4 --- /dev/null +++ b/python-experimental/model_templates/model_normal.mustache @@ -0,0 +1,83 @@ +class {{classname}}(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> python-experimental/model_templates/docstring_allowed }} + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. +{{> python-experimental/model_templates/docstring_openapi_validations }} + """ + +{{> python-experimental/model_templates/classvar_allowed }} + + attribute_map = { +{{#vars}} + '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501 +{{/vars}} + } +{{#discriminator}} + + discriminator_value_class_map = { + {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, + {{/-last}}{{/children}} + } +{{/discriminator}} + +{{> python-experimental/model_templates/classvar_openapi_validations }} + +{{> python-experimental/model_templates/methods_init_properties }} +{{#discriminator}} + def get_real_child_model(self, data): + """Returns the real base class specified by the discriminator""" + discriminator_key = self.attribute_map[self.discriminator] + discriminator_value = data[discriminator_key] + return self.discriminator_value_class_map.get(discriminator_value) + +{{/discriminator}} + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other \ No newline at end of file diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache new file mode 100644 index 0000000000..94ad6336f9 --- /dev/null +++ b/python-experimental/model_templates/model_simple.mustache @@ -0,0 +1,34 @@ +class {{classname}}(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> python-experimental/model_templates/docstring_allowed }} +{{> python-experimental/model_templates/docstring_openapi_validations }} + """ + +{{> python-experimental/model_templates/classvar_allowed }} + +{{> python-experimental/model_templates/classvar_openapi_validations }} + +{{> python-experimental/model_templates/methods_init_properties }} + def to_str(self): + """Returns the string representation of the model""" + return str(self._value) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache new file mode 100644 index 0000000000..c251879b10 --- /dev/null +++ b/python-experimental/model_utils.mustache @@ -0,0 +1,175 @@ +# coding: utf-8 + +{{>partial_header}} +import re + +from {{packageName}}.exceptions import ApiValueError + + +def check_allowed_values(allowed_values, input_variable_path, input_values, + validations): + """Raises an exception if the input_values are not allowed + + Args: + allowed_values (dict): the allowed_values dict + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking to see if they are in allowed_values + validations (dict): the validations dict + """ + min_collection_length = ( + validations.get(input_variable_path, {}).get('min_length') or + validations.get(input_variable_path, {}).get('min_items', 0)) + these_allowed_values = list(allowed_values[input_variable_path].values()) + if (isinstance(input_values, list) + and len(input_values) > min_collection_length + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), + raise ApiValueError( + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (isinstance(input_values, dict) + and len(input_values) > min_collection_length + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) + raise ApiValueError( + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): + raise ApiValueError( + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) + ) + + +def check_validations(validations, input_variable_path, input_values): + """Raises an exception if the input_values are invalid + + Args: + validations (dict): the validation dictionary + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking + """ + current_validations = validations[input_variable_path] + if ('max_length' in current_validations and + len(input_values) > current_validations['max_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) + ) + + if ('min_length' in current_validations and + len(input_values) < current_validations['min_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be greater than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) + ) + + if ('max_items' in current_validations and + len(input_values) > current_validations['max_items']): + raise ApiValueError( + "Invalid value for `%s`, number of items must be less than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) + ) + + if ('min_items' in current_validations and + len(input_values) < current_validations['min_items']): + raise ValueError( + "Invalid value for `%s`, number of items must be greater than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) + ) + + if ('exclusive_maximum' in current_validations and + input_values >= current_validations['exclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_maximum' in current_validations and + input_values > current_validations['inclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) + ) + + if ('exclusive_minimum' in current_validations and + input_values <= current_validations['exclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_minimum' in current_validations and + input_values < current_validations['inclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than or equal " + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) + ) + flags = current_validations.get('regex', {}).get('flags', 0) + if ('regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): + raise ApiValueError( + r"Invalid value for `%s`, must be a follow pattern or equal to " + r"`%s` with flags=`%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'], + flags + ) + ) + + +class ModelSimple(object): + # the parent class of models whose type != object in their swagger/openapi + # spec + pass + + +class ModelNormal(object): + # the parent class of models whose type == object in their swagger/openapi + # spec + pass From ea771c31fd32cf9928b4e4e0b7aaa2c22bdf8e5c Mon Sep 17 00:00:00 2001 From: Pete Savage Date: Wed, 9 Oct 2019 04:16:34 +0100 Subject: [PATCH 051/185] Fixed Readonly Docs for python (#4085) --- model_doc.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_doc.mustache b/model_doc.mustache index 0216a3372c..71c106fdc5 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} {{/vars}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) From 34d64ab00f6f902d8ef795420d094cadbb333df4 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 9 Oct 2019 15:16:22 +0800 Subject: [PATCH 052/185] Fix readonly with isReadOnly (#4102) * fix readonly * update samples --- python-experimental/model_doc.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index b6e1b263fc..16592869b7 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -3,9 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#requiredVars}}{{^defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#readOnly}}[readonly] {{/readOnly}} -{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} -{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{#requiredVars}}{{^defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) From 98bf60846ba40beadea3cd1dc255f32782a2c713 Mon Sep 17 00:00:00 2001 From: Arun Date: Wed, 16 Oct 2019 12:45:14 +0530 Subject: [PATCH 053/185] Skip adding None value in query parameters (#4161) --- api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.mustache b/api.mustache index 590299dc5f..9ed3340627 100644 --- a/api.mustache +++ b/api.mustache @@ -182,7 +182,7 @@ class {{classname}}(object): query_params = [] {{#queryParams}} - if '{{paramName}}' in local_var_params: + if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] is not None: # noqa: E501 query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/queryParams}} From e355121075c7174062db528eb36e7bc9a1c6d5f5 Mon Sep 17 00:00:00 2001 From: Arun Date: Wed, 16 Oct 2019 13:04:22 +0530 Subject: [PATCH 054/185] [python] Remove post_params and body from OPTIONS request (#4163) * Remove post_params and body from OPTIONS * Empty commit to retrigger build --- api_client.mustache | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 768b8d973f..546313cc19 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -379,10 +379,8 @@ class ApiClient(object): return self.rest_client.OPTIONS(url, query_params=query_params, headers=headers, - post_params=post_params, _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + _request_timeout=_request_timeout) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, From 0779caf2d121dca1ff35d0b784e44c710f0cdce5 Mon Sep 17 00:00:00 2001 From: Arun Date: Wed, 16 Oct 2019 13:14:04 +0530 Subject: [PATCH 055/185] [python] Add option to skip client validations (#4137) * Adds options to skip client side validations * Runs petstore.sh * Correct typo in variable name * Consistent code styling * Rerun petstore.sh * Change position of local_vars_configuration * Make code pep8 compliant --- api.mustache | 26 ++++++++++++------------ api_client.mustache | 1 + configuration.mustache | 2 ++ model.mustache | 45 +++++++++++++++++++++++++++++------------- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/api.mustache b/api.mustache index 9ed3340627..f1a110bd47 100644 --- a/api.mustache +++ b/api.mustache @@ -126,8 +126,8 @@ class {{classname}}(object): {{^isNullable}} {{#required}} # verify the required parameter '{{paramName}}' is set - if ('{{paramName}}' not in local_var_params or - local_var_params['{{paramName}}'] is None): + if self.api_client.client_side_validation and ('{{paramName}}' not in local_var_params or # noqa: E501 + local_var_params['{{paramName}}'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 {{/required}} {{/isNullable}} @@ -136,35 +136,35 @@ class {{classname}}(object): {{#allParams}} {{#hasValidation}} {{#maxLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxLength}}): + if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 + len(local_var_params['{{paramName}}']) > {{maxLength}}): # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 {{/maxLength}} {{#minLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minLength}}): + if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 + len(local_var_params['{{paramName}}']) < {{minLength}}): # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 {{/minLength}} {{#maximum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 {{/maximum}} {{#minimum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxItems}}): + if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 + len(local_var_params['{{paramName}}']) > {{maxItems}}): # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 {{/maxItems}} {{#minItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minItems}}): + if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 + len(local_var_params['{{paramName}}']) < {{minItems}}): # noqa: E501 raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 {{/minItems}} {{/hasValidation}} diff --git a/api_client.mustache b/api_client.mustache index 546313cc19..63dd91ebb5 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -72,6 +72,7 @@ class ApiClient(object): self.cookie = cookie # Set default User-Agent. self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' + self.client_side_validation = configuration.client_side_validation def __del__(self): if self._pool: diff --git a/configuration.mustache b/configuration.mustache index 2afcb7478e..9677031a8c 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -149,6 +149,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): self.retries = None """Adding retries to override urllib3 default value 3 """ + # Disable client side validation + self.client_side_validation = True @property def logger_file(self): diff --git a/model.mustache b/model.mustache index 16c8dadbf6..e2c39f3d6b 100644 --- a/model.mustache +++ b/model.mustache @@ -7,6 +7,8 @@ import re # noqa: F401 import six +from {{packageName}}.configuration import Configuration + {{#models}} {{#model}} @@ -51,8 +53,11 @@ class {{classname}}(object): } {{/discriminator}} - def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}, local_vars_configuration=None): # noqa: E501 """{{classname}} - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration {{#vars}}{{#-first}} {{/-first}} self._{{name}} = None @@ -101,7 +106,7 @@ class {{classname}}(object): """ {{^isNullable}} {{#required}} - if {{name}} is None: + if self.local_vars_configuration.client_side_validation and {{name}} is None: # noqa: E501 raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 {{/required}} {{/isNullable}} @@ -109,7 +114,8 @@ class {{classname}}(object): {{#isContainer}} allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 {{#isListContainer}} - if not set({{{name}}}).issubset(set(allowed_values)): + if (self.local_vars_configuration.client_side_validation and + not set({{{name}}}).issubset(set(allowed_values))): raise ValueError( "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 @@ -117,7 +123,8 @@ class {{classname}}(object): ) {{/isListContainer}} {{#isMapContainer}} - if not set({{{name}}}.keys()).issubset(set(allowed_values)): + if (self.local_vars_configuration.client_side_validation and + not set({{{name}}}.keys()).issubset(set(allowed_values))): raise ValueError( "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 @@ -127,7 +134,7 @@ class {{classname}}(object): {{/isContainer}} {{^isContainer}} allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if {{{name}}} not in allowed_values: + if self.local_vars_configuration.client_side_validation and {{{name}}} not in allowed_values: # noqa: E501 raise ValueError( "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 .format({{{name}}}, allowed_values) @@ -137,31 +144,38 @@ class {{classname}}(object): {{^isEnum}} {{#hasValidation}} {{#maxLength}} - if {{name}} is not None and len({{name}}) > {{maxLength}}: + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and len({{name}}) > {{maxLength}}): raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 {{/maxLength}} {{#minLength}} - if {{name}} is not None and len({{name}}) < {{minLength}}: + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and len({{name}}) < {{minLength}}): raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 {{/minLength}} {{#maximum}} - if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}): # noqa: E501 raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 {{/maximum}} {{#minimum}} - if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}): # noqa: E501 raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}})): # noqa: E501 raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} - if {{name}} is not None and len({{name}}) > {{maxItems}}: + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and len({{name}}) > {{maxItems}}): raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 {{/maxItems}} {{#minItems}} - if {{name}} is not None and len({{name}}) < {{minItems}}: + if (self.local_vars_configuration.client_side_validation and + {{name}} is not None and len({{name}}) < {{minItems}}): raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 {{/minItems}} {{/hasValidation}} @@ -215,10 +229,13 @@ class {{classname}}(object): if not isinstance(other, {{classname}}): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, {{classname}}): + return True + + return self.to_dict() != other.to_dict() {{/model}} {{/models}} From c93605affafee5e042029859da9c06c8042e6f23 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 17 Oct 2019 02:34:04 +0800 Subject: [PATCH 056/185] [Python] Minor fix to code format (#4172) * test python e501 fix * 2 spaces * fix format with noqa: E501 * fix format, update samples --- model.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.mustache b/model.mustache index e2c39f3d6b..17264bb46b 100644 --- a/model.mustache +++ b/model.mustache @@ -115,7 +115,7 @@ class {{classname}}(object): allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 {{#isListContainer}} if (self.local_vars_configuration.client_side_validation and - not set({{{name}}}).issubset(set(allowed_values))): + not set({{{name}}}).issubset(set(allowed_values))): # noqa: E501 raise ValueError( "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 @@ -124,7 +124,7 @@ class {{classname}}(object): {{/isListContainer}} {{#isMapContainer}} if (self.local_vars_configuration.client_side_validation and - not set({{{name}}}.keys()).issubset(set(allowed_values))): + not set({{{name}}}.keys()).issubset(set(allowed_values))): # noqa: E501 raise ValueError( "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 From cc11b6ed125f2912b98d10699ad1e3eb7ffa4df1 Mon Sep 17 00:00:00 2001 From: Arun Date: Thu, 24 Oct 2019 14:58:29 +0530 Subject: [PATCH 057/185] [python] Add ability to get allowed values (#4138) * Add function to get list of allowed values * [python] Add function to get list of allowed values * Remove temporary variable * Remove static method and use a variable * Remove classname --- model.mustache | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model.mustache b/model.mustache index 17264bb46b..70f6e7489a 100644 --- a/model.mustache +++ b/model.mustache @@ -27,6 +27,10 @@ class {{classname}}(object): {{/-last}} {{/enumVars}}{{/allowableValues}} +{{#allowableValues}} + allowable_values = [{{#enumVars}}{{name}}{{^-last}}, {{/-last}}{{/enumVars}}] # noqa: E501 + +{{/allowableValues}} """ Attributes: openapi_types (dict): The key is attribute name From 62480238733d834592f3b98e379f6ecc88d2ed30 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 28 Oct 2019 06:24:31 -0700 Subject: [PATCH 058/185] [Python-experimental] types now classes, adds additionalProperties handling (#4154) * Changes python-experimental types to classes, adds additionalalproperties handling Adds model_utils update, updates model.mustache Updates api.mustache and uses model_to_dict in model_normal.mustache Updates requirements.mustache for PythonClientExperimental Passes through check_type when deserializing models Converts types from strings to classes in PythonClientExperimentalCodegen.java and PythonTest.java Creates PythonClientExperimentalTest.java Updates toInstantiationType to use ModelUtils.xxx Corrects docstring descriptions of response_type Updates python-experimental typing, partially fixes deserialization tests Adds fixes for some of the deserialization tests Fixes deserialization tests Switches model teplates to use allVars so allof props will be included Fixes tests.test_enum_arrays Fixes test_to_str Adds additional_properties_type, fixes teast_todict in test_map_test.py Correctly check the type of _request_timeout values Fixes test_upload_file test Turns off coercion when instantiating model types with client data Updates file handling to input and output an open file object Fixes linting errors Adds fixes for python2 tests, linting fixes Adds additionalproperties to docs + tests Regenerates python-experimatal client * Regenerates python-experimental client * Updates windows python-experimental bat file * Fixes addModelImport so client generation will work with the v2 spec * Reverts PythonClientCodegen.java * Acutally revert PythonClientCodegen.java * Updates the sample example for file_type in docs * Silences line too long error for python models so CI tests pass * Fixes handling of file uploads, adds tests for uploading files * Removes comment * Fixes mock installation in python2 * Limit mock addition to python-experimental test requirements only * Removes SmartBear copyright line --- python-experimental/api.mustache | 121 ++- python-experimental/api_client.mustache | 327 +++----- python-experimental/model.mustache | 21 +- python-experimental/model_doc.mustache | 18 +- .../model_templates/classvar_allowed.mustache | 6 +- .../classvar_openapi_validations.mustache | 43 +- .../docstring_openapi_validations.mustache | 4 +- .../methods_init_properties.mustache | 170 ++-- .../model_templates/model_normal.mustache | 56 +- .../model_templates/model_simple.mustache | 16 +- python-experimental/model_utils.mustache | 735 +++++++++++++++++- python-experimental/requirements.mustache | 6 + python-experimental/setup.mustache | 45 ++ .../test-requirements.mustache | 13 + requirements.mustache | 1 + 15 files changed, 1194 insertions(+), 388 deletions(-) create mode 100644 python-experimental/requirements.mustache create mode 100644 python-experimental/setup.mustache create mode 100644 python-experimental/test-requirements.mustache diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index dd650b37d7..651559cf4f 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -14,10 +14,20 @@ from {{packageName}}.exceptions import ( ApiTypeError, ApiValueError ) -from {{packageName}}.model_utils import ( +from {{packageName}}.model_utils import ( # noqa: F401 check_allowed_values, - check_validations + check_validations, + date, + datetime, + file_type, + int, + none_type, + str, + validate_and_convert_types ) +{{#imports}} +{{{import}}} +{{/imports}} {{#operations}} @@ -51,24 +61,51 @@ class {{classname}}(object): >>> result = thread.get() :param async_req bool: execute request asynchronously + Default is False. {{#allParams}} :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} {{/allParams}} :param _return_http_data_only: response data without head status - code and headers + code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. + Default is None. + :param _check_input_type: boolean specifying if type checking + should be done one the data sent to the server. + Default is True. + :param _check_return_type: boolean specifying if type checking + should be done one the data received from the server. + Default is True. + :param _host_index: integer specifying the index of the server + that we want to use. + Default is 0. :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} If the method is called asynchronously, returns the request thread. """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index', 0) {{#requiredParams}} kwargs['{{paramName}}'] = {{paramName}} {{/requiredParams}} @@ -76,7 +113,7 @@ class {{classname}}(object): self.{{operationId}} = Endpoint( settings={ - 'response_type': {{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, + 'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}}, {{#authMethods}} {{#-first}} 'auth': [ @@ -178,7 +215,7 @@ class {{classname}}(object): }, 'openapi_types': { {{#allParams}} - '{{paramName}}': '{{dataType}}', + '{{paramName}}': ({{{dataType}}},), {{/allParams}} }, 'attribute_map': { @@ -237,7 +274,7 @@ class Endpoint(object): Args: settings (dict): see below key value pairs - 'response_type' (str): response type + 'response_type' (tuple/None): response type 'auth' (list): a list of auth type keys 'endpoint_path' (str): the endpoint path 'operation_id' (str): endpoint string identifier @@ -273,11 +310,24 @@ class Endpoint(object): '_host_index', '_preload_content', '_request_timeout', - '_return_http_data_only' + '_return_http_data_only', + '_check_input_type', + '_check_return_type' ]) + self.params_map['nullable'].extend(['_request_timeout']) self.validations = root_map['validations'] self.allowed_values = root_map['allowed_values'] self.openapi_types = root_map['openapi_types'] + extra_types = { + 'async_req': (bool,), + '_host_index': (int,), + '_preload_content': (bool,), + '_request_timeout': (none_type, int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) + } + self.openapi_types.update(extra_types) self.attribute_map = root_map['attribute_map'] self.location_map = root_map['location_map'] self.collection_format_map = root_map['collection_format_map'] @@ -291,8 +341,7 @@ class Endpoint(object): check_allowed_values( self.allowed_values, (param,), - kwargs[param], - self.validations + kwargs[param] ) for param in self.params_map['validation']: @@ -303,6 +352,20 @@ class Endpoint(object): kwargs[param] ) + if kwargs['_check_input_type'] is False: + return + + for key, value in six.iteritems(kwargs): + fixed_val = validate_and_convert_types( + value, + self.openapi_types[key], + [key], + False, + kwargs['_check_input_type'], + configuration=self.api_client.configuration + ) + kwargs[key] = fixed_val + def __gather_params(self, kwargs): params = { 'body': None, @@ -316,14 +379,20 @@ class Endpoint(object): for param_name, param_value in six.iteritems(kwargs): param_location = self.location_map.get(param_name) + if param_location is None: + continue if param_location: if param_location == 'body': params['body'] = param_value continue base_name = self.attribute_map[param_name] if (param_location == 'form' and - self.openapi_types[param_name] == 'file'): - param_location = 'file' + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): + # param_value is already a list + params['file'][param_name] = param_value elif param_location in {'form', 'query'}: param_value_full = (base_name, param_value) params[param_location].append(param_value_full) @@ -348,20 +417,15 @@ class Endpoint(object): def call_with_http_info(self, **kwargs): - if kwargs.get('_host_index') and self.settings['servers']: - _host_index = kwargs.get('_host_index') - try: - _host = self.settings['servers'][_host_index] - except IndexError: + try: + _host = self.settings['servers'][kwargs['_host_index']] + except IndexError: + if self.settings['servers']: raise ApiValueError( "Invalid host index. Must be 0 <= index < %s" % len(self.settings['servers']) ) - else: - try: - _host = self.settings['servers'][0] - except IndexError: - _host = None + _host = None for key, value in six.iteritems(kwargs): if key not in self.params_map['all']: @@ -370,7 +434,11 @@ class Endpoint(object): " to method `%s`" % (key, self.settings['operation_id']) ) - if key not in self.params_map['nullable'] and value is None: + # only throw this nullable ApiValueError if _check_input_type + # is False, if _check_input_type==True we catch this case + # in self.__validate_inputs + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): raise ApiValueError( "Value may not be None for non-nullable parameter `%s`" " when calling `%s`" % @@ -409,9 +477,10 @@ class Endpoint(object): files=params['file'], response_type=self.settings['response_type'], auth_settings=self.settings['auth'], - async_req=kwargs.get('async_req'), - _return_http_data_only=kwargs.get('_return_http_data_only'), - _preload_content=kwargs.get('_preload_content', True), - _request_timeout=kwargs.get('_request_timeout'), + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], _host=_host, collection_formats=params['collection_format']) diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 0f02b445df..aec1ef3753 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -2,14 +2,10 @@ {{>partial_header}} from __future__ import absolute_import -import datetime -import inspect import json import mimetypes from multiprocessing.pool import ThreadPool import os -import re -import tempfile # python 2 and python 3 compatibility library import six @@ -18,14 +14,20 @@ from six.moves.urllib.parse import quote import tornado.gen {{/tornado}} -import {{modelPackage}} from {{packageName}} import rest from {{packageName}}.configuration import Configuration +from {{packageName}}.exceptions import ApiValueError from {{packageName}}.model_utils import ( ModelNormal, - ModelSimple + ModelSimple, + date, + datetime, + deserialize_file, + file_type, + model_to_dict, + str, + validate_and_convert_types ) -from {{packageName}}.exceptions import ApiValueError class ApiClient(object): @@ -50,17 +52,11 @@ class ApiClient(object): to the API. More threads means more concurrent API requests. """ - PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, - } + # six.binary_type python2=str, python3=bytes + # six.text_type python2=unicode, python3=str + PRIMITIVE_TYPES = ( + (float, bool, six.binary_type, six.text_type) + six.integer_types + ) _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, @@ -113,7 +109,8 @@ class ApiClient(object): query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + _preload_content=True, _request_timeout=None, _host=None, + _check_type=None): config = self.configuration @@ -180,7 +177,11 @@ class ApiClient(object): if _preload_content: # deserialize response data if response_type: - return_data = self.deserialize(response_data, response_type) + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) else: return_data = None @@ -223,93 +224,73 @@ class ApiClient(object): elif isinstance(obj, tuple): return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) - elif isinstance(obj, (datetime.datetime, datetime.date)): + elif isinstance(obj, (datetime, date)): return obj.isoformat() if isinstance(obj, dict): obj_dict = obj elif isinstance(obj, ModelNormal): - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. + # Convert model obj to dict # Convert attribute name to json key in - # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None} + # model definition for request + obj_dict = model_to_dict(obj, serialize=True) elif isinstance(obj, ModelSimple): return self.sanitize_for_serialization(obj.value) return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)} - def deserialize(self, response, response_type): + def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. :param response: RESTResponse object to be deserialized. - :param response_type: class literal for - deserialized object, or string of class name. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param _check_type: boolean, whether to check the types of the data + received from the server :return: deserialized object. """ # handle file downloading # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) + if response_type == (file_type,): + content_disposition = response.getheader("Content-Disposition") + return deserialize_file(response.data, self.configuration, + content_disposition=content_disposition) # fetch data from response object try: - data = json.loads(response.data) + received_data = json.loads(response.data) except ValueError: - data = response.data - - return self.__deserialize(data, response_type) - - def __deserialize(self, data, klass): - """Deserializes dict, list, str into an object. - - :param data: dict, list or str. - :param klass: class literal, or string of class name. - - :return: object. - """ - if data is None: - return None - - if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] - - if klass.startswith('dict('): - sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr({{modelPackage}}, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == datetime.date: - return self.__deserialize_date(data) - elif klass == datetime.datetime: - return self.__deserialize_datatime(data) - else: - return self.__deserialize_model(data, klass) + received_data = response.data + + # store our data under the key of 'received_data' so users have some + # context if they are deserializing a string and the data type is wrong + deserialized_data = validate_and_convert_types( + received_data, + response_type, + ['received_data'], + True, + _check_type, + configuration=self.configuration + ) + return deserialized_data def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + _preload_content=True, _request_timeout=None, _host=None, + _check_type=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -324,9 +305,18 @@ class ApiClient(object): :param post_params dict: Request post form parameters, for `application/x-www-form-urlencoded`, `multipart/form-data`. :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param files dict: key -> field name, value -> a list of open file + objects for `multipart/form-data`. :param async_req bool: execute request asynchronously :param _return_http_data_only: response data without head status code and headers @@ -339,6 +329,8 @@ class ApiClient(object): number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. + :param _check_type: boolean describing if the data back from the server + should have its type checked. :return: If async_req parameter is True, the request will be called asynchronously. @@ -352,7 +344,8 @@ class ApiClient(object): body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout, _host) + _preload_content, _request_timeout, _host, + _check_type) else: thread = self.pool.apply_async(self.__call_api, (resource_path, method, path_params, query_params, @@ -363,7 +356,7 @@ class ApiClient(object): collection_formats, _preload_content, _request_timeout, - _host)) + _host, _check_type)) return thread def request(self, method, url, query_params=None, headers=None, @@ -460,24 +453,34 @@ class ApiClient(object): def files_parameters(self, files=None): """Builds form parameters. - :param files: File parameters. - :return: Form parameters with files. + :param files: None or a dict with key=param_name and + value is a list of open file objects + :return: List of tuples of form parameters with file data """ - params = [] + if files is None: + return [] - if files: - for k, v in six.iteritems(files): - if not v: + params = [] + for param_name, file_instances in six.iteritems(files): + if file_instances is None: + # if the file field is nullable, skip None values + continue + for file_instance in file_instances: + if file_instance is None: + # if the file field is nullable, skip None values continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) + if file_instance.closed is True: + raise ApiValueError( + "Cannot read a closed file. The passed in file_type " + "for %s must be open." % param_name + ) + filename = os.path.basename(file_instance.name) + filedata = file_instance.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([param_name, tuple([filename, filedata, mimetype])])) + file_instance.close() return params @@ -538,133 +541,3 @@ class ApiClient(object): raise ApiValueError( 'Authentication token must be in `query` or `header`' ) - - def __deserialize_file(self, response): - """Deserializes body to file - - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - :param response: RESTResponse. - :return: file path. - """ - fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) - os.close(fd) - os.remove(path) - - content_disposition = response.getheader("Content-Disposition") - if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "wb") as f: - f.write(response.data) - - return path - - def __deserialize_primitive(self, data, klass): - """Deserializes string to primitive type. - - :param data: str. - :param klass: class literal. - - :return: int, long, float, str, bool. - """ - try: - return klass(data) - except UnicodeEncodeError: - return six.text_type(data) - except TypeError: - return data - except ValueError as exc: - raise ApiValueError(str(exc)) - - def __deserialize_object(self, value): - """Return an original value. - - :return: object. - """ - return value - - def __deserialize_date(self, string): - """Deserializes string to date. - - :param string: str. - :return: date. - """ - try: - from dateutil.parser import parse - return parse(string).date() - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) - ) - - def __deserialize_datatime(self, string): - """Deserializes string to datetime. - - The string should be in iso8601 datetime format. - - :param string: str. - :return: datetime. - """ - try: - from dateutil.parser import parse - return parse(string) - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) - ) - - def __deserialize_model(self, data, klass): - """Deserializes list or dict to model. - - :param data: dict, list. - :param klass: class literal, ModelSimple or ModelNormal - :return: model object. - """ - - if issubclass(klass, ModelSimple): - value = self.__deserialize(data, klass.openapi_types['value']) - return klass(value) - - # code to handle ModelNormal - used_data = data - if not isinstance(data, (list, dict)): - used_data = [data] - keyword_args = {} - positional_args = [] - if klass.openapi_types is not None: - for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in used_data): - value = used_data[klass.attribute_map[attr]] - keyword_args[attr] = self.__deserialize(value, attr_type) - end_index = None - argspec = inspect.getargspec(getattr(klass, '__init__')) - if argspec.defaults: - end_index = -len(argspec.defaults) - required_positional_args = argspec.args[1:end_index] - for index, req_positional_arg in enumerate(required_positional_args): - if keyword_args and req_positional_arg in keyword_args: - positional_args.append(keyword_args[req_positional_arg]) - del keyword_args[req_positional_arg] - elif (not keyword_args and index < len(used_data) and - isinstance(used_data, list)): - positional_args.append(used_data[index]) - instance = klass(*positional_args, **keyword_args) - if hasattr(instance, 'get_real_child_model'): - klass_name = instance.get_real_child_model(data) - if klass_name: - instance = self.__deserialize(data, klass_name) - return instance diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 082f4bddc4..2513d6b3f8 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -7,14 +7,29 @@ import re # noqa: F401 import six # noqa: F401 -from {{packageName}}.exceptions import ApiValueError # noqa: F401 +from {{packageName}}.exceptions import ( # noqa: F401 + ApiKeyError, + ApiTypeError, + ApiValueError, +) from {{packageName}}.model_utils import ( # noqa: F401 ModelNormal, ModelSimple, check_allowed_values, - check_validations + check_validations, + date, + datetime, + file_type, + get_simple_class, + int, + model_to_dict, + none_type, + str, + type_error_message, + validate_and_convert_types ) - +{{#models}}{{#model}}{{#imports}}{{.}} +{{/imports}}{{/model}}{{/models}} {{#models}} {{#model}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index 16592869b7..70b2339985 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -3,10 +3,22 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#requiredVars}}{{^defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} -{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} -{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{#requiredVars}} +{{^defaultValue}} +**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +{{/defaultValue}} +{{/requiredVars}} +{{#requiredVars}} +{{#defaultValue}} +**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +{{/defaultValue}} +{{/requiredVars}} +{{#optionalVars}} +**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} +{{#additionalPropertiesType}} +**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] +{{/additionalPropertiesType}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/python-experimental/model_templates/classvar_allowed.mustache b/python-experimental/model_templates/classvar_allowed.mustache index 6ed39521f6..2414be114a 100644 --- a/python-experimental/model_templates/classvar_allowed.mustache +++ b/python-experimental/model_templates/classvar_allowed.mustache @@ -1,5 +1,5 @@ allowed_values = { -{{#vars}} +{{#allVars}} {{#isEnum}} ('{{name}}',): { {{#isNullable}} @@ -7,10 +7,10 @@ {{/isNullable}} {{#allowableValues}} {{#enumVars}} - '{{name}}': {{{value}}}{{^-last}},{{/-last}} + '{{name}}': {{{value}}}, {{/enumVars}} {{/allowableValues}} }, {{/isEnum}} -{{/vars}} +{{/allVars}} } \ No newline at end of file diff --git a/python-experimental/model_templates/classvar_openapi_validations.mustache b/python-experimental/model_templates/classvar_openapi_validations.mustache index 7e89f83ef2..1cc7b58550 100644 --- a/python-experimental/model_templates/classvar_openapi_validations.mustache +++ b/python-experimental/model_templates/classvar_openapi_validations.mustache @@ -1,25 +1,42 @@ openapi_types = { -{{#vars}} - '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} -{{/vars}} +{{#allVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/allVars}} } validations = { -{{#vars}} +{{#allVars}} {{#hasValidation}} ('{{name}}',): { {{#maxLength}} - 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} - 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} - 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} - 'min_items': {{minItems}},{{/minItems}}{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} 'regex': { 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - },{{/pattern}} + }, +{{/pattern}} }, {{/hasValidation}} -{{/vars}} - } \ No newline at end of file +{{/allVars}} + } + + additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} + + discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} \ No newline at end of file diff --git a/python-experimental/model_templates/docstring_openapi_validations.mustache b/python-experimental/model_templates/docstring_openapi_validations.mustache index 46dc1afefc..03eec953f3 100644 --- a/python-experimental/model_templates/docstring_openapi_validations.mustache +++ b/python-experimental/model_templates/docstring_openapi_validations.mustache @@ -4,4 +4,6 @@ and the for var_name this is (var_name,). The value is a dict that stores validations for max_length, min_length, max_items, min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, - inclusive_minimum, and regex. \ No newline at end of file + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. \ No newline at end of file diff --git a/python-experimental/model_templates/methods_init_properties.mustache b/python-experimental/model_templates/methods_init_properties.mustache index 447aa22cac..dab632efab 100644 --- a/python-experimental/model_templates/methods_init_properties.mustache +++ b/python-experimental/model_templates/methods_init_properties.mustache @@ -1,76 +1,126 @@ - def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 - """{{classname}} - a model defined in OpenAPI""" # noqa: E501 -{{#vars}}{{#-first}} -{{/-first}} - self._{{name}} = None -{{/vars}} - self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} -{{#vars}}{{#-first}} -{{/-first}} -{{#required}} - self.{{name}} = {{name}} -{{/required}} -{{^required}} -{{#isNullable}} - self.{{name}} = {{name}} -{{/isNullable}} -{{^isNullable}} - if {{name}} is not None: - self.{{name}} = ( - {{name}} + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} +{{/hasMore}}{{/requiredVars}} + Keyword Args:{{#requiredVars}}{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done.{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + """ + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + +{{#requiredVars}} + self.__set_item('{{name}}', {{name}}) +{{/requiredVars}} + for var_name, var_value in six.iteritems(kwargs): + self.__set_item(var_name, var_value) + + def __set_item(self, name, value): + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._from_server, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value ) -{{/isNullable}} -{{/required}} -{{/vars}} -{{#vars}} + self._data_store[name] = value + + def __get_item(self, name): + if name in self._data_store: + return self._data_store[name] + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + [name] + ) + + def __setitem__(self, name, value): + """this allows us to set values with instance[field_name] = val""" + self.__set_item(name, value) + + def __getitem__(self, name): + """this allows us to get a value with val = instance[field_name]""" + return self.__get_item(name) +{{#allVars}} @property def {{name}}(self): """Gets the {{name}} of this {{classname}}. # noqa: E501 - {{#description}} {{{description}}} # noqa: E501 {{/description}} - :return: The {{name}} of this {{classname}}. # noqa: E501 - :rtype: {{dataType}} + Returns: + ({{{dataType}}}): The {{name}} of this {{classname}}. # noqa: E501 """ - return self._{{name}} + return self.__get_item('{{name}}') @{{name}}.setter - def {{name}}(self, {{name}}): # noqa: E501 - """Sets the {{name}} of this {{classname}}. - + def {{name}}(self, value): + """Sets the {{name}} of this {{classname}}. # noqa: E501 {{#description}} {{{description}}} # noqa: E501 {{/description}} - - :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type: {{dataType}} """ -{{^isNullable}} -{{#required}} - if {{name}} is None: - raise ApiValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 -{{/required}} -{{/isNullable}} -{{#isEnum}} - check_allowed_values( - self.allowed_values, - ('{{name}}',), - {{name}}, - self.validations - ) -{{/isEnum}} -{{#hasValidation}} - check_validations( - self.validations, - ('{{name}}',), - {{name}} - ) -{{/hasValidation}} - - self._{{name}} = ( - {{name}} - ) -{{/vars}} \ No newline at end of file + return self.__set_item('{{name}}', value) +{{/allVars}} \ No newline at end of file diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache index bd1eaddcb4..c4e707e036 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/python-experimental/model_templates/model_normal.mustache @@ -16,14 +16,14 @@ class {{classname}}(ModelNormal): {{> python-experimental/model_templates/classvar_allowed }} attribute_map = { -{{#vars}} +{{#allVars}} '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501 -{{/vars}} +{{/allVars}} } {{#discriminator}} discriminator_value_class_map = { - {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, + {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}{{^-last}}, {{/-last}}{{/children}} } {{/discriminator}} @@ -32,36 +32,19 @@ class {{classname}}(ModelNormal): {{> python-experimental/model_templates/methods_init_properties }} {{#discriminator}} - def get_real_child_model(self, data): - """Returns the real base class specified by the discriminator""" - discriminator_key = self.attribute_map[self.discriminator] + @classmethod + def get_real_child_model(cls, data): + """Returns the real base class specified by the discriminator + We assume that data has javascript keys + """ + discriminator_key = cls.attribute_map[cls.discriminator] discriminator_value = data[discriminator_key] - return self.discriminator_value_class_map.get(discriminator_value) + return cls.discriminator_value_class_map.get(discriminator_value) {{/discriminator}} def to_dict(self): """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result + return model_to_dict(self, serialize=False) def to_str(self): """Returns the string representation of the model""" @@ -76,7 +59,22 @@ class {{classname}}(ModelNormal): if not isinstance(other, {{classname}}): return False - return self.__dict__ == other.__dict__ + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in six.iteritems(self._data_store): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if (not six.PY3 and + len(types) == 2 and unicode in types): # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True def __ne__(self, other): """Returns true if both objects are not equal""" diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index 94ad6336f9..b5939d926c 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -16,7 +16,7 @@ class {{classname}}(ModelSimple): {{> python-experimental/model_templates/methods_init_properties }} def to_str(self): """Returns the string representation of the model""" - return str(self._value) + return str(self.value) def __repr__(self): """For `print` and `pprint`""" @@ -27,7 +27,19 @@ class {{classname}}(ModelSimple): if not isinstance(other, {{classname}}): return False - return self.__dict__ == other.__dict__ + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True def __ne__(self, other): """Returns true if both objects are not equal""" diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index c251879b10..101b5466c3 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -1,13 +1,162 @@ # coding: utf-8 {{>partial_header}} + +import copy +from datetime import date, datetime # noqa: F401 +import inspect +import os import re +import tempfile + +from dateutil.parser import parse +import six + +from {{packageName}}.exceptions import ( + ApiKeyError, + ApiTypeError, + ApiValueError, +) + +none_type = type(None) +if six.PY3: + import io + file_type = io.IOBase + # these are needed for when other modules import str and int from here + str = str + int = int +else: + file_type = file # noqa: F821 + str_py2 = str + unicode_py2 = unicode # noqa: F821 + long_py2 = long # noqa: F821 + int_py2 = int + # this requires that the future library is installed + from builtins import int, str + + +class OpenApiModel(object): + """The base class for all OpenAPIModels""" + + +class ModelSimple(OpenApiModel): + """the parent class of models whose type != object in their + swagger/openapi""" -from {{packageName}}.exceptions import ApiValueError +class ModelNormal(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi""" -def check_allowed_values(allowed_values, input_variable_path, input_values, - validations): + +COERCION_INDEX_BY_TYPE = { + ModelNormal: 0, + ModelSimple: 1, + none_type: 2, + list: 3, + dict: 4, + float: 5, + int: 6, + bool: 7, + datetime: 8, + date: 9, + str: 10, + file_type: 11, +} + +# these are used to limit what type conversions we try to do +# when we have a valid type already and we want to try converting +# to another type +UPCONVERSION_TYPE_PAIRS = ( + (str, datetime), + (str, date), + (list, ModelNormal), + (dict, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), +) + +COERCIBLE_TYPE_PAIRS = { + False: ( # client instantiation of a model with client data + # (dict, ModelNormal), + # (list, ModelNormal), + # (str, ModelSimple), + # (int, ModelSimple), + # (float, ModelSimple), + # (list, ModelSimple), + # (str, int), + # (str, float), + # (str, datetime), + # (str, date), + # (int, str), + # (float, str), + ), + True: ( # server -> client data + (dict, ModelNormal), + (list, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), + # (str, int), + # (str, float), + (str, datetime), + (str, date), + # (int, str), + # (float, str), + (str, file_type) + ), +} + + +def get_simple_class(input_value): + """Returns an input_value's simple class that we will use for type checking + Python2: + float and int will return int, where int is the python3 int backport + str and unicode will return str, where str is the python3 str backport + Note: float and int ARE both instances of int backport + Note: str_py2 and unicode_py2 are NOT both instances of str backport + + Args: + input_value (class/class_instance): the item for which we will return + the simple class + """ + if isinstance(input_value, type): + # input_value is a class + return input_value + elif isinstance(input_value, tuple): + return tuple + elif isinstance(input_value, list): + return list + elif isinstance(input_value, dict): + return dict + elif isinstance(input_value, none_type): + return none_type + elif isinstance(input_value, file_type): + return file_type + elif isinstance(input_value, bool): + # this must be higher than the int check because + # isinstance(True, int) == True + return bool + elif isinstance(input_value, int): + # for python2 input_value==long_instance -> return int + # where int is the python3 int backport + return int + elif isinstance(input_value, datetime): + # this must be higher than the date check because + # isinstance(datetime_instance, date) == True + return datetime + elif isinstance(input_value, date): + return date + elif (six.PY2 and isinstance(input_value, (str_py2, unicode_py2, str)) or + isinstance(input_value, str)): + return str + return type(input_value) + + +def check_allowed_values(allowed_values, input_variable_path, input_values): """Raises an exception if the input_values are not allowed Args: @@ -15,14 +164,9 @@ def check_allowed_values(allowed_values, input_variable_path, input_values, input_variable_path (tuple): the path to the input variable input_values (list/str/int/float/date/datetime): the values that we are checking to see if they are in allowed_values - validations (dict): the validations dict """ - min_collection_length = ( - validations.get(input_variable_path, {}).get('min_length') or - validations.get(input_variable_path, {}).get('min_items', 0)) these_allowed_values = list(allowed_values[input_variable_path].values()) if (isinstance(input_values, list) - and len(input_values) > min_collection_length and not set(input_values).issubset( set(these_allowed_values))): invalid_values = ", ".join( @@ -36,7 +180,6 @@ def check_allowed_values(allowed_values, input_variable_path, input_values, ) ) elif (isinstance(input_values, dict) - and len(input_values) > min_collection_length and not set( input_values.keys()).issubset(set(these_allowed_values))): invalid_values = ", ".join( @@ -111,8 +254,21 @@ def check_validations(validations, input_variable_path, input_values): ) ) + items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum') + if (any(item in current_validations for item in items)): + if isinstance(input_values, list): + max_val = max(input_values) + min_val = min(input_values) + elif isinstance(input_values, dict): + max_val = max(input_values.values()) + min_val = min(input_values.values()) + else: + max_val = input_values + min_val = input_values + if ('exclusive_maximum' in current_validations and - input_values >= current_validations['exclusive_maximum']): + max_val >= current_validations['exclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than `%s`" % ( input_variable_path[0], @@ -121,7 +277,7 @@ def check_validations(validations, input_variable_path, input_values): ) if ('inclusive_maximum' in current_validations and - input_values > current_validations['inclusive_maximum']): + max_val > current_validations['inclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than or equal to " "`%s`" % ( @@ -131,7 +287,7 @@ def check_validations(validations, input_variable_path, input_values): ) if ('exclusive_minimum' in current_validations and - input_values <= current_validations['exclusive_minimum']): + min_val <= current_validations['exclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than `%s`" % ( @@ -141,7 +297,7 @@ def check_validations(validations, input_variable_path, input_values): ) if ('inclusive_minimum' in current_validations and - input_values < current_validations['inclusive_minimum']): + min_val < current_validations['inclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than or equal " "to `%s`" % ( @@ -163,13 +319,550 @@ def check_validations(validations, input_variable_path, input_values): ) -class ModelSimple(object): - # the parent class of models whose type != object in their swagger/openapi - # spec - pass +def order_response_types(required_types): + """Returns the required types sorted in coercion order + + Args: + required_types (list/tuple): collection of classes or instance of + list or dict with classs information inside it + + Returns: + (list): coercion order sorted collection of classes or instance + of list or dict with classs information inside it + """ + + def index_getter(class_or_instance): + if isinstance(class_or_instance, list): + return COERCION_INDEX_BY_TYPE[list] + elif isinstance(class_or_instance, dict): + return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelNormal)): + return COERCION_INDEX_BY_TYPE[ModelNormal] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelSimple)): + return COERCION_INDEX_BY_TYPE[ModelSimple] + return COERCION_INDEX_BY_TYPE[class_or_instance] + + sorted_types = sorted( + required_types, + key=lambda class_or_instance: index_getter(class_or_instance) + ) + return sorted_types + + +def remove_uncoercible(required_types_classes, current_item, from_server, + must_convert=True): + """Only keeps the type conversions that are possible + + Args: + required_types_classes (tuple): tuple of classes that are required + these should be ordered by COERCION_INDEX_BY_TYPE + from_server (bool): a boolean of whether the data is from the server + if false, the data is from the client + current_item (any): the current item to be converted + + Keyword Args: + must_convert (bool): if True the item to convert is of the wrong + type and we want a big list of coercibles + if False, we want a limited list of coercibles + + Returns: + (list): the remaining coercible required types, classes only + """ + current_type_simple = get_simple_class(current_item) + + results_classes = [] + for required_type_class in required_types_classes: + # convert our models to OpenApiModel + required_type_class_simplified = required_type_class + if isinstance(required_type_class_simplified, type): + if issubclass(required_type_class_simplified, ModelNormal): + required_type_class_simplified = ModelNormal + elif issubclass(required_type_class_simplified, ModelSimple): + required_type_class_simplified = ModelSimple + + if required_type_class_simplified == current_type_simple: + # don't consider converting to one's own class + continue + + class_pair = (current_type_simple, required_type_class_simplified) + if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[from_server]: + results_classes.append(required_type_class) + elif class_pair in UPCONVERSION_TYPE_PAIRS: + results_classes.append(required_type_class) + return results_classes + + +def get_required_type_classes(required_types_mixed): + """Converts the tuple required_types into a tuple and a dict described + below + + Args: + required_types_mixed (tuple/list): will contain either classes or + instance of list or dict + + Returns: + (valid_classes, dict_valid_class_to_child_types_mixed): + valid_classes (tuple): the valid classes that the current item + should be + dict_valid_class_to_child_types_mixed (doct): + valid_class (class): this is the key + child_types_mixed (list/dict/tuple): describes the valid child + types + """ + valid_classes = [] + child_req_types_by_current_type = {} + for required_type in required_types_mixed: + if isinstance(required_type, list): + valid_classes.append(list) + child_req_types_by_current_type[list] = required_type + elif isinstance(required_type, tuple): + valid_classes.append(tuple) + child_req_types_by_current_type[tuple] = required_type + elif isinstance(required_type, dict): + valid_classes.append(dict) + child_req_types_by_current_type[dict] = required_type[str] + else: + valid_classes.append(required_type) + return tuple(valid_classes), child_req_types_by_current_type + + +def change_keys_js_to_python(input_dict, model_class): + """ + Converts from javascript_key keys in the input_dict to python_keys in + the output dict using the mapping in model_class + """ + + output_dict = {} + reversed_attr_map = {value: key for key, value in + six.iteritems(model_class.attribute_map)} + for javascript_key, value in six.iteritems(input_dict): + python_key = reversed_attr_map.get(javascript_key) + if python_key is None: + # if the key is unknown, it is in error or it is an + # additionalProperties variable + python_key = javascript_key + output_dict[python_key] = value + return output_dict + + +def get_type_error(var_value, path_to_item, valid_classes, key_type=False): + error_msg = type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type + ) + + +def deserialize_primitive(data, klass, path_to_item): + """Deserializes string to primitive type. + + :param data: str/int/float + :param klass: str/class the class to convert to + + :return: int, float, str, bool, date, datetime + """ + additional_message = "" + try: + if klass in {datetime, date}: + additional_message = ( + "If you need your parameter to have a fallback " + "string value, please set its type as `type: {}` in your " + "spec. That allows the value to be any type. " + ) + if klass == datetime: + if len(data) < 8: + raise ValueError("This is not a datetime") + # The string should be in iso8601 datetime format. + parsed_datetime = parse(data) + date_only = ( + parsed_datetime.hour == 0 and + parsed_datetime.minute == 0 and + parsed_datetime.second == 0 and + parsed_datetime.tzinfo is None and + 8 <= len(data) <= 10 + ) + if date_only: + raise ValueError("This is a date, not a datetime") + return parsed_datetime + elif klass == date: + if len(data) < 8: + raise ValueError("This is not a date") + return parse(data).date() + else: + converted_value = klass(data) + if isinstance(data, str) and klass == float: + if str(converted_value) != data: + # '7' -> 7.0 -> '7.0' != '7' + raise ValueError('This is not a float') + return converted_value + except (OverflowError, ValueError): + # parse can raise OverflowError + raise ApiValueError( + "{0}Failed to parse {1} as {2}".format( + additional_message, repr(data), get_py3_class_name(klass) + ), + path_to_item=path_to_item + ) + + +def deserialize_model(model_data, model_class, path_to_item, check_type, + configuration, from_server): + """Deserializes model_data to model instance. + + Args: + model_data (list/dict): data to instantiate the model + model_class (OpenApiModel): the model class + path_to_item (list): path to the model in the received data + check_type (bool): whether to check the data tupe for the values in + the model + configuration (Configuration): the instance to use to convert files + from_server (bool): True if the data is from the server + False if the data is from the client + + Returns: + model instance + + Raise: + ApiTypeError + ApiValueError + ApiKeyError + """ + fixed_model_data = copy.deepcopy(model_data) + + if isinstance(fixed_model_data, dict): + fixed_model_data = change_keys_js_to_python(fixed_model_data, + model_class) + + kw_args = dict(_check_type=check_type, + _path_to_item=path_to_item, + _configuration=configuration, + _from_server=from_server) + + if hasattr(model_class, 'get_real_child_model'): + # discriminator case + discriminator_class = model_class.get_real_child_model(model_data) + if discriminator_class: + if isinstance(model_data, list): + instance = discriminator_class(*model_data, **kw_args) + elif isinstance(model_data, dict): + fixed_model_data = change_keys_js_to_python( + fixed_model_data, + discriminator_class + ) + kw_args.update(fixed_model_data) + instance = discriminator_class(**kw_args) + else: + # all other cases + if isinstance(model_data, list): + instance = model_class(*model_data, **kw_args) + if isinstance(model_data, dict): + fixed_model_data = change_keys_js_to_python(fixed_model_data, + model_class) + kw_args.update(fixed_model_data) + instance = model_class(**kw_args) + else: + instance = model_class(model_data, **kw_args) + + return instance + + +def deserialize_file(response_data, configuration, content_disposition=None): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + Args: + param response_data (str): the file data to write + configuration (Configuration): the instance to use to convert files + + Keyword Args: + content_disposition (str): the value of the Content-Disposition + header + + Returns: + (file_type): the deserialized file which is open + The user is responsible for closing and reading the file + """ + fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + if six.PY3 and isinstance(response_data, str): + # in python3 change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + + f = open(path, "rb") + return f + + +def attempt_convert_item(input_value, valid_classes, path_to_item, + configuration, from_server, key_type=False, + must_convert=False, check_type=True): + """ + Args: + input_value (any): the data to convert + valid_classes (any): the classes that are valid + path_to_item (list): the path to the item to convert + configuration (Configuration): the instance to use to convert files + from_server (bool): True if data is from the server, False is data is + from the client + key_type (bool): if True we need to convert a key type (not supported) + must_convert (bool): if True we must convert + check_type (bool): if True we check the type or the returned data in + ModelNormal and ModelSimple instances + + Returns: + instance (any) the fixed item + + Raises: + ApiTypeError + ApiValueError + ApiKeyError + """ + valid_classes_ordered = order_response_types(valid_classes) + valid_classes_coercible = remove_uncoercible( + valid_classes_ordered, input_value, from_server) + if not valid_classes_coercible or key_type: + # we do not handle keytype errors, json will take care + # of this for us + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) + for valid_class in valid_classes_coercible: + try: + if issubclass(valid_class, OpenApiModel): + return deserialize_model(input_value, valid_class, + path_to_item, check_type, + configuration, from_server) + elif valid_class == file_type: + return deserialize_file(input_value, configuration) + return deserialize_primitive(input_value, valid_class, + path_to_item) + except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc: + if must_convert: + raise conversion_exc + # if we have conversion errors when must_convert == False + # we ignore the exception and move on to the next class + continue + # we were unable to convert, must_convert == False + return input_value + + +def validate_and_convert_types(input_value, required_types_mixed, path_to_item, + from_server, _check_type, configuration=None): + """Raises a TypeError is there is a problem, otherwise returns value + + Args: + input_value (any): the data to validate/convert + required_types_mixed (list/dict/tuple): A list of + valid classes, or a list tuples of valid classes, or a dict where + the value is a tuple of value classes + path_to_item: (list) the path to the data being validated + this stores a list of keys or indices to get to the data being + validated + from_server (bool): True if data is from the server + False if data is from the client + _check_type: (boolean) if true, type will be checked and conversion + will be attempted. + configuration: (Configuration): the configuration class to use + when converting file_type items. + If passed, conversion will be attempted when possible + If not passed, no conversions will be attempted and + exceptions will be raised + + Returns: + the correctly typed value + + Raises: + ApiTypeError + """ + results = get_required_type_classes(required_types_mixed) + valid_classes, child_req_types_by_current_type = results + + input_class_simple = get_simple_class(input_value) + valid_type = input_class_simple in set(valid_classes) + if not valid_type: + if configuration: + # if input_value is not valid_type try to convert it + converted_instance = attempt_convert_item( + input_value, + valid_classes, + path_to_item, + configuration, + from_server, + key_type=False, + must_convert=True + ) + return converted_instance + else: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=False) + + # input_value's type is in valid_classes + if len(valid_classes) > 1 and configuration: + # there are valid classes which are not the current class + valid_classes_coercible = remove_uncoercible( + valid_classes, input_value, from_server, must_convert=False) + if valid_classes_coercible: + converted_instance = attempt_convert_item( + input_value, + valid_classes_coercible, + path_to_item, + configuration, + from_server, + key_type=False, + must_convert=False + ) + return converted_instance + + if child_req_types_by_current_type == {}: + # all types are of the required types and there are no more inner + # variables left to look at + return input_value + inner_required_types = child_req_types_by_current_type.get( + type(input_value) + ) + if inner_required_types is None: + # for this type, there are not more inner variables left to look at + return input_value + if isinstance(input_value, list): + if input_value == []: + # allow an empty list + return input_value + for index, inner_value in enumerate(input_value): + inner_path = list(path_to_item) + inner_path.append(index) + input_value[index] = validate_and_convert_types( + inner_value, + inner_required_types, + inner_path, + from_server, + _check_type, + configuration=configuration + ) + elif isinstance(input_value, dict): + if input_value == {}: + # allow an empty dict + return input_value + for inner_key, inner_val in six.iteritems(input_value): + inner_path = list(path_to_item) + inner_path.append(inner_key) + if get_simple_class(inner_key) != str: + raise get_type_error(inner_key, inner_path, valid_classes, + key_type=True) + input_value[inner_key] = validate_and_convert_types( + inner_val, + inner_required_types, + inner_path, + from_server, + _check_type, + configuration=configuration + ) + return input_value + + +def model_to_dict(model_instance, serialize=True): + """Returns the model properties as a dict + + Args: + model_instance (one of your model instances): the model instance that + will be converted to a dict. + + Keyword Args: + serialize (bool): if True, the keys in the dict will be values from + attribute_map + """ + result = {} + + for attr, value in six.iteritems(model_instance._data_store): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + attr = model_instance.attribute_map.get(attr, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: model_to_dict(x, serialize=serialize) + if hasattr(x, '_data_store') else x, value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value + + return result + + +def type_error_message(var_value=None, var_name=None, valid_classes=None, + key_type=None): + """ + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + """ + key_or_value = 'value' + if key_type: + key_or_value = 'key' + valid_classes_phrase = get_valid_classes_phrase(valid_classes) + msg = ( + "Invalid type for variable '{0}'. Required {1} type {2} and " + "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + ) + return msg + + +def get_valid_classes_phrase(input_classes): + """Returns a string phrase describing what types are allowed + Note: Adds the extra valid classes in python2 + """ + all_classes = list(input_classes) + if six.PY2 and str in input_classes: + all_classes.extend([str_py2, unicode_py2]) + if six.PY2 and int in input_classes: + all_classes.extend([int_py2, long_py2]) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return 'is {0}'.format(all_class_names[0]) + return "is one of [{0}]".format(", ".join(all_class_names)) -class ModelNormal(object): - # the parent class of models whose type == object in their swagger/openapi - # spec - pass +def get_py3_class_name(input_class): + if six.PY2: + if input_class == str: + return 'str' + elif input_class == int: + return 'int' + return input_class.__name__ diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache new file mode 100644 index 0000000000..eb358efd5b --- /dev/null +++ b/python-experimental/requirements.mustache @@ -0,0 +1,6 @@ +certifi >= 14.05.14 +future; python_version<="2.7" +six >= 1.10 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache new file mode 100644 index 0000000000..80006ded16 --- /dev/null +++ b/python-experimental/setup.mustache @@ -0,0 +1,45 @@ +# coding: utf-8 + +{{>partial_header}} + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "{{{projectName}}}" +VERSION = "{{packageVersion}}" +{{#apiInfo}} +{{#apis}} +{{^hasMore}} +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +{{#asyncio}} +REQUIRES.append("aiohttp >= 3.0.0") +{{/asyncio}} +{{#tornado}} +REQUIRES.append("tornado>=4.2,<5") +{{/tornado}} +EXTRAS = {':python_version <= "2.7"': ['future']} + +setup( + name=NAME, + version=VERSION, + description="{{appName}}", + author_email="{{infoEmail}}", + url="{{packageUrl}}", + keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], + install_requires=REQUIRES, + extras_require=EXTRAS, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description="""\ + {{appDescription}} # noqa: E501 + """ +) +{{/hasMore}} +{{/apis}} +{{/apiInfo}} diff --git a/python-experimental/test-requirements.mustache b/python-experimental/test-requirements.mustache new file mode 100644 index 0000000000..023ff96078 --- /dev/null +++ b/python-experimental/test-requirements.mustache @@ -0,0 +1,13 @@ +{{^asyncio}} +coverage>=4.0.3 +nose>=1.3.7 +{{/asyncio}} +{{#asyncio}} +pytest>=3.6.0 +pytest-cov>=2.6.1 +{{/asyncio}} +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 +mock; python_version<="2.7" + diff --git a/requirements.mustache b/requirements.mustache index bafdc07532..eb358efd5b 100644 --- a/requirements.mustache +++ b/requirements.mustache @@ -1,4 +1,5 @@ certifi >= 14.05.14 +future; python_version<="2.7" six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 From 554e6cb2f5f546cd1d77a82dc49bf8be90263ed2 Mon Sep 17 00:00:00 2001 From: Arun Date: Tue, 29 Oct 2019 20:24:05 +0530 Subject: [PATCH 059/185] [Python] [Bug] Correct typo in the word datetime (#4304) --- api_client.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 63dd91ebb5..4c0be2fe86 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -294,7 +294,7 @@ class ApiClient(object): elif klass == datetime.date: return self.__deserialize_date(data) elif klass == datetime.datetime: - return self.__deserialize_datatime(data) + return self.__deserialize_datetime(data) else: return self.__deserialize_model(data, klass) @@ -594,7 +594,7 @@ class ApiClient(object): reason="Failed to parse `{0}` as date object".format(string) ) - def __deserialize_datatime(self, string): + def __deserialize_datetime(self, string): """Deserializes string to datetime. The string should be in iso8601 datetime format. From 5933bdf42abc5a799c8fa68d8b63b064d9b45086 Mon Sep 17 00:00:00 2001 From: Arun Date: Wed, 30 Oct 2019 14:32:08 +0530 Subject: [PATCH 060/185] [Python] Remove redundant else statement (#4311) * [Python] Remove redundant else condition * Add indentation * Reduce extra indent * Avoid longer than 79 chars * Remove trailing space after response_body * [Python] Fix pep8 violation in imports * Revert "[Python] Fix pep8 violation in imports" This reverts commit bc69aaae7fa7739d0d48421e47a1a446f130c225. --- api_client.mustache | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 4c0be2fe86..8cba076583 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -347,18 +347,19 @@ class ApiClient(object): response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host)) - return thread + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, From d12d265ae6a8e5256b80db9eaaa1a043ae69819b Mon Sep 17 00:00:00 2001 From: Sai Giridhar P Date: Wed, 30 Oct 2019 14:40:02 +0530 Subject: [PATCH 061/185] [python][fix] Adding model summary to model documentation files (#4306) * feat(documentation): Adding model documentation * feat(documentation): Adding model documentation * feat(documentation): Adding model documentation * feat(documentation): Adding model documentation --- model_doc.mustache | 2 ++ python-experimental/model_doc.mustache | 2 ++ 2 files changed, 4 insertions(+) diff --git a/model_doc.mustache b/model_doc.mustache index 71c106fdc5..c1ead8680c 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -1,5 +1,7 @@ {{#models}}{{#model}}# {{classname}} +{{#description}}{{description}} +{{/description}} ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index 70b2339985..a8bfb933b6 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -1,5 +1,7 @@ {{#models}}{{#model}}# {{classname}} +{{#description}}{{description}} +{{/description}} ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- From d98b3f46c0d052ba141c120aebd546ae4fb6e756 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 31 Oct 2019 09:10:05 +0800 Subject: [PATCH 062/185] Do not HTML escaped the description in the doc (#4321) * html escaped the description in the doc * update python oas3 sample --- model_doc.mustache | 2 +- python-experimental/model_doc.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model_doc.mustache b/model_doc.mustache index c1ead8680c..fc90a2e0fc 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -1,6 +1,6 @@ {{#models}}{{#model}}# {{classname}} -{{#description}}{{description}} +{{#description}}{{&description}} {{/description}} ## Properties Name | Type | Description | Notes diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index a8bfb933b6..79abbf6130 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -1,6 +1,6 @@ {{#models}}{{#model}}# {{classname}} -{{#description}}{{description}} +{{#description}}{{&description}} {{/description}} ## Properties Name | Type | Description | Notes From 0a9f1e302bffebb4862be820acd1e153ad91f3e4 Mon Sep 17 00:00:00 2001 From: Arun Date: Sun, 3 Nov 2019 12:18:42 +0530 Subject: [PATCH 063/185] [Python] Avoid pep8 violation (#4316) --- api_client.mustache | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 8cba076583..790ec22046 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -3,6 +3,7 @@ from __future__ import absolute_import import datetime +from dateutil.parser import parse import json import mimetypes from multiprocessing.pool import ThreadPool @@ -585,7 +586,6 @@ class ApiClient(object): :return: date. """ try: - from dateutil.parser import parse return parse(string).date() except ImportError: return string @@ -604,7 +604,6 @@ class ApiClient(object): :return: datetime. """ try: - from dateutil.parser import parse return parse(string) except ImportError: return string From b1f41083071ccb982e7b7dcb2e08279e54846545 Mon Sep 17 00:00:00 2001 From: Sai Giridhar P Date: Sun, 3 Nov 2019 12:28:39 +0530 Subject: [PATCH 064/185] [python][metadata]: Adding license and author fields (#4318) * fix(license): Fixing the license and author information * fix(license): Fixing the license and author information * fix(metadata): Adding default values for contact details and license fields * fix(metadata): Adding default values for contact details and license fields --- python-experimental/setup.mustache | 6 ++++-- setup.mustache | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 80006ded16..bf9ffe07d0 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -29,14 +29,16 @@ setup( name=NAME, version=VERSION, description="{{appName}}", - author_email="{{infoEmail}}", + author="{{#infoName}}{{infoName}}{{/infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", + author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], install_requires=REQUIRES, extras_require=EXTRAS, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, - long_description="""\ + {{#licenseInfo}}license="{{licenseInfo}}", + {{/licenseInfo}}long_description="""\ {{appDescription}} # noqa: E501 """ ) diff --git a/setup.mustache b/setup.mustache index 588851cc7b..a41fee1467 100644 --- a/setup.mustache +++ b/setup.mustache @@ -28,13 +28,15 @@ setup( name=NAME, version=VERSION, description="{{appName}}", - author_email="{{infoEmail}}", + author="{{#infoName}}{{infoName}}{{/infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", + author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, - long_description="""\ + {{#licenseInfo}}license="{{licenseInfo}}", + {{/licenseInfo}}long_description="""\ {{appDescription}} # noqa: E501 """ ) From 20f072747c3b848a1bd22cf4758aed92033d93ef Mon Sep 17 00:00:00 2001 From: Arun Date: Mon, 4 Nov 2019 14:02:53 +0530 Subject: [PATCH 065/185] [Python-Experimental]: Remove redundant else statement (#4324) * [Python-Experimental]: Remove redundant else statement * Run petstore --- python-experimental/api_client.mustache | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index aec1ef3753..25ca4b5043 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -346,18 +346,19 @@ class ApiClient(object): _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, _check_type)) - return thread + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, From db2880d027684a57d566f2ed77b075f1050216a5 Mon Sep 17 00:00:00 2001 From: Arun Date: Thu, 7 Nov 2019 08:19:54 +0530 Subject: [PATCH 066/185] [Python] [Performance] Avoid unnessacary checks inside the loop (#4305) --- api_client.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 790ec22046..3bf085e190 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -629,11 +629,11 @@ class ApiClient(object): return data kwargs = {} - if klass.openapi_types is not None: + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) From dda753800d9986250c64f9a47f684b44b1e7a3c3 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sat, 16 Nov 2019 16:49:19 -0800 Subject: [PATCH 067/185] Fixes Python client Configuration class so each instance uses its own dicts (#4485) --- configuration.mustache | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 9677031a8c..6e02b238da 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -4,7 +4,6 @@ from __future__ import absolute_import -import copy import logging {{^asyncio}} import multiprocessing @@ -16,21 +15,7 @@ import six from six.moves import http_client as httplib -class TypeWithDefault(type): - def __init__(cls, name, bases, dct): - super(TypeWithDefault, cls).__init__(name, bases, dct) - cls._default = None - - def __call__(cls, **kwargs): - if cls._default is None: - cls._default = type.__call__(cls, **kwargs) - return copy.copy(cls._default) - - def set_default(cls, default): - cls._default = copy.copy(default) - - -class Configuration(six.with_metaclass(TypeWithDefault, object)): +class Configuration(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech @@ -44,7 +29,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): """ def __init__(self, host="{{{basePath}}}", - api_key={}, api_key_prefix={}, + api_key=None, api_key_prefix=None, username="", password=""): """Constructor """ @@ -55,10 +40,14 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): """Temp file folder for downloading files """ # Authentication Settings - self.api_key = api_key + self.api_key = {} + if api_key: + self.api_key = api_key """dict to store API key(s) """ - self.api_key_prefix = api_key_prefix + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix """dict to store API prefix (e.g. Bearer) """ self.refresh_api_key_hook = None From 360acdc4bdd25532e9808afea8dae4ba0b4190bd Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 9 Dec 2019 19:29:14 -0800 Subject: [PATCH 068/185] Updates python and python-flask travis CI testing to use python 3.6, 3.7, and 3.8 (#4743) --- travis.mustache | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/travis.mustache b/travis.mustache index 86211e2d4a..388de83128 100644 --- a/travis.mustache +++ b/travis.mustache @@ -6,8 +6,9 @@ python: - "3.3" - "3.4" - "3.5" - #- "3.5-dev" # 3.5 development branch - #- "nightly" # points to the latest development branch e.g. 3.6-dev + - "3.6" + - "3.7" + - "3.8" # command to install dependencies install: "pip install -r requirements.txt" # command to run tests From f543f21b343301ec0959b9b3d83de8fec19b6250 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 12 Dec 2019 21:21:28 +0800 Subject: [PATCH 069/185] fix package name in tox.ini (#4776) --- tox.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.mustache b/tox.mustache index 63d12fdeae..585feb3c68 100644 --- a/tox.mustache +++ b/tox.mustache @@ -16,5 +16,5 @@ commands= [] {{/asyncio}} {{#asyncio}} - pytest -v --cov petstore_api + pytest -v --cov {{{packageName}}} {{/asyncio}} From 52924f1e65e55e7b7abcf7f7120b648de55ad007 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sat, 14 Dec 2019 18:18:41 -0800 Subject: [PATCH 070/185] [Python] Adds allOf/oneOf/anyOf composed models (#4446) * Adds composed model support for allOf oneOf anyOf * Moves discriminator into discriminator() class method, adds test_deserialize_lizard, adds setting discriminator using allOf schema --- README.mustache | 2 +- python-experimental/README.mustache | 55 +++ python-experimental/README_common.mustache | 74 ++++ .../README_onlypackage.mustache | 44 ++ python-experimental/__init__model.mustache | 7 + python-experimental/__init__package.mustache | 36 ++ python-experimental/api.mustache | 1 + python-experimental/api_doc.mustache | 11 +- python-experimental/api_doc_example.mustache | 13 +- python-experimental/model.mustache | 26 +- python-experimental/model_doc.mustache | 6 +- .../model_templates/classvar_allowed.mustache | 16 - .../classvar_openapi_validations.mustache | 42 -- .../model_templates/classvars.mustache | 119 ++++++ .../method_discriminator.mustache | 12 + .../method_init_composed.mustache | 42 ++ .../method_init_normal.mustache | 21 + .../method_init_shared.mustache | 23 + .../method_set_attribute.mustache | 49 +++ .../methods_init_properties.mustache | 126 ------ .../methods_setattr_getattr_composed.mustache | 61 +++ .../methods_setattr_getattr_normal.mustache | 24 ++ .../model_templates/methods_shared.mustache | 15 + .../methods_todict_tostr_eq_shared.mustache | 29 ++ .../methods_tostr_eq_simple.mustache | 22 + .../model_templates/model_composed.mustache | 56 +++ .../model_templates/model_normal.mustache | 74 +--- .../model_templates/model_simple.mustache | 40 +- python-experimental/model_test.mustache | 33 ++ python-experimental/model_utils.mustache | 403 +++++++++++++++--- 30 files changed, 1103 insertions(+), 379 deletions(-) create mode 100644 python-experimental/README.mustache create mode 100644 python-experimental/README_common.mustache create mode 100644 python-experimental/README_onlypackage.mustache create mode 100644 python-experimental/__init__model.mustache create mode 100644 python-experimental/__init__package.mustache delete mode 100644 python-experimental/model_templates/classvar_allowed.mustache delete mode 100644 python-experimental/model_templates/classvar_openapi_validations.mustache create mode 100644 python-experimental/model_templates/classvars.mustache create mode 100644 python-experimental/model_templates/method_discriminator.mustache create mode 100644 python-experimental/model_templates/method_init_composed.mustache create mode 100644 python-experimental/model_templates/method_init_normal.mustache create mode 100644 python-experimental/model_templates/method_init_shared.mustache create mode 100644 python-experimental/model_templates/method_set_attribute.mustache delete mode 100644 python-experimental/model_templates/methods_init_properties.mustache create mode 100644 python-experimental/model_templates/methods_setattr_getattr_composed.mustache create mode 100644 python-experimental/model_templates/methods_setattr_getattr_normal.mustache create mode 100644 python-experimental/model_templates/methods_shared.mustache create mode 100644 python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache create mode 100644 python-experimental/model_templates/methods_tostr_eq_simple.mustache create mode 100644 python-experimental/model_templates/model_composed.mustache create mode 100644 python-experimental/model_test.mustache diff --git a/README.mustache b/README.mustache index 144f72427e..94d72af33d 100644 --- a/README.mustache +++ b/README.mustache @@ -31,7 +31,7 @@ pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git Then import the package: ```python -import {{{packageName}}} +import {{{packageName}}} ``` ### Setuptools diff --git a/python-experimental/README.mustache b/python-experimental/README.mustache new file mode 100644 index 0000000000..f26408cf66 --- /dev/null +++ b/python-experimental/README.mustache @@ -0,0 +1,55 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +{{> python-experimental/README_common }} diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache new file mode 100644 index 0000000000..a8b66b0bed --- /dev/null +++ b/python-experimental/README_common.mustache @@ -0,0 +1,74 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{> python_doc_auth_partial}} +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{unescapedDescription}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} + All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +## {{{name}}} + +{{#isApiKey}} +- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}} +{{^isBasicBearer}} +- **Type**: HTTP basic authentication +{{/isBasicBearer}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} +- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/python-experimental/README_onlypackage.mustache b/python-experimental/README_onlypackage.mustache new file mode 100644 index 0000000000..11c002c9aa --- /dev/null +++ b/python-experimental/README_onlypackage.mustache @@ -0,0 +1,44 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage + +This python library package is generated without supporting files like setup.py or requirements files + +To be able to use it, you will need these dependencies in your own package that uses this library: + +* urllib3 >= 1.15 +* six >= 1.10 +* certifi +* python-dateutil +{{#asyncio}} +* aiohttp +{{/asyncio}} +{{#tornado}} +* tornado>=4.2,<5 +{{/tornado}} + +## Getting Started + +In your own code, to use this library to connect and interact with {{{projectName}}}, +you can run the following: + +{{> python-experimental/README_common }} diff --git a/python-experimental/__init__model.mustache b/python-experimental/__init__model.mustache new file mode 100644 index 0000000000..ca86cb8a62 --- /dev/null +++ b/python-experimental/__init__model.mustache @@ -0,0 +1,7 @@ +# coding: utf-8 + +# flake8: noqa +{{>partial_header}} + +# we can not import model classes here because that would create a circular +# reference which would not work in python2 diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache new file mode 100644 index 0000000000..b5224a5821 --- /dev/null +++ b/python-experimental/__init__package.mustache @@ -0,0 +1,36 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +__version__ = "{{packageVersion}}" + +# import apis into sdk package +{{#apiInfo}} +{{#apis}} +from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}} +{{/apiInfo}} + +# import ApiClient +from {{packageName}}.api_client import ApiClient + +# import Configuration +from {{packageName}}.configuration import Configuration + +# import exceptions +from {{packageName}}.exceptions import OpenApiException +from {{packageName}}.exceptions import ApiTypeError +from {{packageName}}.exceptions import ApiValueError +from {{packageName}}.exceptions import ApiKeyError +from {{packageName}}.exceptions import ApiException + +# import models into sdk package +{{#models}} +{{#model}} +from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} +{{/model}} +{{/models}} diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 651559cf4f..734c490cab 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -5,6 +5,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six diff --git a/python-experimental/api_doc.mustache b/python-experimental/api_doc.mustache index 5cc638a2eb..4feb612f1c 100644 --- a/python-experimental/api_doc.mustache +++ b/python-experimental/api_doc.mustache @@ -35,19 +35,16 @@ Method | HTTP request | Description {{#isOAuth}} * OAuth Authentication ({{name}}): {{/isOAuth }} -{{> api_doc_example }} {{/authMethods}} {{/hasAuthMethods}} -{{^hasAuthMethods}} -{{> api_doc_example }} -{{/hasAuthMethods}} +{{> python-experimental/api_doc_example }} ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | -{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | defaults to {{{.}}} -{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | +{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalParams}} ### Return type diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index e5eeee6b0e..8a6beabd2d 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -2,7 +2,6 @@ from __future__ import print_function import time import {{{packageName}}} -from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} {{#hasAuthMethods}} @@ -18,40 +17,40 @@ api_instance = {{{packageName}}}.{{{classname}}}() {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} - {{#requiredParams}} {{^hasMore}} + # example passing only required values which don't have defaults set try: {{#summary}} # {{{.}}} {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} pprint(api_response){{/returnType}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/hasMore}} {{/requiredParams}} - {{#optionalParams}} {{^hasMore}} + # example passing only required values which don't have defaults set # and optional values try: {{#summary}} # {{{.}}} {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} pprint(api_response){{/returnType}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/hasMore}} {{/optionalParams}} - {{^requiredParams}} {{^optionalParams}} + # example, this endpoint has no required or optional parameters try: {{#summary}} # {{{.}}} {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} pprint(api_response){{/returnType}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/optionalParams}} {{/requiredParams}} diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 2513d6b3f8..0ca198ddf9 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -2,37 +2,31 @@ {{>partial_header}} -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from {{packageName}}.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from {{packageName}}.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -{{#models}}{{#model}}{{#imports}}{{.}} -{{/imports}}{{/model}}{{/models}} - {{#models}} {{#model}} +{{#imports}} +{{{.}}} +{{/imports}} + + {{^interfaces}} {{#isAlias}} {{> python-experimental/model_templates/model_simple }} @@ -43,7 +37,7 @@ from {{packageName}}.model_utils import ( # noqa: F401 {{/interfaces}} {{#interfaces}} {{#-last}} -{{> python-experimental/model_templates/model_normal }} +{{> python-experimental/model_templates/model_composed }} {{/-last}} {{/interfaces}} {{/model}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index 79abbf6130..a1e57131bc 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -7,16 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- {{#requiredVars}} {{^defaultValue}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} {{/defaultValue}} {{/requiredVars}} {{#requiredVars}} {{#defaultValue}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} {{/defaultValue}} {{/requiredVars}} {{#optionalVars}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} {{#additionalPropertiesType}} **any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] diff --git a/python-experimental/model_templates/classvar_allowed.mustache b/python-experimental/model_templates/classvar_allowed.mustache deleted file mode 100644 index 2414be114a..0000000000 --- a/python-experimental/model_templates/classvar_allowed.mustache +++ /dev/null @@ -1,16 +0,0 @@ - allowed_values = { -{{#allVars}} -{{#isEnum}} - ('{{name}}',): { -{{#isNullable}} - 'None': None, -{{/isNullable}} -{{#allowableValues}} -{{#enumVars}} - '{{name}}': {{{value}}}, -{{/enumVars}} -{{/allowableValues}} - }, -{{/isEnum}} -{{/allVars}} - } \ No newline at end of file diff --git a/python-experimental/model_templates/classvar_openapi_validations.mustache b/python-experimental/model_templates/classvar_openapi_validations.mustache deleted file mode 100644 index 1cc7b58550..0000000000 --- a/python-experimental/model_templates/classvar_openapi_validations.mustache +++ /dev/null @@ -1,42 +0,0 @@ - openapi_types = { -{{#allVars}} - '{{name}}': ({{{dataType}}},), # noqa: E501 -{{/allVars}} - } - - validations = { -{{#allVars}} -{{#hasValidation}} - ('{{name}}',): { -{{#maxLength}} - 'max_length': {{maxLength}}, -{{/maxLength}} -{{#minLength}} - 'min_length': {{minLength}}, -{{/minLength}} -{{#maxItems}} - 'max_items': {{maxItems}}, -{{/maxItems}} -{{#minItems}} - 'min_items': {{minItems}}, -{{/minItems}} -{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, -{{/maximum}} -{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, -{{/minimum}} -{{#pattern}} - 'regex': { - 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} - {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - }, -{{/pattern}} - }, -{{/hasValidation}} -{{/allVars}} - } - - additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} - - discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} \ No newline at end of file diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache new file mode 100644 index 0000000000..fcd8a71fd1 --- /dev/null +++ b/python-experimental/model_templates/classvars.mustache @@ -0,0 +1,119 @@ + allowed_values = { +{{#requiredVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/requiredVars}} +{{#optionalVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/optionalVars}} + } + + openapi_types = { +{{#requiredVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/optionalVars}} + } + + validations = { +{{#requiredVars}} +{{#hasValidation}} + ('{{name}}',): { +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} + }, +{{/hasValidation}} +{{/requiredVars}} +{{#optionalVars}} +{{#hasValidation}} + ('{{name}}',): { +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} + }, +{{/hasValidation}} +{{/optionalVars}} + } + + additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} + + @staticmethod + def discriminator(): + return {{^discriminator}}None{{/discriminator}}{{#discriminator}}{ + '{{{discriminatorName}}}': { +{{#children}} + '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}, +{{/children}} +{{^children}} +{{#mappedModels}} + '{{mappingName}}': {{{modelName}}}, +{{/mappedModels}} +{{/children}} + }, + }{{/discriminator}} \ No newline at end of file diff --git a/python-experimental/model_templates/method_discriminator.mustache b/python-experimental/model_templates/method_discriminator.mustache new file mode 100644 index 0000000000..c4baa722ff --- /dev/null +++ b/python-experimental/model_templates/method_discriminator.mustache @@ -0,0 +1,12 @@ + @classmethod + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache new file mode 100644 index 0000000000..5ed5993fe9 --- /dev/null +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -0,0 +1,42 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + +{{> python-experimental/model_templates/method_init_shared }} + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { +{{#requiredVars}} + '{{name}}': {{name}}, +{{/requiredVars}} + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache new file mode 100644 index 0000000000..b053427a79 --- /dev/null +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -0,0 +1,21 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + +{{> python-experimental/model_templates/method_init_shared }} + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache new file mode 100644 index 0000000000..2f3b70ea69 --- /dev/null +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -0,0 +1,23 @@ + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} +{{/hasMore}}{{/requiredVars}} + Keyword Args:{{#requiredVars}}{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done.{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + """ \ No newline at end of file diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache new file mode 100644 index 0000000000..f4a36e42f2 --- /dev/null +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -0,0 +1,49 @@ + def set_attribute(self, name, value): + # this is only used to set properties on self + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._from_server, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value + ) + self.__dict__['_data_store'][name] = value \ No newline at end of file diff --git a/python-experimental/model_templates/methods_init_properties.mustache b/python-experimental/model_templates/methods_init_properties.mustache deleted file mode 100644 index dab632efab..0000000000 --- a/python-experimental/model_templates/methods_init_properties.mustache +++ /dev/null @@ -1,126 +0,0 @@ - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """{{classname}} - a model defined in OpenAPI - -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} -{{/hasMore}}{{/requiredVars}} - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} - _check_type (bool): if True, values for parameters in openapi_types - will be type checked and a TypeError will be - raised if the wrong type is input. - Defaults to True - _path_to_item (tuple/list): This is a list of keys or values to - drill down to the model in received_data - when deserializing a response - _from_server (bool): True if the data is from the server - False if the data is from the client (default) - _configuration (Configuration): the instance to use when - deserializing a file_type parameter. - If passed, type conversion is attempted - If omitted no type conversion is done.{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - -{{#requiredVars}} - self.__set_item('{{name}}', {{name}}) -{{/requiredVars}} - for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) -{{#allVars}} - - @property - def {{name}}(self): - """Gets the {{name}} of this {{classname}}. # noqa: E501 -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - Returns: - ({{{dataType}}}): The {{name}} of this {{classname}}. # noqa: E501 - """ - return self.__get_item('{{name}}') - - @{{name}}.setter - def {{name}}(self, value): - """Sets the {{name}} of this {{classname}}. # noqa: E501 -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - """ - return self.__set_item('{{name}}', value) -{{/allVars}} \ No newline at end of file diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache new file mode 100644 index 0000000000..e5eee88a96 --- /dev/null +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -0,0 +1,61 @@ + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + # set the attribute on the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + if model_instances: + for model_instance in model_instances: + if model_instance == self: + self.set_attribute(name, value) + else: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = ( + model_instance + ) + return None + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + # get the attribute from the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + if model_instances: + values = set() + for model_instance in model_instances: + if name in model_instance._data_store: + values.add(model_instance._data_store[name]) + if len(values) == 1: + return list(values)[0] + raise ApiValueError( + "Values stored for property {0} in {1} difffer when looking " + "at self and self's composed instances. All values must be " + "the same".format(name, type(self).__name__), + path_to_item + ) + + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) \ No newline at end of file diff --git a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache new file mode 100644 index 0000000000..f92663ab20 --- /dev/null +++ b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache @@ -0,0 +1,24 @@ + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + if name in self.__dict__['_data_store']: + return self.__dict__['_data_store'][name] + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + [name] + ) \ No newline at end of file diff --git a/python-experimental/model_templates/methods_shared.mustache b/python-experimental/model_templates/methods_shared.mustache new file mode 100644 index 0000000000..d3cf66e41b --- /dev/null +++ b/python-experimental/model_templates/methods_shared.mustache @@ -0,0 +1,15 @@ + def __setitem__(self, name, value): + """this allows us to set values with instance[field_name] = val""" + self.__setattr__(name, value) + + def __getitem__(self, name): + """this allows us to get a value with val = instance[field_name]""" + return self.__getattr__(name) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other \ No newline at end of file diff --git a/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache b/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache new file mode 100644 index 0000000000..d01d49ad77 --- /dev/null +++ b/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache @@ -0,0 +1,29 @@ + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in six.iteritems(self._data_store): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if (not six.PY3 and + len(types) == 2 and unicode in types): # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True \ No newline at end of file diff --git a/python-experimental/model_templates/methods_tostr_eq_simple.mustache b/python-experimental/model_templates/methods_tostr_eq_simple.mustache new file mode 100644 index 0000000000..0bba565d22 --- /dev/null +++ b/python-experimental/model_templates/methods_tostr_eq_simple.mustache @@ -0,0 +1,22 @@ + def to_str(self): + """Returns the string representation of the model""" + return str(self.value) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True \ No newline at end of file diff --git a/python-experimental/model_templates/model_composed.mustache b/python-experimental/model_templates/model_composed.mustache new file mode 100644 index 0000000000..d53d89cef2 --- /dev/null +++ b/python-experimental/model_templates/model_composed.mustache @@ -0,0 +1,56 @@ +class {{unescapedDescription}}(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> python-experimental/model_templates/docstring_allowed }} + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. +{{> python-experimental/model_templates/docstring_openapi_validations }} + """ + +{{> python-experimental/model_templates/classvars }} + + attribute_map = { +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} + } + +{{> python-experimental/model_templates/method_init_composed }} + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ +{{#anyOf}} + {{{.}}}, +{{/anyOf}} + ], + 'allOf': [ +{{#allOf}} + {{{.}}}, +{{/allOf}} + ], + 'oneOf': [ +{{#oneOf}} + {{{.}}}, +{{/oneOf}} + ], + }{{#discriminator}} + +{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache index c4e707e036..8bfe6ada48 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/python-experimental/model_templates/model_normal.mustache @@ -1,4 +1,4 @@ -class {{classname}}(ModelNormal): +class {{unescapedDescription}}(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -13,69 +13,21 @@ class {{classname}}(ModelNormal): {{> python-experimental/model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvar_allowed }} +{{> python-experimental/model_templates/classvars }} attribute_map = { -{{#allVars}} - '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501 -{{/allVars}} +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} } -{{#discriminator}} - discriminator_value_class_map = { - {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}{{^-last}}, - {{/-last}}{{/children}} - } -{{/discriminator}} - -{{> python-experimental/model_templates/classvar_openapi_validations }} - -{{> python-experimental/model_templates/methods_init_properties }} -{{#discriminator}} - @classmethod - def get_real_child_model(cls, data): - """Returns the real base class specified by the discriminator - We assume that data has javascript keys - """ - discriminator_key = cls.attribute_map[cls.discriminator] - discriminator_value = data[discriminator_key] - return cls.discriminator_value_class_map.get(discriminator_value) - -{{/discriminator}} - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False + @staticmethod + def _composed_schemas(): + return None - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True +{{> python-experimental/model_templates/method_init_normal}}{{#discriminator}} - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other \ No newline at end of file +{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index b5939d926c..465918dfa5 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -1,4 +1,4 @@ -class {{classname}}(ModelSimple): +class {{unescapedDescription}}(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -9,38 +9,10 @@ class {{classname}}(ModelSimple): {{> python-experimental/model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvar_allowed }} +{{> python-experimental/model_templates/classvars }} -{{> python-experimental/model_templates/classvar_openapi_validations }} + @staticmethod + def _composed_schemas(): + return None -{{> python-experimental/model_templates/methods_init_properties }} - def to_str(self): - """Returns the string representation of the model""" - return str(self.value) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False - - this_val = self._data_store['value'] - that_val = other._data_store['value'] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other \ No newline at end of file +{{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file diff --git a/python-experimental/model_test.mustache b/python-experimental/model_test.mustache new file mode 100644 index 0000000000..4fd1263b5f --- /dev/null +++ b/python-experimental/model_test.mustache @@ -0,0 +1,33 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +{{#models}} +{{#model}} +import {{packageName}} + + +class Test{{unescapedDescription}}(unittest.TestCase): + """{{unescapedDescription}} unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test{{unescapedDescription}}(self): + """Test {{unescapedDescription}}""" + # FIXME: construct object with mandatory attributes with example values + # model = {{packageName}}.{{unescapedDescription}}() # noqa: E501 + pass + +{{/model}} +{{/models}} + +if __name__ == '__main__': + unittest.main() diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 101b5466c3..dbd592c37e 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -2,10 +2,10 @@ {{>partial_header}} -import copy from datetime import date, datetime # noqa: F401 import inspect import os +import pprint import re import tempfile @@ -38,30 +38,52 @@ else: class OpenApiModel(object): """The base class for all OpenAPIModels""" +{{> python-experimental/model_templates/method_set_attribute }} + +{{> python-experimental/model_templates/methods_shared }} + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their swagger/openapi""" +{{> python-experimental/model_templates/methods_setattr_getattr_normal }} + +{{> python-experimental/model_templates/methods_tostr_eq_simple }} + class ModelNormal(OpenApiModel): """the parent class of models whose type == object in their swagger/openapi""" +{{> python-experimental/model_templates/methods_setattr_getattr_normal }} + +{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} + + +class ModelComposed(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi and have oneOf/allOf/anyOf""" + +{{> python-experimental/model_templates/methods_setattr_getattr_composed }} + +{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} + COERCION_INDEX_BY_TYPE = { - ModelNormal: 0, - ModelSimple: 1, - none_type: 2, - list: 3, - dict: 4, - float: 5, - int: 6, - bool: 7, - datetime: 8, - date: 9, - str: 10, - file_type: 11, + ModelComposed: 0, + ModelNormal: 1, + ModelSimple: 2, + none_type: 3, + list: 4, + dict: 5, + float: 6, + int: 7, + bool: 8, + datetime: 9, + date: 10, + str: 11, + file_type: 12, } # these are used to limit what type conversions we try to do @@ -70,6 +92,8 @@ COERCION_INDEX_BY_TYPE = { UPCONVERSION_TYPE_PAIRS = ( (str, datetime), (str, date), + (list, ModelComposed), + (dict, ModelComposed), (list, ModelNormal), (dict, ModelNormal), (str, ModelSimple), @@ -80,6 +104,8 @@ UPCONVERSION_TYPE_PAIRS = ( COERCIBLE_TYPE_PAIRS = { False: ( # client instantiation of a model with client data + # (dict, ModelComposed), + # (list, ModelComposed), # (dict, ModelNormal), # (list, ModelNormal), # (str, ModelSimple), @@ -94,6 +120,8 @@ COERCIBLE_TYPE_PAIRS = { # (float, str), ), True: ( # server -> client data + (dict, ModelComposed), + (list, ModelComposed), (dict, ModelNormal), (list, ModelNormal), (str, ModelSimple), @@ -336,6 +364,9 @@ def order_response_types(required_types): return COERCION_INDEX_BY_TYPE[list] elif isinstance(class_or_instance, dict): return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): + return COERCION_INDEX_BY_TYPE[ModelComposed] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelNormal)): return COERCION_INDEX_BY_TYPE[ModelNormal] @@ -377,7 +408,9 @@ def remove_uncoercible(required_types_classes, current_item, from_server, # convert our models to OpenApiModel required_type_class_simplified = required_type_class if isinstance(required_type_class_simplified, type): - if issubclass(required_type_class_simplified, ModelNormal): + if issubclass(required_type_class_simplified, ModelComposed): + required_type_class_simplified = ModelComposed + elif issubclass(required_type_class_simplified, ModelNormal): required_type_class_simplified = ModelNormal elif issubclass(required_type_class_simplified, ModelSimple): required_type_class_simplified = ModelSimple @@ -514,6 +547,21 @@ def deserialize_primitive(data, klass, path_to_item): ) +def fix_model_input_data(model_data, model_class): + # this is only called on classes where the input data is a dict + fixed_model_data = change_keys_js_to_python( + model_data, + model_class + ) + if model_class._composed_schemas() is not None: + for allof_class in model_class._composed_schemas()['allOf']: + fixed_model_data = change_keys_js_to_python( + fixed_model_data, + allof_class + ) + return fixed_model_data + + def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -536,42 +584,29 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, ApiValueError ApiKeyError """ - fixed_model_data = copy.deepcopy(model_data) - - if isinstance(fixed_model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) kw_args = dict(_check_type=check_type, _path_to_item=path_to_item, _configuration=configuration, _from_server=from_server) - if hasattr(model_class, 'get_real_child_model'): - # discriminator case - discriminator_class = model_class.get_real_child_model(model_data) - if discriminator_class: - if isinstance(model_data, list): - instance = discriminator_class(*model_data, **kw_args) - elif isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - discriminator_class - ) - kw_args.update(fixed_model_data) - instance = discriminator_class(**kw_args) - else: - # all other cases - if isinstance(model_data, list): - instance = model_class(*model_data, **kw_args) - if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) - kw_args.update(fixed_model_data) - instance = model_class(**kw_args) - else: - instance = model_class(model_data, **kw_args) - + used_model_class = model_class + if model_class.discriminator() is not None: + used_model_class = model_class.get_discriminator_class( + from_server, model_data) + + if issubclass(used_model_class, ModelSimple): + instance = used_model_class(value=model_data, **kw_args) + return instance + if isinstance(model_data, list): + instance = used_model_class(*model_data, **kw_args) + if isinstance(model_data, dict): + fixed_model_data = change_keys_js_to_python( + model_data, + used_model_class + ) + kw_args.update(fixed_model_data) + instance = used_model_class(**kw_args) return instance @@ -626,7 +661,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in - ModelNormal and ModelSimple instances + ModelComposed/ModelNormal/ModelSimple instances Returns: instance (any) the fixed item @@ -790,27 +825,31 @@ def model_to_dict(model_instance, serialize=True): """ result = {} - for attr, value in six.iteritems(model_instance._data_store): - if serialize: - # we use get here because additional property key names do not - # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: model_to_dict(x, serialize=serialize) - if hasattr(x, '_data_store') else x, value - )) - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], - model_to_dict(item[1], serialize=serialize)) - if hasattr(item[1], '_data_store') else item, - value.items() - )) - elif hasattr(value, '_data_store'): - result[attr] = model_to_dict(value, serialize=serialize) - else: - result[attr] = value + model_instances = [model_instance] + if model_instance._composed_schemas() is not None: + model_instances = model_instance._composed_instances + for model_instance in model_instances: + for attr, value in six.iteritems(model_instance._data_store): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + attr = model_instance.attribute_map.get(attr, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: model_to_dict(x, serialize=serialize) + if hasattr(x, '_data_store') else x, value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value return result @@ -866,3 +905,235 @@ def get_py3_class_name(input_class): elif input_class == int: return 'int' return input_class.__name__ + + +def get_allof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + composed_instances (list) + """ + composed_instances = [] + for allof_class in self._composed_schemas()['allOf']: + + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, allof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(allof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) + return composed_instances + + +def get_oneof_instance(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + oneof_instance (instance) + """ + oneof_instance = None + if len(self._composed_schemas()['oneOf']) == 0: + return oneof_instance + + for oneof_class in self._composed_schemas()['oneOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, oneof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(oneof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + oneof_instance = oneof_class(**kwargs) + break + except Exception: + pass + if oneof_instance is None: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in oneOf definition." % + self.__class__.__name__ + ) + return oneof_instance + + +def get_anyof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + anyof_instances (list) + """ + anyof_instances = [] + if len(self._composed_schemas()['anyOf']) == 0: + return anyof_instances + + for anyof_class in self._composed_schemas()['anyOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python(model_args, anyof_class) + + # extract a dict of only required keys from these_model_vars + kwargs = {} + var_names = set(anyof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + anyof_instance = anyof_class(**kwargs) + anyof_instances.append(anyof_instance) + except Exception: + pass + if len(anyof_instances) == 0: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in anyOf definition." % + self.__class__.__name__ + ) + return anyof_instances + + +def get_additional_properties_model_instances( + composed_instances, self): + additional_properties_model_instances = [] + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + if instance.additional_properties_type is not None: + additional_properties_model_instances.append(instance) + return additional_properties_model_instances + + +def get_var_name_to_model_instances(self, composed_instances): + var_name_to_model_instances = {} + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + for var_name in instance.openapi_types: + if var_name not in var_name_to_model_instances: + var_name_to_model_instances[var_name] = [instance] + else: + var_name_to_model_instances[var_name].append(instance) + return var_name_to_model_instances + + +def get_unused_args(self, composed_instances, model_args): + unused_args = dict(model_args) + # arguments apssed to self were already converted to python names + # before __init__ was called + for var_name_py in self.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + for instance in composed_instances: + if instance.__class__ in self._composed_schemas()['allOf']: + for var_name_py in instance.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + else: + for var_name_js in instance.attribute_map.values(): + if var_name_js in unused_args: + del unused_args[var_name_js] + return unused_args + + +def validate_get_composed_info(constant_args, model_args, self): + """ + For composed schemas/classes, validates the classes to make sure that + they do not share any of the same parameters. If there is no collision + then composed model instances are created and returned tot the calling + self model + + Args: + constant_args (dict): these are the args that every model requires + model_args (dict): these are the required and optional spec args that + were passed in to make this model + self (class): the class that we are instantiating + This class contains self._composed_schemas() + + Returns: + composed_info (list): length three + composed_instances (list): the composed instances which are not + self + var_name_to_model_instances (dict): a dict going from var_name + to the model_instance which holds that var_name + the model_instance may be self or an instance of one of the + classes in self.composed_instances() + additional_properties_model_instances (list): a list of the + model instances which have the property + additional_properties_type. This list can include self + """ + # create composed_instances + composed_instances = [] + allof_instances = get_allof_instances(self, model_args, constant_args) + composed_instances.extend(allof_instances) + oneof_instance = get_oneof_instance(self, model_args, constant_args) + if oneof_instance is not None: + composed_instances.append(oneof_instance) + anyof_instances = get_anyof_instances(self, model_args, constant_args) + composed_instances.extend(anyof_instances) + + # map variable names to composed_instances + var_name_to_model_instances = get_var_name_to_model_instances( + self, composed_instances) + + # set additional_properties_model_instances + additional_properties_model_instances = ( + get_additional_properties_model_instances(composed_instances, self) + ) + + # set any remaining values + unused_args = get_unused_args(self, composed_instances, model_args) + if len(unused_args) > 0: + if len(additional_properties_model_instances) == 0: + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + for var_name, var_value in six.iteritems(unused_args): + for instance in additional_properties_model_instances: + setattr(instance, var_name, var_value) + # no need to add additional_properties to var_name_to_model_instances here + # because additional_properties_model_instances will direct us to that + # instance when we use getattr or setattr + # and we update var_name_to_model_instances in setattr + + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances + ] From a8b8ddb1e2f03f7f3629b1e1ccbed7bcd268ecdb Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 17 Dec 2019 03:39:54 +0100 Subject: [PATCH 071/185] [Python] Remove mutable default argument (#4665) --- configuration.mustache | 46 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 6e02b238da..b6a89d495d 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -349,41 +349,37 @@ class Configuration(object): {{/servers}} ] - def get_host_from_settings(self, index, variables={}): + def get_host_from_settings(self, index, variables=None): """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value :return: URL based on host settings """ - + variables = {} if variables is None else variables servers = self.get_host_settings() - # check array index out of bound - if index < 0 or index >= len(servers): + try: + server = servers[index] + except IndexError: raise ValueError( - "Invalid index {} when selecting the host settings. Must be less than {}" # noqa: E501 - .format(index, len(servers))) + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) - server = servers[index] url = server['url'] - # go through variable and assign a value - for variable_name in server['variables']: - if variable_name in variables: - if variables[variable_name] in server['variables'][ - variable_name]['enum_values']: - url = url.replace("{" + variable_name + "}", - variables[variable_name]) - else: - raise ValueError( - "The variable `{}` in the host URL has invalid value {}. Must be {}." # noqa: E501 - .format( - variable_name, variables[variable_name], - server['variables'][variable_name]['enum_values'])) - else: - # use default value - url = url.replace( - "{" + variable_name + "}", - server['variables'][variable_name]['default_value']) + # go through variables and replace placeholders + for variable_name, variable in server['variables'].items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) return url From 779e70b026a1a6edacc10507143cc981a6f51561 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 22 Dec 2019 00:14:04 -0600 Subject: [PATCH 072/185] [Python] Updates python test framework to pytest (#4765) * Switches python generators to use pytest, useNose CLI option added if to allow nose to be used instead * Adds ensure-up-to-date changes * Adds setup.cfg to python clients so we can configure nose when useNose=true * Adds fix for python-aiohttp testing, adds files missing from ensure-up-to-date --- gitignore.mustache | 2 ++ python-experimental/test-requirements.mustache | 16 ++++++++-------- setup_cfg.mustache | 13 +++++++++++++ test-requirements.mustache | 13 +++++++------ tox.mustache | 8 +------- 5 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 setup_cfg.mustache diff --git a/gitignore.mustache b/gitignore.mustache index a655050c26..43995bd42f 100644 --- a/gitignore.mustache +++ b/gitignore.mustache @@ -45,7 +45,9 @@ coverage.xml *,cover .hypothesis/ venv/ +.venv/ .python-version +.pytest_cache # Translations *.mo diff --git a/python-experimental/test-requirements.mustache b/python-experimental/test-requirements.mustache index 023ff96078..338b229bae 100644 --- a/python-experimental/test-requirements.mustache +++ b/python-experimental/test-requirements.mustache @@ -1,13 +1,13 @@ -{{^asyncio}} +{{#useNose}} coverage>=4.0.3 nose>=1.3.7 -{{/asyncio}} -{{#asyncio}} -pytest>=3.6.0 -pytest-cov>=2.6.1 -{{/asyncio}} pluggy>=0.3.1 py>=1.4.31 randomize>=0.13 -mock; python_version<="2.7" - +{{/useNose}} +{{^useNose}} +pytest~=4.6.7 # needed for python 2.7+3.4 +pytest-cov>=2.8.1 +pytest-randomly==1.2.3 # needed for python 2.7+3.4 +{{/useNose}} +mock; python_version<="2.7" \ No newline at end of file diff --git a/setup_cfg.mustache b/setup_cfg.mustache new file mode 100644 index 0000000000..d89aa72ee4 --- /dev/null +++ b/setup_cfg.mustache @@ -0,0 +1,13 @@ +{{#useNose}} +[nosetests] +logging-clear-handlers=true +verbosity=2 +randomize=true +exe=true +with-coverage=true +cover-package=petstore_api +cover-erase=true + +{{/useNose}} +[flake8] +max-line-length=99 diff --git a/test-requirements.mustache b/test-requirements.mustache index d9e3f20b53..12021b47a1 100644 --- a/test-requirements.mustache +++ b/test-requirements.mustache @@ -1,11 +1,12 @@ -{{^asyncio}} +{{#useNose}} coverage>=4.0.3 nose>=1.3.7 -{{/asyncio}} -{{#asyncio}} -pytest>=3.6.0 -pytest-cov>=2.6.1 -{{/asyncio}} pluggy>=0.3.1 py>=1.4.31 randomize>=0.13 +{{/useNose}} +{{^useNose}} +pytest~=4.6.7 # needed for python 2.7+3.4 +pytest-cov>=2.8.1 +pytest-randomly==1.2.3 # needed for python 2.7+3.4 +{{/useNose}} \ No newline at end of file diff --git a/tox.mustache b/tox.mustache index 585feb3c68..fe989faf93 100644 --- a/tox.mustache +++ b/tox.mustache @@ -11,10 +11,4 @@ deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands= -{{^asyncio}} - nosetests \ - [] -{{/asyncio}} -{{#asyncio}} - pytest -v --cov {{{packageName}}} -{{/asyncio}} + {{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} From 5dd55cc14f0427f2db0a19228394ca4906b3102c Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 3 Jan 2020 22:54:52 +0800 Subject: [PATCH 073/185] replace petstore_api with packageName (#4921) --- setup_cfg.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup_cfg.mustache b/setup_cfg.mustache index d89aa72ee4..931f02c5d1 100644 --- a/setup_cfg.mustache +++ b/setup_cfg.mustache @@ -5,7 +5,7 @@ verbosity=2 randomize=true exe=true with-coverage=true -cover-package=petstore_api +cover-package={{{packageName}}} cover-erase=true {{/useNose}} From e6a668e03597b49826afbaa697a01106247a3150 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 10 Jan 2020 01:43:35 -0800 Subject: [PATCH 074/185] [Python] Allow models to have properties of type self (#4888) * Refactors openapi_types into a staticmethod * Adds a Player model with a self type rpoperty, adds a test to ensure that it is working right --- .../model_templates/classvars.mustache | 28 +++++++++++++------ .../docstring_openapi_validations.mustache | 2 -- .../method_set_attribute.mustache | 5 ++-- python-experimental/model_utils.mustache | 8 +++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index fcd8a71fd1..60fff484ef 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -29,15 +29,6 @@ {{/optionalVars}} } - openapi_types = { -{{#requiredVars}} - '{{name}}': ({{{dataType}}},), # noqa: E501 -{{/requiredVars}} -{{#optionalVars}} - '{{name}}': ({{{dataType}}},), # noqa: E501 -{{/optionalVars}} - } - validations = { {{#requiredVars}} {{#hasValidation}} @@ -103,6 +94,25 @@ additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} + @staticmethod + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { +{{#requiredVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/optionalVars}} + } + @staticmethod def discriminator(): return {{^discriminator}}None{{/discriminator}}{{#discriminator}}{ diff --git a/python-experimental/model_templates/docstring_openapi_validations.mustache b/python-experimental/model_templates/docstring_openapi_validations.mustache index 03eec953f3..f933b86c5b 100644 --- a/python-experimental/model_templates/docstring_openapi_validations.mustache +++ b/python-experimental/model_templates/docstring_openapi_validations.mustache @@ -1,5 +1,3 @@ - openapi_types (dict): The key is attribute name - and the value is attribute type. validations (dict): The key is the tuple path to the attribute and the for var_name this is (var_name,). The value is a dict that stores validations for max_length, min_length, max_items, diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache index f4a36e42f2..bcafb71368 100644 --- a/python-experimental/model_templates/method_set_attribute.mustache +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -6,8 +6,9 @@ path_to_item.extend(self._path_to_item) path_to_item.append(name) - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] + openapi_types = self.openapi_types() + if name in openapi_types: + required_types_mixed = openapi_types[name] elif self.additional_properties_type is None: raise ApiKeyError( "{0} has no key '{1}'".format(type(self).__name__, name), diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index dbd592c37e..c3d9e7d536 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -928,7 +928,7 @@ def get_allof_instances(self, model_args, constant_args): # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(allof_class.openapi_types.keys()) + var_names = set(allof_class.openapi_types().keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -963,7 +963,7 @@ def get_oneof_instance(self, model_args, constant_args): # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) + var_names = set(oneof_class.openapi_types().keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1006,7 +1006,7 @@ def get_anyof_instances(self, model_args, constant_args): # extract a dict of only required keys from these_model_vars kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) + var_names = set(anyof_class.openapi_types().keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1043,7 +1043,7 @@ def get_var_name_to_model_instances(self, composed_instances): all_instances = [self] all_instances.extend(composed_instances) for instance in all_instances: - for var_name in instance.openapi_types: + for var_name in instance.openapi_types(): if var_name not in var_name_to_model_instances: var_name_to_model_instances[var_name] = [instance] else: From 0f0aa0c1ed1d5e41e9d672a9fe3b352119efd8db Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 16 Jan 2020 01:42:23 -0800 Subject: [PATCH 075/185] [Python] Conditionally set auth attributes (#4988) * Enhance python API keys * Run python scripts under ./bin/openapi3 * fix unit test issue * Fix unit tests * Fix unit tests * Invoke bin scripts --- api_client.mustache | 4 +- configuration.mustache | 101 +++++++++++++++--------- python-experimental/api_client.mustache | 4 +- 3 files changed, 67 insertions(+), 42 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 3bf085e190..8297ad5798 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -520,9 +520,7 @@ class ApiClient(object): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting['value']: - continue - elif auth_setting['in'] == 'cookie': + if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] diff --git a/configuration.mustache b/configuration.mustache index b6a89d495d..f53b6f4197 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -22,15 +22,38 @@ class Configuration(object): Do not edit the class manually. :param host: Base url - :param api_key: Dict to store API key(s) + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication + + :Example: + + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + conf = {{{packageName}}}.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} + ) + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 """ def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, - username="", password=""): + username=None, password=None): """Constructor """ self.host = host @@ -247,8 +270,14 @@ class Configuration(object): :return: The token for basic HTTP authentication. """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password return urllib3.util.make_headers( - basic_auth=self.username + ':' + self.password + basic_auth=username + ':' + password ).get('authorization') def auth_settings(self): @@ -256,51 +285,51 @@ class Configuration(object): :return: The Auth Settings information dict. """ - return { + auth = {} {{#authMethods}} {{#isApiKey}} - '{{name}}': - { - 'type': 'api_key', - 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, - 'key': '{{keyParamName}}', - 'value': self.get_api_key_with_prefix('{{keyParamName}}') - }, + if '{{keyParamName}}' in self.api_key: + auth['{{name}}'] = { + 'type': 'api_key', + 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix('{{keyParamName}}') + } {{/isApiKey}} {{#isBasic}} {{^isBasicBearer}} - '{{name}}': - { - 'type': 'basic', - 'in': 'header', - 'key': 'Authorization', - 'value': self.get_basic_auth_token() - }, + if self.username is not None and self.password is not None: + auth['{{name}}'] = { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + } {{/isBasicBearer}} {{#isBasicBearer}} - '{{name}}': - { - 'type': 'bearer', - 'in': 'header', - {{#bearerFormat}} - 'format': '{{{.}}}', - {{/bearerFormat}} - 'key': 'Authorization', - 'value': 'Bearer ' + self.access_token - }, + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'bearer', + 'in': 'header', + {{#bearerFormat}} + 'format': '{{{.}}}', + {{/bearerFormat}} + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } {{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} - '{{name}}': - { - 'type': 'oauth2', - 'in': 'header', - 'key': 'Authorization', - 'value': 'Bearer ' + self.access_token - }, + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } {{/isOAuth}} {{/authMethods}} - } + return auth def to_debug_report(self): """Gets the essential information for debugging. diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 25ca4b5043..c9d7eac63e 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -530,9 +530,7 @@ class ApiClient(object): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting['value']: - continue - elif auth_setting['in'] == 'cookie': + if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] From f22c81787e4aae9e6819357bcb3f7f2abbb1e5a2 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Tue, 21 Jan 2020 07:19:07 -0800 Subject: [PATCH 076/185] Add python-experimental-openapiv3-sample (#4992) Add python-experimental-openapiv3-sample Add missing files for the Python samples Add python-experimental-petstore.bat for openapi v3 Add python-experimental samples openapi v3 Add python-experimental samples openapi v3 Add python-experimental samples openapi v3. Address review comments add missing files for test purpose fix python formatting issues fix python formatting issues fix python formatting issues Fix unit tests fix python formatting issues fix python formatting issues fix python formatting issues fix 'line too long' pep8 error address PR comments for pep8 'line too long' problem regenerate samples execute samples scripts dummy commit to retrigger circleci Revert dummy commit, it didn't help. --- python-experimental/api.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 734c490cab..2182d7362d 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -108,7 +108,8 @@ class {{classname}}(object): ) kwargs['_host_index'] = kwargs.get('_host_index', 0) {{#requiredParams}} - kwargs['{{paramName}}'] = {{paramName}} + kwargs['{{paramName}}'] = \ + {{paramName}} {{/requiredParams}} return self.call_with_http_info(**kwargs) @@ -216,7 +217,8 @@ class {{classname}}(object): }, 'openapi_types': { {{#allParams}} - '{{paramName}}': ({{{dataType}}},), + '{{paramName}}': + ({{{dataType}}},), {{/allParams}} }, 'attribute_map': { From 11fedab25445f136a5cbe23751a8a5cdd6b95617 Mon Sep 17 00:00:00 2001 From: Michele Albano Date: Wed, 22 Jan 2020 15:08:53 +0100 Subject: [PATCH 077/185] Rebased to current upstream/master. (#4514) Tests for python client, comprising support for additional_properties and arrays. There are ugly workarounds for when there are discriminators, since the python client generator does not fully handle them. Cool indentation of test files. --- model_test.mustache | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/model_test.mustache b/model_test.mustache index 765e4f9c2c..b69f13f744 100644 --- a/model_test.mustache +++ b/model_test.mustache @@ -5,6 +5,7 @@ from __future__ import absolute_import import unittest +import datetime {{#models}} {{#model}} @@ -12,7 +13,6 @@ import {{packageName}} from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 from {{packageName}}.rest import ApiException - class Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" @@ -22,11 +22,31 @@ class Test{{classname}}(unittest.TestCase): def tearDown(self): pass + def make_instance(self, include_optional): + """Test {{classname}} + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 + if include_optional : + return {{classname}}( +{{#vars}} + {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}{{#hasMore}}, {{/hasMore}} +{{/vars}} + ) + else : + return {{classname}}( +{{#vars}} +{{#required}} + {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}, +{{/required}} +{{/vars}} + ) + def test{{classname}}(self): """Test {{classname}}""" - # FIXME: construct object with mandatory attributes with example values - # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 - pass + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) {{/model}} {{/models}} From 0cccbfba2affac4e4ab30f41dcda01bc4b481201 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 23 Jan 2020 18:35:56 -0800 Subject: [PATCH 078/185] [HttpBasicAuth] Use positive isBasicBasic tag instead of negative isBasicBearer (#5095) * use positive isBasicBasic tag instead of negative isBasicBearer * use positive isBasicBasic tag instead of negative isBasicBearer --- api_doc.mustache | 4 ++-- common_README.mustache | 4 ++-- configuration.mustache | 4 ++-- python-experimental/README_common.mustache | 4 ++-- python-experimental/api_doc.mustache | 4 ++-- python_doc_auth_partial.mustache | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api_doc.mustache b/api_doc.mustache index 1df5389c5c..fb537ad30b 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -22,9 +22,9 @@ Method | HTTP request | Description {{#hasAuthMethods}} {{#authMethods}} {{#isBasic}} -{{^isBasicBearer}} +{{#isBasicBasic}} * Basic Authentication ({{name}}): -{{/isBasicBearer}} +{{/isBasicBasic}} {{#isBasicBearer}} * Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): {{/isBasicBearer}} diff --git a/common_README.mustache b/common_README.mustache index 7238703c4b..7de8c9ef09 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -51,9 +51,9 @@ Class | Method | HTTP request | Description - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} {{#isBasic}} -{{^isBasicBearer}} +{{#isBasicBasic}} - **Type**: HTTP basic authentication -{{/isBasicBearer}} +{{/isBasicBasic}} {{#isBasicBearer}} - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} {{/isBasicBearer}} diff --git a/configuration.mustache b/configuration.mustache index f53b6f4197..1aed945621 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -297,7 +297,7 @@ class Configuration(object): } {{/isApiKey}} {{#isBasic}} - {{^isBasicBearer}} + {{#isBasicBasic}} if self.username is not None and self.password is not None: auth['{{name}}'] = { 'type': 'basic', @@ -305,7 +305,7 @@ class Configuration(object): 'key': 'Authorization', 'value': self.get_basic_auth_token() } - {{/isBasicBearer}} + {{/isBasicBasic}} {{#isBasicBearer}} if self.access_token is not None: auth['{{name}}'] = { diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index a8b66b0bed..d8185eea5a 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -50,9 +50,9 @@ Class | Method | HTTP request | Description - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} {{#isBasic}} -{{^isBasicBearer}} +{{#isBasicBasic}} - **Type**: HTTP basic authentication -{{/isBasicBearer}} +{{/isBasicBasic}} {{#isBasicBearer}} - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} {{/isBasicBearer}} diff --git a/python-experimental/api_doc.mustache b/python-experimental/api_doc.mustache index 4feb612f1c..10317b4b48 100644 --- a/python-experimental/api_doc.mustache +++ b/python-experimental/api_doc.mustache @@ -22,9 +22,9 @@ Method | HTTP request | Description {{#hasAuthMethods}} {{#authMethods}} {{#isBasic}} -{{^isBasicBearer}} +{{#isBasicBasic}} * Basic Authentication ({{name}}): -{{/isBasicBearer}} +{{/isBasicBasic}} {{#isBasicBearer}} * Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): {{/isBasicBearer}} diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 899e4b58b9..2e74426103 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -2,11 +2,11 @@ {{#authMethods}} configuration = {{{packageName}}}.Configuration() {{#isBasic}} -{{^isBasicBearer}} +{{#isBasicBasic}} # Configure HTTP basic authorization: {{{name}}} configuration.username = 'YOUR_USERNAME' configuration.password = 'YOUR_PASSWORD' -{{/isBasicBearer}} +{{/isBasicBasic}} {{#isBasicBearer}} # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} configuration.access_token = 'YOUR_BEARER_TOKEN' From c0924d16ea14332d4490cbd6ce067a28e330a0e1 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Sun, 26 Jan 2020 18:17:26 -0800 Subject: [PATCH 079/185] [Python] Support for HTTP signature (#4958) * start implementation of HTTP signature * add api key parameters for http message signature * HTTP signature authentication * start implementation of HTTP signature * add api key parameters for http message signature * HTTP signature authentication * HTTP signature authentication * start implementation of HTTP signature * fix merge issues * Address formatting issues * Address formatting issues * move python-experimental-openapiv3-sample to a separate PR * Add support for HTTP signature * Add code comments * Add code comments * Fix formatting issues * Fix formatting issues * Fix formatting issues * add code comments * add code comments * fix python formatting issues * Make PKCS1v15 string constant consistent between Python and Golang * fix python formatting issues * Add code comments in generated Python. Start adding unit tests for HTTP signature * compliance with HTTP signature draft 12 * compliance with HTTP signature draft 12 * working on review comments * working on review comments * working on review comments * working on review comments * working on review comments * working on review comments * working on review comments * working on review comments * working on review comments * fix python formatting issues * fix trailing white space * address PR comments * address PR comments * address PR comments * Add suppport for '(expires)' signature parameter * address PR comments * address PR comments * Fix python formatting issues * Fix python formatting issues * Starting to move code to dedicated file for HTTP signatures * Continue to refactor code to dedicated file for HTTP signatures * Continue to refactor code to dedicated file for HTTP signatures * Continue to refactor code to dedicated file for HTTP signatures * Continue to refactor code to dedicated file for HTTP signatures * move method to ProcessUtils * conditionally build signing.py * move method to ProcessUtils * Code reformatting * externalize http signature configuration * address PR review comments * address PR review comments * run samples scripts * Address PR review comments * Move 'private_key' field to signing module * Move 'private_key' field to signing module * code cleanup * remove use of strftime('%s'), which is non portable * code cleanup * code cleanup * code cleanup * run sample scripts * Address PR review comments. * Add http-signature security scheme * Run sample scripts for go * Fix issue uncovered in integration branch * Fix issue uncovered in integration branch * Fix issue uncovered in integration branch * Fix issue uncovered in integration branch * Run samples scripts * move http signature tests to separate file * move http signature tests to separate file * unit tests for HTTP signature * continue implementation of unit tests * add http_signature_test to security scheme * add unit tests for http signature * address review comments * remove http signature from petapi * Add separate OAS file with support for HTTP signature * Add support for private key passphrase. Add more unit tests * Add unit test to validate the signature against the public key * remove http signature from petstore-with-fake-endpoints-models-for-testing.yaml * fix unit test issues * run scripts in bin directory * Refact unit test with better variable names * do not throw exception if security scheme is unrecognized * change URL of apache license to use https * sync from master * fix usage of escape character in python regex. Fix generated python documentation * write HTTP signed headers in user-specified order. Fix PEP8 formatting issues * write HTTP signed headers in user-specified order. Fix PEP8 formatting issues * http signature unit tests * Fix PEP8 format issue * spread out each requirement to a separate line * run samples scripts * run sample scripts * remove encoding of '+' character --- configuration.mustache | 57 ++- python-experimental/README_common.mustache | 3 + python-experimental/api.mustache | 2 +- python-experimental/api_client.mustache | 26 +- python-experimental/setup.mustache | 15 +- python-experimental/signing.mustache | 368 ++++++++++++++++++ .../test-requirements.mustache | 3 + python_doc_auth_partial.mustache | 22 ++ 8 files changed, 486 insertions(+), 10 deletions(-) create mode 100644 python-experimental/signing.mustache diff --git a/configuration.mustache b/configuration.mustache index 1aed945621..3e0a156765 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -31,6 +31,8 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication + :param signing_info: Configuration parameters for HTTP signature. + Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration :Example: @@ -49,11 +51,50 @@ class Configuration(object): ) The following cookie will be added to the HTTP request: Cookie: JSESSIONID abc123 + + Configure API client with HTTP basic authentication: + conf = {{{packageName}}}.Configuration( + username='the-user', + password='the-password', + ) + + Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, + sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time + of the signature to 5 minutes after the signature has been created. + Note you can use the constants defined in the {{{packageName}}}.signing module, and you can + also specify arbitrary HTTP headers to be included in the HTTP signature, except for the + 'Authorization' header, which is used to carry the signature. + + One may be tempted to sign all headers by default, but in practice it rarely works. + This is beccause explicit proxies, transparent proxies, TLS termination endpoints or + load balancers may add/modify/remove headers. Include the HTTP headers that you know + are not going to be modified in transit. + + conf = {{{packageName}}}.Configuration( + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = signing.SCHEME_HS2019, + signing_algorithm = signing.ALGORITHM_RSASSA_PSS, + signed_headers = [signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + signing.HEADER_EXPIRES, + signing.HEADER_HOST, + signing.HEADER_DATE, + signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) + ) """ def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, - username=None, password=None): + username=None, password=None, + signing_info=None): """Constructor """ self.host = host @@ -82,6 +123,11 @@ class Configuration(object): self.password = password """Password for HTTP basic authentication """ + if signing_info is not None: + signing_info.host = host + self.signing_info = signing_info + """The HTTP signing configuration + """ {{#hasOAuthMethods}} self.access_token = "" """access token for OAuth/Bearer @@ -318,6 +364,15 @@ class Configuration(object): 'value': 'Bearer ' + self.access_token } {{/isBasicBearer}} + {{#isHttpSignature}} + if self.signing_info is not None: + auth['{{name}}'] = { + 'type': 'http-signature', + 'in': 'header', + 'key': 'Authorization', + 'value': None # Signature headers are calculated for every HTTP request + } + {{/isHttpSignature}} {{/isBasic}} {{#isOAuth}} if self.access_token is not None: diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index d8185eea5a..5fffdc74fc 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -56,6 +56,9 @@ Class | Method | HTTP request | Description {{#isBasicBearer}} - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} {{/isBasicBearer}} +{{#isHttpSignature}} +- **Type**: HTTP signature authentication +{{/isHttpSignature}} {{/isBasic}} {{#isOAuth}} - **Type**: OAuth diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 2182d7362d..8390a848d2 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -120,7 +120,7 @@ class {{classname}}(object): {{#-first}} 'auth': [ {{/-first}} - '{{name}}'{{#hasMore}}, {{/hasMore}} + '{{name}}'{{#hasMore}},{{/hasMore}} {{#-last}} ], {{/-last}} diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index c9d7eac63e..9520896120 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -150,13 +150,14 @@ class ApiClient(object): collection_formats) post_params.extend(self.files_parameters(files)) - # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings) - # body if body: body = self.sanitize_for_serialization(body) + # auth setting + self.update_params_for_auth(header_params, query_params, + auth_settings, resource_path, method, body) + # request url if _host is None: url = self.configuration.host + resource_path @@ -517,12 +518,17 @@ class ApiClient(object): else: return content_types[0] - def update_params_for_auth(self, headers, querys, auth_settings): + def update_params_for_auth(self, headers, querys, auth_settings, + resource_path, method, body): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). """ if not auth_settings: return @@ -533,7 +539,17 @@ class ApiClient(object): if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] +{{#hasHttpSignatureMethods}} + else: + # The HTTP signature scheme requires multiple HTTP headers + # that are calculated dynamically. + signing_info = self.configuration.signing_info + auth_headers = signing_info.get_http_signature_headers( + resource_path, method, headers, body, querys) + headers.update(auth_headers) +{{/hasHttpSignatureMethods}} elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index bf9ffe07d0..2fe84efcee 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -16,13 +16,22 @@ VERSION = "{{packageVersion}}" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +REQUIRES = [ + "urllib3 >= 1.15", + "six >= 1.10", + "certifi", + "python-dateutil", {{#asyncio}} -REQUIRES.append("aiohttp >= 3.0.0") + "aiohttp >= 3.0.0", {{/asyncio}} {{#tornado}} -REQUIRES.append("tornado>=4.2,<5") + "tornado>=4.2,<5", {{/tornado}} +{{#hasHttpSignatureMethods}} + "pem>=19.3.0", + "pycryptodome>=3.9.0", +{{/hasHttpSignatureMethods}} +] EXTRAS = {':python_version <= "2.7"': ['future']} setup( diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache new file mode 100644 index 0000000000..d191bbf485 --- /dev/null +++ b/python-experimental/signing.mustache @@ -0,0 +1,368 @@ +# coding: utf-8 +{{>partial_header}} +from __future__ import absolute_import + +from base64 import b64encode +from Crypto.IO import PEM, PKCS8 +from Crypto.Hash import SHA256, SHA512 +from Crypto.PublicKey import RSA, ECC +from Crypto.Signature import PKCS1_v1_5, pss, DSS +from datetime import datetime +from email.utils import formatdate +import json +import os +import re +from six.moves.urllib.parse import urlencode, urlparse +from time import mktime + +HEADER_REQUEST_TARGET = '(request-target)' +HEADER_CREATED = '(created)' +HEADER_EXPIRES = '(expires)' +HEADER_HOST = 'Host' +HEADER_DATE = 'Date' +HEADER_DIGEST = 'Digest' # RFC 3230, include digest of the HTTP request body. +HEADER_AUTHORIZATION = 'Authorization' + +SCHEME_HS2019 = 'hs2019' +SCHEME_RSA_SHA256 = 'rsa-sha256' +SCHEME_RSA_SHA512 = 'rsa-sha512' + +ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' +ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' + +ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { + ALGORITHM_ECDSA_MODE_FIPS_186_3, + ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 +} + + +class HttpSigningConfiguration(object): + """The configuration parameters for the HTTP signature security scheme. + The HTTP signature security scheme is used to sign HTTP requests with a private key + which is in possession of the API client. + An 'Authorization' header is calculated by creating a hash of select headers, + and optionally the body of the HTTP request, then signing the hash value using + a private key. The 'Authorization' header is added to outbound HTTP requests. + + NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param key_id: A string value specifying the identifier of the cryptographic key, + when signing HTTP requests. + :param signing_scheme: A string value specifying the signature scheme, when + signing HTTP requests. + Supported value are hs2019, rsa-sha256, rsa-sha512. + Avoid using rsa-sha256, rsa-sha512 as they are deprecated. These values are + available for server-side applications that only support the older + HTTP signature algorithms. + :param private_key_path: A string value specifying the path of the file containing + a private key. The private key is used to sign HTTP requests. + :param private_key_passphrase: A string value specifying the passphrase to decrypt + the private key. + :param signed_headers: A list of strings. Each value is the name of a HTTP header + that must be included in the HTTP signature calculation. + The two special signature headers '(request-target)' and '(created)' SHOULD be + included in SignedHeaders. + The '(created)' header expresses when the signature was created. + The '(request-target)' header is a concatenation of the lowercased :method, an + ASCII space, and the :path pseudo-headers. + When signed_headers is not specified, the client defaults to a single value, + '(created)', in the list of HTTP headers. + When SignedHeaders contains the 'Digest' value, the client performs the + following operations: + 1. Calculate a digest of request body, as specified in RFC3230, section 4.3.2. + 2. Set the 'Digest' header in the request body. + 3. Include the 'Digest' header and value in the HTTP signature. + :param signing_algorithm: A string value specifying the signature algorithm, when + signing HTTP requests. + Supported values are: + 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. + 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. + The default value is inferred from the private key. + The default value for RSA keys is RSASSA-PSS. + The default value for ECDSA keys is fips-186-3. + :param signature_max_validity: The signature max validity, expressed as + a datetime.timedelta value. It must be a positive value. + """ + def __init__(self, key_id, signing_scheme, private_key_path, + private_key_passphrase=None, + signed_headers=None, + signing_algorithm=None, + signature_max_validity=None): + self.key_id = key_id + if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: + raise Exception("Unsupported security scheme: {0}".format(signing_scheme)) + self.signing_scheme = signing_scheme + if not os.path.exists(private_key_path): + raise Exception("Private key file does not exist") + self.private_key_path = private_key_path + self.private_key_passphrase = private_key_passphrase + self.signing_algorithm = signing_algorithm + if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: + raise Exception("The signature max validity must be a positive value") + self.signature_max_validity = signature_max_validity + # If the user has not provided any signed_headers, the default must be set to '(created)', + # as specified in the 'HTTP signature' standard. + if signed_headers is None or len(signed_headers) == 0: + signed_headers = [HEADER_CREATED] + if self.signature_max_validity is None and HEADER_EXPIRES in signed_headers: + raise Exception( + "Signature max validity must be set when " + "'(expires)' signature parameter is specified") + if len(signed_headers) != len(set(signed_headers)): + raise Exception("Cannot have duplicates in the signed_headers parameter") + if HEADER_AUTHORIZATION in signed_headers: + raise Exception("'Authorization' header cannot be included in signed headers") + self.signed_headers = signed_headers + self.private_key = None + """The private key used to sign HTTP requests. + Initialized when the PEM-encoded private key is loaded from a file. + """ + self.host = None + """The host name, optionally followed by a colon and TCP port number. + """ + self._load_private_key() + + def get_http_signature_headers(self, resource_path, method, headers, body, query_params): + """Create a cryptographic message signature for the HTTP request and add the signed headers. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A dict of HTTP headers that must be added to the outbound HTTP request. + """ + if method is None: + raise Exception("HTTP method must be set") + if resource_path is None: + raise Exception("Resource path must be set") + + signed_headers_list, request_headers_dict = self._get_signed_header_info( + resource_path, method, headers, body, query_params) + + header_items = [ + "{0}: {1}".format(key.lower(), value) for key, value in signed_headers_list] + string_to_sign = "\n".join(header_items) + + digest, digest_prefix = self._get_message_digest(string_to_sign.encode()) + b64_signed_msg = self._sign_digest(digest) + + request_headers_dict[HEADER_AUTHORIZATION] = self._get_authorization_header( + signed_headers_list, b64_signed_msg) + + return request_headers_dict + + def get_public_key(self): + """Returns the public key object associated with the private key. + """ + pubkey = None + if isinstance(self.private_key, RSA.RsaKey): + pubkey = self.private_key.publickey() + elif isinstance(self.private_key, ECC.EccKey): + pubkey = self.private_key.public_key() + return pubkey + + def _load_private_key(self): + """Load the private key used to sign HTTP requests. + The private key is used to sign HTTP requests as defined in + https://datatracker.ietf.org/doc/draft-cavage-http-signatures/. + """ + if self.private_key is not None: + return + with open(self.private_key_path, 'r') as f: + pem_data = f.read() + # Verify PEM Pre-Encapsulation Boundary + r = re.compile(r"\s*-----BEGIN (.*)-----\s+") + m = r.match(pem_data) + if not m: + raise ValueError("Not a valid PEM pre boundary") + pem_header = m.group(1) + if pem_header == 'RSA PRIVATE KEY': + self.private_key = RSA.importKey(pem_data, self.private_key_passphrase) + elif pem_header == 'EC PRIVATE KEY': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + elif pem_header in {'PRIVATE KEY', 'ENCRYPTED PRIVATE KEY'}: + # Key is in PKCS8 format, which is capable of holding many different + # types of private keys, not just EC keys. + (key_binary, pem_header, is_encrypted) = \ + PEM.decode(pem_data, self.private_key_passphrase) + (oid, privkey, params) = \ + PKCS8.unwrap(key_binary, passphrase=self.private_key_passphrase) + if oid == '1.2.840.10045.2.1': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + else: + raise Exception("Unsupported key: {0}. OID: {1}".format(pem_header, oid)) + else: + raise Exception("Unsupported key: {0}".format(pem_header)) + # Validate the specified signature algorithm is compatible with the private key. + if self.signing_algorithm is not None: + supported_algs = None + if isinstance(self.private_key, RSA.RsaKey): + supported_algs = {ALGORITHM_RSASSA_PSS, ALGORITHM_RSASSA_PKCS1v15} + elif isinstance(self.private_key, ECC.EccKey): + supported_algs = ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS + if supported_algs is not None and self.signing_algorithm not in supported_algs: + raise Exception( + "Signing algorithm {0} is not compatible with private key".format( + self.signing_algorithm)) + + def _get_unix_time(self, ts): + """Converts and returns a datetime object to UNIX time, the number of seconds + elapsed since January 1, 1970 UTC. + """ + return (ts - datetime(1970, 1, 1)).total_seconds() + + def _get_signed_header_info(self, resource_path, method, headers, body, query_params): + """Build the HTTP headers (name, value) that need to be included in + the HTTP signature scheme. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object (e.g. a dict) representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A tuple containing two dict objects: + The first dict contains the HTTP headers that are used to calculate + the HTTP signature. + The second dict contains the HTTP headers that must be added to + the outbound HTTP request. + """ + + if body is None: + body = '' + else: + body = json.dumps(body) + + # Build the '(request-target)' HTTP signature parameter. + target_host = urlparse(self.host).netloc + target_path = urlparse(self.host).path + request_target = method.lower() + " " + target_path + resource_path + if query_params: + request_target += "?" + urlencode(query_params) + + # Get current time and generate RFC 1123 (HTTP/1.1) date/time string. + now = datetime.now() + stamp = mktime(now.timetuple()) + cdate = formatdate(timeval=stamp, localtime=False, usegmt=True) + # The '(created)' value MUST be a Unix timestamp integer value. + # Subsecond precision is not supported. + created = int(self._get_unix_time(now)) + if self.signature_max_validity is not None: + expires = self._get_unix_time(now + self.signature_max_validity) + + signed_headers_list = [] + request_headers_dict = {} + for hdr_key in self.signed_headers: + hdr_key = hdr_key.lower() + if hdr_key == HEADER_REQUEST_TARGET: + value = request_target + elif hdr_key == HEADER_CREATED: + value = '{0}'.format(created) + elif hdr_key == HEADER_EXPIRES: + value = '{0}'.format(expires) + elif hdr_key == HEADER_DATE.lower(): + value = cdate + request_headers_dict[HEADER_DATE] = '{0}'.format(cdate) + elif hdr_key == HEADER_DIGEST.lower(): + request_body = body.encode() + body_digest, digest_prefix = self._get_message_digest(request_body) + b64_body_digest = b64encode(body_digest.digest()) + value = digest_prefix + b64_body_digest.decode('ascii') + request_headers_dict[HEADER_DIGEST] = '{0}{1}'.format( + digest_prefix, b64_body_digest.decode('ascii')) + elif hdr_key == HEADER_HOST.lower(): + value = target_host + request_headers_dict[HEADER_HOST] = '{0}'.format(target_host) + else: + value = next((v for k, v in headers.items() if k.lower() == hdr_key), None) + if value is None: + raise Exception( + "Cannot sign HTTP request. " + "Request does not contain the '{0}' header".format(hdr_key)) + signed_headers_list.append((hdr_key, value)) + + return signed_headers_list, request_headers_dict + + def _get_message_digest(self, data): + """Calculates and returns a cryptographic digest of a specified HTTP request. + + :param data: The string representation of the date to be hashed with a cryptographic hash. + :return: A tuple of (digest, prefix). + The digest is a hashing object that contains the cryptographic digest of + the HTTP request. + The prefix is a string that identifies the cryptographc hash. It is used + to generate the 'Digest' header as specified in RFC 3230. + """ + if self.signing_scheme in {SCHEME_RSA_SHA512, SCHEME_HS2019}: + digest = SHA512.new() + prefix = 'SHA-512=' + elif self.signing_scheme == SCHEME_RSA_SHA256: + digest = SHA256.new() + prefix = 'SHA-256=' + else: + raise Exception("Unsupported signing algorithm: {0}".format(self.signing_scheme)) + digest.update(data) + return digest, prefix + + def _sign_digest(self, digest): + """Signs a message digest with a private key specified in the signing_info. + + :param digest: A hashing object that contains the cryptographic digest of the HTTP request. + :return: A base-64 string representing the cryptographic signature of the input digest. + """ + sig_alg = self.signing_algorithm + if isinstance(self.private_key, RSA.RsaKey): + if sig_alg is None or sig_alg == ALGORITHM_RSASSA_PSS: + # RSASSA-PSS in Section 8.1 of RFC8017. + signature = pss.new(self.private_key).sign(digest) + elif sig_alg == ALGORITHM_RSASSA_PKCS1v15: + # RSASSA-PKCS1-v1_5 in Section 8.2 of RFC8017. + signature = PKCS1_v1_5.new(self.private_key).sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + elif isinstance(self.private_key, ECC.EccKey): + if sig_alg is None: + sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 + if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: + signature = DSS.new(self.private_key, sig_alg).sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + else: + raise Exception("Unsupported private key: {0}".format(type(self.private_key))) + return b64encode(signature) + + def _get_authorization_header(self, signed_headers, signed_msg): + """Calculates and returns the value of the 'Authorization' header when signing HTTP requests. + + :param signed_headers : A list of tuples. Each value is the name of a HTTP header that + must be included in the HTTP signature calculation. + :param signed_msg: A base-64 encoded string representation of the signature. + :return: The string value of the 'Authorization' header, representing the signature + of the HTTP request. + """ + created_ts = None + expires_ts = None + for k, v in signed_headers: + if k == HEADER_CREATED: + created_ts = v + elif k == HEADER_EXPIRES: + expires_ts = v + lower_keys = [k.lower() for k, v in signed_headers] + headers_value = " ".join(lower_keys) + + auth_str = "Signature keyId=\"{0}\",algorithm=\"{1}\",".format( + self.key_id, self.signing_scheme) + if created_ts is not None: + auth_str = auth_str + "created={0},".format(created_ts) + if expires_ts is not None: + auth_str = auth_str + "expires={0},".format(expires_ts) + auth_str = auth_str + "headers=\"{0}\",signature=\"{1}\"".format( + headers_value, signed_msg.decode('ascii')) + + print("AUTH: {0}".format(auth_str)) + return auth_str diff --git a/python-experimental/test-requirements.mustache b/python-experimental/test-requirements.mustache index 338b229bae..ebdee3392e 100644 --- a/python-experimental/test-requirements.mustache +++ b/python-experimental/test-requirements.mustache @@ -10,4 +10,7 @@ pytest~=4.6.7 # needed for python 2.7+3.4 pytest-cov>=2.8.1 pytest-randomly==1.2.3 # needed for python 2.7+3.4 {{/useNose}} +{{#hasHttpSignatureMethods}} +pycryptodome>=3.9.0 +{{/hasHttpSignatureMethods}} mock; python_version<="2.7" \ No newline at end of file diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 2e74426103..9f5b49f821 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -11,6 +11,28 @@ configuration.password = 'YOUR_PASSWORD' # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} configuration.access_token = 'YOUR_BEARER_TOKEN' {{/isBasicBearer}} +{{#isHttpSignature}} +# Configure HTTP signature authorization: {{{name}}} +# You can specify the signing key-id, private key path, signing scheme, signing algorithm, +# list of signed headers and signature max validity. +configuration.signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = signing.SCHEME_HS2019, + signing_algorithm = signing.ALGORITHM_RSASSA_PSS, + signed_headers = [signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + signing.HEADER_EXPIRES, + signing.HEADER_HOST, + signing.HEADER_DATE, + signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) +) +{{/isHttpSignature}} {{/isBasic}} {{#isApiKey}} # Configure API key authorization: {{{name}}} From 73b434916e889df56b9a81ab1107f3c1e38638f4 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Tue, 28 Jan 2020 21:58:11 -0800 Subject: [PATCH 080/185] [python] Cleanup ThreadPool with atexit rather than __del__ (#5094) * [python] Cleanup ThreadPool with atexit rather than __del__ This removes the `__del__` function from the generated Python client, and replaces it with a `cleanup` function. When a ThreadPool is created, the cleanup function is registered with the `atexit` module. This fixes #5093, where the API client could hang indefinitely at garbage collection. * Update petstore examples * Test to ensure threadpool is cleaned up * Docs now encourage using the context manager * Regenerate docs * Update samples --- api_client.mustache | 12 ++- api_doc_example.mustache | 32 ++++---- common_README.mustache | 24 +++--- python-experimental/README_common.mustache | 24 +++--- python-experimental/api_client.mustache | 12 ++- python-experimental/api_doc_example.mustache | 86 ++++++++++---------- 6 files changed, 111 insertions(+), 79 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 8297ad5798..08de3bab85 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -2,6 +2,7 @@ {{>partial_header}} from __future__ import absolute_import +import atexit import datetime from dateutil.parser import parse import json @@ -75,11 +76,19 @@ class ApiClient(object): self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' self.client_side_validation = configuration.client_side_validation - def __del__(self): + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): if self._pool: self._pool.close() self._pool.join() self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) @property def pool(self): @@ -87,6 +96,7 @@ class ApiClient(object): avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: + atexit.register(self.close) self._pool = ThreadPool(self.pool_threads) return self._pool diff --git a/api_doc_example.mustache b/api_doc_example.mustache index f2d6117a7c..e86c5d6011 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -8,22 +8,26 @@ from pprint import pprint {{#hasAuthMethods}} # Defining host is optional and default to {{{basePath}}} configuration.host = "{{{basePath}}}" -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}() -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient() as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} {{/hasAuthMethods}} -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) ``` diff --git a/common_README.mustache b/common_README.mustache index 7de8c9ef09..991002aa17 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -8,18 +8,20 @@ from pprint import pprint {{> python_doc_auth_partial}} # Defining host is optional and default to {{{basePath}}} configuration.host = "{{{basePath}}}" -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` ## Documentation for API Endpoints diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index 5fffdc74fc..b474eb264a 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -7,18 +7,20 @@ from pprint import pprint {{> python_doc_auth_partial}} # Defining host is optional and default to {{{basePath}}} configuration.host = "{{{basePath}}}" -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` ## Documentation for API Endpoints diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 9520896120..78f502b00d 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -3,6 +3,7 @@ from __future__ import absolute_import import json +import atexit import mimetypes from multiprocessing.pool import ThreadPool import os @@ -74,11 +75,19 @@ class ApiClient(object): # Set default User-Agent. self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' - def __del__(self): + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): if self._pool: self._pool.close() self._pool.join() self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) @property def pool(self): @@ -86,6 +95,7 @@ class ApiClient(object): avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: + atexit.register(self.close) self._pool = ThreadPool(self.pool_threads) return self._pool diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index 8a6beabd2d..565d00a3b9 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -7,51 +7,55 @@ from pprint import pprint {{#hasAuthMethods}} # Defining host is optional and default to {{{basePath}}} configuration.host = "{{{basePath}}}" -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{/hasAuthMethods}} {{^hasAuthMethods}} -# Create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}() +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{/hasAuthMethods}} -{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} -{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} -{{/optionalParams}} -{{#requiredParams}} -{{^hasMore}} + {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} + {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} + {{/optionalParams}} + {{#requiredParams}} + {{^hasMore}} -# example passing only required values which don't have defaults set -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/hasMore}} -{{/requiredParams}} -{{#optionalParams}} -{{^hasMore}} + # example passing only required values which don't have defaults set + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + {{/hasMore}} + {{/requiredParams}} + {{#optionalParams}} + {{^hasMore}} -# example passing only required values which don't have defaults set -# and optional values -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/hasMore}} -{{/optionalParams}} -{{^requiredParams}} -{{^optionalParams}} + # example passing only required values which don't have defaults set + # and optional values + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + {{/hasMore}} + {{/optionalParams}} + {{^requiredParams}} + {{^optionalParams}} -# example, this endpoint has no required or optional parameters -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} - pprint(api_response){{/returnType}} -except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/optionalParams}} -{{/requiredParams}} + # example, this endpoint has no required or optional parameters + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} + pprint(api_response){{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) + {{/optionalParams}} + {{/requiredParams}} ``` From f538592ff5894788002a0a7e2e4b9bfc7b37d52d Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Wed, 29 Jan 2020 10:18:57 +0100 Subject: [PATCH 081/185] Switch to predominant use of appDescriptionWithNewLines in README.mustache (#5109) Descriptions tend to get lengthy and can include multiple lines. New lines are important to markdown formatting/syntax and can't just be ignored. Resolves https://github.com/OpenAPITools/openapi-generator/issues/3704 --- README.mustache | 6 +++--- python-experimental/README.mustache | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.mustache b/README.mustache index 94d72af33d..9d854a4f1b 100644 --- a/README.mustache +++ b/README.mustache @@ -1,7 +1,7 @@ # {{{projectName}}} -{{#appDescription}} -{{{appDescription}}} -{{/appDescription}} +{{#appDescriptionWithNewLines}} +{{{appDescriptionWithNewLines}}} +{{/appDescriptionWithNewLines}} This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: diff --git a/python-experimental/README.mustache b/python-experimental/README.mustache index f26408cf66..72c7f3de3f 100644 --- a/python-experimental/README.mustache +++ b/python-experimental/README.mustache @@ -1,7 +1,7 @@ # {{{projectName}}} -{{#appDescription}} -{{{appDescription}}} -{{/appDescription}} +{{#appDescriptionWithNewLines}} +{{{appDescriptionWithNewLines}}} +{{/appDescriptionWithNewLines}} This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: From 0df7216b683a6d15baa8e0cb0cadd2007042fd9d Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 29 Jan 2020 10:10:41 -0800 Subject: [PATCH 082/185] [Python] Fix #5126 operations with req enums of length one (#5129) * Updates ap.mustache for python-experimental, adds test test_test_endpoint_enums_length_one * Removes sortParamsByRequiredFlag from python-experimental * Removes duplicate params from docstring --- python-experimental/api.mustache | 90 ++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 8390a848d2..4cf1d423e8 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -45,7 +45,20 @@ class {{classname}}(object): self.api_client = api_client {{#operation}} - def __{{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + def __{{operationId}}( + self, +{{#requiredParams}} +{{^defaultValue}} + {{paramName}}, +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}}={{{defaultValue}}}, +{{/defaultValue}} +{{/requiredParams}} + **kwargs + ): """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} @@ -53,40 +66,51 @@ class {{classname}}(object): {{/notes}} This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True -{{#sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} -{{^sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) >>> result = thread.get() - :param async_req bool: execute request asynchronously - Default is False. -{{#allParams}} - :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} -{{/allParams}} - :param _return_http_data_only: response data without head status - code and headers. Default is True. - :param _preload_content: if False, the urllib3.HTTPResponse object - will be returned without reading/decoding response data. - Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - :param _check_input_type: boolean specifying if type checking - should be done one the data sent to the server. - Default is True. - :param _check_return_type: boolean specifying if type checking - should be done one the data received from the server. - Default is True. - :param _host_index: integer specifying the index of the server - that we want to use. - Default is 0. - :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} - If the method is called asynchronously, returns the request - thread. +{{#requiredParams}} +{{^hasMore}} + Args: +{{/hasMore}} +{{/requiredParams}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}} +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] +{{/defaultValue}} +{{/requiredParams}} + + Keyword Args:{{#optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int): specifies the index of the server + that we want to use. + Default is 0. + async_req (bool): execute request asynchronously + + Returns: + {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, returns the request + thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False From d296a2d73f80a442881a47c331f815c1ddb4e3ec Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Mon, 3 Feb 2020 09:39:17 -0800 Subject: [PATCH 083/185] [Python] Python HTTP signature update (#5154) * improve python documentation and add import to __init__package.mustache * improve python documentation and add import to __init__package.mustache * add signing_info parameter conditionally * add code comments and remove 'Content-Length' header from example * Remove debug log statement * set access_token to None by default * set access_token to None by default * fix unit tests for Python experimental * fix trailing space --- configuration.mustache | 41 +++++++++++++++++--- python-experimental/__init__package.mustache | 3 ++ python-experimental/signing.mustache | 20 +++++++++- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 3e0a156765..0645bc4675 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -31,11 +31,16 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication - :param signing_info: Configuration parameters for HTTP signature. +{{#hasHttpSignatureMethods}} + :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration +{{/hasHttpSignatureMethods}} +{{#hasAuthMethods}} :Example: +{{#hasApiKeyMethods}} + API Key Authentication Example. Given the following security scheme in the OpenAPI specification: components: securitySchemes: @@ -51,12 +56,32 @@ class Configuration(object): ) The following cookie will be added to the HTTP request: Cookie: JSESSIONID abc123 +{{/hasApiKeyMethods}} +{{#hasHttpBasicMethods}} + + HTTP Basic Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: basic Configure API client with HTTP basic authentication: conf = {{{packageName}}}.Configuration( username='the-user', password='the-password', ) +{{/hasHttpBasicMethods}} +{{#hasHttpSignatureMethods}} + + HTTP Signature Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: signature Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time @@ -83,18 +108,22 @@ class Configuration(object): signing.HEADER_DATE, signing.HEADER_DIGEST, 'Content-Type', - 'Content-Length', 'User-Agent' ], signature_max_validity = datetime.timedelta(minutes=5) ) ) +{{/hasHttpSignatureMethods}} +{{/hasAuthMethods}} """ def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, username=None, password=None, - signing_info=None): +{{#hasHttpSignatureMethods}} + signing_info=None, +{{/hasHttpSignatureMethods}} + ): """Constructor """ self.host = host @@ -123,19 +152,21 @@ class Configuration(object): self.password = password """Password for HTTP basic authentication """ +{{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host self.signing_info = signing_info """The HTTP signing configuration """ +{{/hasHttpSignatureMethods}} {{#hasOAuthMethods}} - self.access_token = "" + self.access_token = None """access token for OAuth/Bearer """ {{/hasOAuthMethods}} {{^hasOAuthMethods}} {{#hasBearerMethods}} - self.access_token = "" + self.access_token = None """access token for OAuth/Bearer """ {{/hasBearerMethods}} diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache index b5224a5821..1d74d016ab 100644 --- a/python-experimental/__init__package.mustache +++ b/python-experimental/__init__package.mustache @@ -20,6 +20,9 @@ from {{packageName}}.api_client import ApiClient # import Configuration from {{packageName}}.configuration import Configuration +{{#hasHttpSignatureMethods}} +from {{packageName}}.signing import HttpSigningConfiguration +{{/hasHttpSignatureMethods}} # import exceptions from {{packageName}}.exceptions import OpenApiException diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index d191bbf485..300efa007b 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -15,18 +15,35 @@ import re from six.moves.urllib.parse import urlencode, urlparse from time import mktime +# The constants below define a subset of HTTP headers that can be included in the +# HTTP signature scheme. Additional headers may be included in the signature. + +# The '(request-target)' header is a calculated field that includes the HTTP verb, +# the URL path and the URL query. HEADER_REQUEST_TARGET = '(request-target)' +# The time when the HTTP signature was generated. HEADER_CREATED = '(created)' +# The time when the HTTP signature expires. The API server should reject HTTP requests +# that have expired. HEADER_EXPIRES = '(expires)' +# The 'Host' header. HEADER_HOST = 'Host' +# The 'Date' header. HEADER_DATE = 'Date' -HEADER_DIGEST = 'Digest' # RFC 3230, include digest of the HTTP request body. +# When the 'Digest' header is included in the HTTP signature, the client automatically +# computes the digest of the HTTP request body, per RFC 3230. +HEADER_DIGEST = 'Digest' +# The 'Authorization' header is automatically generated by the client. It includes +# the list of signed headers and a base64-encoded signature. HEADER_AUTHORIZATION = 'Authorization' +# The constants below define the cryptographic schemes for the HTTP signature scheme. SCHEME_HS2019 = 'hs2019' SCHEME_RSA_SHA256 = 'rsa-sha256' SCHEME_RSA_SHA512 = 'rsa-sha512' +# The constants below define the signature algorithms that can be used for the HTTP +# signature scheme. ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' @@ -364,5 +381,4 @@ class HttpSigningConfiguration(object): auth_str = auth_str + "headers=\"{0}\",signature=\"{1}\"".format( headers_value, signed_msg.decode('ascii')) - print("AUTH: {0}".format(auth_str)) return auth_str From f82715a3ac59b492c6cf50076dbe5bcadcefbe9e Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 6 Feb 2020 09:48:23 -0800 Subject: [PATCH 084/185] [python] use datetime aware object (#5209) * python use aware datetime object * python use aware datetime object * python use aware datetime object * python use aware datetime object * python use aware datetime object * python use aware datetime object --- python-experimental/signing.mustache | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index 300efa007b..f52feb8f12 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -7,13 +7,12 @@ from Crypto.IO import PEM, PKCS8 from Crypto.Hash import SHA256, SHA512 from Crypto.PublicKey import RSA, ECC from Crypto.Signature import PKCS1_v1_5, pss, DSS -from datetime import datetime from email.utils import formatdate import json import os import re from six.moves.urllib.parse import urlencode, urlparse -from time import mktime +from time import time # The constants below define a subset of HTTP headers that can be included in the # HTTP signature scheme. Additional headers may be included in the signature. @@ -228,12 +227,6 @@ class HttpSigningConfiguration(object): "Signing algorithm {0} is not compatible with private key".format( self.signing_algorithm)) - def _get_unix_time(self, ts): - """Converts and returns a datetime object to UNIX time, the number of seconds - elapsed since January 1, 1970 UTC. - """ - return (ts - datetime(1970, 1, 1)).total_seconds() - def _get_signed_header_info(self, resource_path, method, headers, body, query_params): """Build the HTTP headers (name, value) that need to be included in the HTTP signature scheme. @@ -262,15 +255,16 @@ class HttpSigningConfiguration(object): if query_params: request_target += "?" + urlencode(query_params) - # Get current time and generate RFC 1123 (HTTP/1.1) date/time string. - now = datetime.now() - stamp = mktime(now.timetuple()) - cdate = formatdate(timeval=stamp, localtime=False, usegmt=True) + # Get UNIX time, e.g. seconds since epoch, not including leap seconds. + now = time() + # Format date per RFC 7231 section-7.1.1.2. An example is: + # Date: Wed, 21 Oct 2015 07:28:00 GMT + cdate = formatdate(timeval=now, localtime=False, usegmt=True) # The '(created)' value MUST be a Unix timestamp integer value. # Subsecond precision is not supported. - created = int(self._get_unix_time(now)) + created = int(now) if self.signature_max_validity is not None: - expires = self._get_unix_time(now + self.signature_max_validity) + expires = now + self.signature_max_validity.total_seconds() signed_headers_list = [] request_headers_dict = {} From 9977d22bf758b7c9c7ceec66973bcb2829ce0333 Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Thu, 6 Feb 2020 13:58:17 -0800 Subject: [PATCH 085/185] [Python] 5094 followup - Reduce redundancy in docs (#5161) * Reduce redundancy in python docs This is a followup to PR #5094, which had a few unresolved comments at merge time. This reduces the amount of redundant lines in the api example doc templates, and ensures that referenced Configuration objects are actually instantiated. * Regenerate samples --- api_doc_example.mustache | 11 ++--------- python-experimental/api_doc_example.mustache | 11 +++-------- python_doc_auth_partial.mustache | 3 +++ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/api_doc_example.mustache b/api_doc_example.mustache index e86c5d6011..dadb8f6a96 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -5,24 +5,17 @@ import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} -{{#hasAuthMethods}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" # Enter a context with an instance of the API client +{{#hasAuthMethods}} with {{{packageName}}}.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) - {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} - {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} -# Enter a context with an instance of the API client with {{{packageName}}}.ApiClient() as api_client: +{{/hasAuthMethods}} # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} -{{/hasAuthMethods}} try: {{#summary}} # {{{.}}} diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index 565d00a3b9..ae7b8a6979 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -4,20 +4,15 @@ import time import {{{packageName}}} from pprint import pprint {{> python_doc_auth_partial}} -{{#hasAuthMethods}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" # Enter a context with an instance of the API client +{{#hasAuthMethods}} with {{{packageName}}}.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{/hasAuthMethods}} {{^hasAuthMethods}} -# Enter a context with an instance of the API client -with {{{packageName}}}.ApiClient(configuration) as api_client: +with {{{packageName}}}.ApiClient() as api_client: +{{/hasAuthMethods}} # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) -{{/hasAuthMethods}} {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 9f5b49f821..d8cfc4ad11 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -45,4 +45,7 @@ configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' configuration.access_token = 'YOUR_ACCESS_TOKEN' {{/isOAuth}} {{/authMethods}} + +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" {{/hasAuthMethods}} From fd4cd68d958e65cf1a9e29d872ec8550babf7c82 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Mon, 17 Feb 2020 15:36:21 +0100 Subject: [PATCH 086/185] python: Add gitlab-ci.mustache (#5342) * python: Add gitlab-ci.mustache It does the same stuff as in the .travis.yml but just for Gitlab CI #5340 - Python .gitlab-ci.yml * python: Run all scripts in bin find bin/ -type f -name 'python*.sh' -exec {} \; Had to update all samples --- gitlab-ci.mustache | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gitlab-ci.mustache diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache new file mode 100644 index 0000000000..28046fefa0 --- /dev/null +++ b/gitlab-ci.mustache @@ -0,0 +1,33 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.nosetest: + stage: test + script: + - pip install -r requirements.txt + - pip install nose + - nosetests + +nosetest-2.7: + extends: .nosetest + image: python:2.7-alpine +nosetest-3.3: + extends: .nosetest + image: python:3.3-alpine +nosetest-3.4: + extends: .nosetest + image: python:3.4-alpine +nosetest-3.5: + extends: .nosetest + image: python:3.5-alpine +nosetest-3.6: + extends: .nosetest + image: python:3.6-alpine +nosetest-3.7: + extends: .nosetest + image: python:3.7-alpine +nosetest-3.8: + extends: .nosetest + image: python:3.8-alpine From 57f7c721dfca35ed02a64d4785703e3fbca94d4d Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Thu, 20 Feb 2020 14:47:13 +0100 Subject: [PATCH 087/185] Respect usenose for Python CI (#5376) * python: Respect useNose option in generated CI templates Travis and Gitlab CI now use nosetests or pytests depending on the "useNose" option that is passed. * python: Update CI samples They now respect the "useNose" option --- gitlab-ci.mustache | 7 ++++++- travis.mustache | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache index 28046fefa0..2cabff63c7 100644 --- a/gitlab-ci.mustache +++ b/gitlab-ci.mustache @@ -7,8 +7,13 @@ stages: stage: test script: - pip install -r requirements.txt - - pip install nose + - pip install -r test-requirements.txt + {{#useNose}} - nosetests + {{/useNose}} + {{^useNose}} + - pytest --cov={{{packageName}}} + {{/useNose}} nosetest-2.7: extends: .nosetest diff --git a/travis.mustache b/travis.mustache index 388de83128..195488737d 100644 --- a/travis.mustache +++ b/travis.mustache @@ -10,6 +10,13 @@ python: - "3.7" - "3.8" # command to install dependencies -install: "pip install -r requirements.txt" +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" # command to run tests +{{#useNose}} script: nosetests +{{/useNose}} +{{^useNose}} +script: pytest --cov={{{packageName}}} +{{/useNose}} From 686c3f76529f05d4b97ffe49851e9200e021eed4 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 21 Feb 2020 14:51:24 -0800 Subject: [PATCH 088/185] [Python] add discard_unknown_keys parameter (#5362) * add discard_unknown_key parameter * add discard_unknown_key parameter * add discard_unknown_key parameter * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * run sample scripts for python * code reformatting * execute script in bin directory * improve unit tests for discarding properties --- configuration.mustache | 13 +++++++++ .../method_init_composed.mustache | 13 +++++---- .../method_init_normal.mustache | 12 ++++---- .../method_init_shared.mustache | 8 +++++- python-experimental/model_utils.mustache | 28 ++++++++++--------- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 0645bc4675..8228fff6a8 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -31,6 +31,17 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. {{#hasHttpSignatureMethods}} :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration @@ -120,6 +131,7 @@ class Configuration(object): def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, username=None, password=None, + discard_unknown_keys=False, {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} @@ -152,6 +164,7 @@ class Configuration(object): self.password = password """Password for HTTP basic authentication """ + self.discard_unknown_keys = discard_unknown_keys {{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index 5ed5993fe9..5a1ece1f92 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -11,12 +11,6 @@ {{> python-experimental/model_templates/method_init_shared }} - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, @@ -34,9 +28,16 @@ self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index b053427a79..d26506c56c 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -8,14 +8,14 @@ {{> python-experimental/model_templates/method_init_shared }} - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} for var_name, var_value in six.iteritems(kwargs): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 2f3b70ea69..318d693e15 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -20,4 +20,10 @@ If passed, type conversion is attempted If omitted no type conversion is done.{{#optionalVars}} {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ \ No newline at end of file + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index c3d9e7d536..8193d8a3b2 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -677,8 +677,9 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us - raise get_type_error(input_value, path_to_item, valid_classes, - key_type=key_type) + if configuration is None or not configuration.discard_unknown_keys: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) for valid_class in valid_classes_coercible: try: if issubclass(valid_class, OpenApiModel): @@ -1117,16 +1118,16 @@ def validate_get_composed_info(constant_args, model_args, self): # set any remaining values unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0: - if len(additional_properties_model_instances) == 0: - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - for var_name, var_value in six.iteritems(unused_args): - for instance in additional_properties_model_instances: - setattr(instance, var_name, var_value) + if len(unused_args) > 0 and \ + len(additional_properties_model_instances) == 0 and \ + (self._configuration is None or + not self._configuration.discard_unknown_keys): + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + # no need to add additional_properties to var_name_to_model_instances here # because additional_properties_model_instances will direct us to that # instance when we use getattr or setattr @@ -1135,5 +1136,6 @@ def validate_get_composed_info(constant_args, model_args, self): return [ composed_instances, var_name_to_model_instances, - additional_properties_model_instances + additional_properties_model_instances, + unused_args ] From f20a3a39d6131179d3426632e46839201e9b48ad Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Sun, 23 Feb 2020 21:10:44 +0100 Subject: [PATCH 089/185] [python] add method to set/get default configuration (#5315) * [python] add method to set/get default configuration * [python] change method name and fix handling api_key * python: using modified deepcopy to set/get default configuration * python: update samples * python: update samples --- api_client.mustache | 2 +- configuration.mustache | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index 08de3bab85..52b2ec2f3d 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -63,7 +63,7 @@ class ApiClient(object): def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration() + configuration = Configuration.get_default_copy() self.configuration = configuration self.pool_threads = pool_threads diff --git a/configuration.mustache b/configuration.mustache index 8228fff6a8..6581e603ad 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -4,6 +4,7 @@ from __future__ import absolute_import +import copy import logging {{^asyncio}} import multiprocessing @@ -128,6 +129,8 @@ class Configuration(object): {{/hasAuthMethods}} """ + _default = None + def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, username=None, password=None, @@ -254,6 +257,45 @@ class Configuration(object): # Disable client side validation self.client_side_validation = True + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + @property def logger_file(self): """The logger file. From c3ed779ac85b5c7eb44a3c9099a9cbde9bc11f82 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 28 Feb 2020 14:21:08 -0800 Subject: [PATCH 090/185] [python] Adds python oneOf/anyOf models + tests (#5341) * Adds oneOf + anyOf schemas, models and tests to python-experimental * Adds setUpClass and tearDownClass * Removes newline in method_init_shared.mustache * Regenerated v3 spec sample for python-experimental * Fxes test for discard_unknown_keys * Moves new models into existing spec, regen python-exp and go-exp * Also fix python-exp windows file --- python-experimental/model.mustache | 1 + .../method_init_composed.mustache | 14 +++++++--- .../method_init_shared.mustache | 28 ++++++++++++++----- .../methods_setattr_getattr_composed.mustache | 20 +++++++------ python-experimental/model_utils.mustache | 28 ++++++++++++++----- python-experimental/requirements.mustache | 1 + python-experimental/setup.mustache | 1 + 7 files changed, 66 insertions(+), 27 deletions(-) diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 0ca198ddf9..ef7da57282 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -7,6 +7,7 @@ import re # noqa: F401 import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index 5a1ece1f92..e00bf129b2 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -17,11 +17,18 @@ '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { {{#requiredVars}} '{{name}}': {{name}}, {{/requiredVars}} } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -30,9 +37,8 @@ self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] -{{#requiredVars}} - self.{{name}} = {{name}} -{{/requiredVars}} + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 318d693e15..9dd5bc2b6f 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,11 +1,23 @@ def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} -{{/hasMore}}{{/requiredVars}} - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} +{{#requiredVars}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/requiredVars}} _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -18,8 +30,10 @@ _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted - If omitted no type conversion is done.{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + If omitted no type conversion is done. +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} """ self._data_store = {} diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index e5eee88a96..9adb2a08a1 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -41,21 +41,23 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) + values = set() if model_instances: - values = set() for model_instance in model_instances: if name in model_instance._data_store: values.add(model_instance._data_store[name]) - if len(values) == 1: - return list(values)[0] + len_values = len(values) + if len_values == 0: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif len_values == 1: + return list(values)[0] + elif len_values > 1: raise ApiValueError( "Values stored for property {0} in {1} difffer when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item - ) - - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) \ No newline at end of file + ) \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 8193d8a3b2..7f05f2dbe8 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -828,7 +828,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances = model_instance._composed_instances + model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -951,12 +951,12 @@ def get_oneof_instance(self, model_args, constant_args): used to make instances Returns - oneof_instance (instance) + oneof_instance (instance/None) """ - oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return oneof_instance + return None + oneof_instances = [] for oneof_class in self._composed_schemas()['oneOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( @@ -969,20 +969,30 @@ def get_oneof_instance(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - break + oneof_instances.append(oneof_instance) except Exception: pass - if oneof_instance is None: + if len(oneof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Unable to " "make any instances of the classes in oneOf definition." % self.__class__.__name__ ) - return oneof_instance + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf instances were generated when a max of one is allowed." % + self.__class__.__name__ + ) + return oneof_instances[0] def get_anyof_instances(self, model_args, constant_args): @@ -1012,6 +1022,10 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache index eb358efd5b..a56bedffbf 100644 --- a/python-experimental/requirements.mustache +++ b/python-experimental/requirements.mustache @@ -1,3 +1,4 @@ +nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 2fe84efcee..796475c456 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -21,6 +21,7 @@ REQUIRES = [ "six >= 1.10", "certifi", "python-dateutil", + "nulltype", {{#asyncio}} "aiohttp >= 3.0.0", {{/asyncio}} From f6e96443584a81e14a62bd969ee766a598651137 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 6 Mar 2020 17:25:45 -0800 Subject: [PATCH 091/185] Add serialization of ModelComposed (#5551) --- python-experimental/api_client.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 78f502b00d..774dae89c6 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -21,6 +21,7 @@ from {{packageName}}.exceptions import ApiValueError from {{packageName}}.model_utils import ( ModelNormal, ModelSimple, + ModelComposed, date, datetime, deserialize_file, @@ -240,7 +241,7 @@ class ApiClient(object): if isinstance(obj, dict): obj_dict = obj - elif isinstance(obj, ModelNormal): + elif isinstance(obj, ModelNormal) or isinstance(obj, ModelComposed): # Convert model obj to dict # Convert attribute name to json key in # model definition for request From 446507eeeb3ef5e641182fb6feac15492d94a3ea Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 6 Mar 2020 20:22:19 -0800 Subject: [PATCH 092/185] Fixes kwargs typos, removes E501s (#5552) --- api.mustache | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/api.mustache b/api.mustache index f1a110bd47..f2c5541835 100644 --- a/api.mustache +++ b/api.mustache @@ -10,7 +10,7 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( +from {{packageName}}.exceptions import ( # noqa: F401 ApiTypeError, ApiValueError ) @@ -99,20 +99,36 @@ class {{classname}}(object): """ {{#servers.0}} - local_var_hosts = [{{#servers}}'{{{url}}}'{{^-last}}, {{/-last}}{{/servers}}] # noqa: E501 + local_var_hosts = [ +{{#servers}} + '{{{url}}}'{{^-last}},{{/-last}} +{{/servers}} + ] local_var_host = local_var_hosts[0] if kwargs.get('_host_index'): - if int(kwags.get('_host_index')) < 0 or int(kawgs.get('_host_index')) >= len(local_var_hosts): - raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) - local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] + _host_index = int(kwargs.get('_host_index')) + if _host_index < 0 or _host_index >= len(local_var_hosts): + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" + % len(local_var_host) + ) + local_var_host = local_var_hosts[_host_index] {{/servers.0}} local_var_params = locals() - all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = [ +{{#allParams}} + '{{paramName}}'{{#hasMore}},{{/hasMore}} +{{/allParams}} + ] + all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout' + ] + ) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: From 185cd3e88627d23dbcf24ed14f5d1b4c4ae203b7 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Wed, 25 Mar 2020 15:59:27 +0100 Subject: [PATCH 093/185] [python/asyncio] explicitly close client session via async context manager (#5621) --- api_client.mustache | 14 +++++++++++++- asyncio/rest.mustache | 5 ++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index 52b2ec2f3d..c69e7d5945 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -76,13 +76,25 @@ class ApiClient(object): self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' self.client_side_validation = configuration.client_side_validation + {{#asyncio}} + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + {{/asyncio}} + {{^asyncio}} def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() + {{/asyncio}} - def close(self): + {{#asyncio}}async {{/asyncio}}def close(self): + {{#asyncio}} + await self.rest_client.close() + {{/asyncio}} if self._pool: self._pool.close() self._pool.join() diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 4585f1c6ad..e797d0ae7a 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -10,7 +10,6 @@ import ssl import aiohttp import certifi -import asyncio # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode @@ -77,8 +76,8 @@ class RESTClientObject(object): connector=connector ) - def __del__(self): - asyncio.ensure_future(self.pool_manager.close()) + async def close(self): + await self.pool_manager.close() async def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, From c2dadaef904be181ab773e6968ded9a30a8bcb12 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 3 Apr 2020 20:49:23 -0700 Subject: [PATCH 094/185] [Python-experimental] Documentation enhancement for oneOf schema and minor err msg improvement (#5791) * Add documentation to generated code * Improve error message * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Run sample scripts * Address review comments * Address review comments * Fix problem in python error message --- python-experimental/model_utils.mustache | 69 ++++++++++++++++++------ 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 7f05f2dbe8..8b60618c1d 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -464,7 +464,11 @@ def get_required_type_classes(required_types_mixed): def change_keys_js_to_python(input_dict, model_class): """ Converts from javascript_key keys in the input_dict to python_keys in - the output dict using the mapping in model_class + the output dict using the mapping in model_class. + If the input_dict contains a key which does not declared in the model_class, + the key is added to the output dict as is. The assumption is the model_class + may have undeclared properties (additionalProperties attribute in the OAS + document). """ output_dict = {} @@ -936,19 +940,39 @@ def get_allof_instances(self, model_args, constant_args): # and use it to make the instance kwargs.update(constant_args) - allof_instance = allof_class(**kwargs) - composed_instances.append(allof_instance) + try: + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) + except Exception as ex: + raise ApiValueError( + "Invalid inputs given to generate an instance of '%s'. The " + "input data was invalid for the allOf schema '%s' in the composed " + "schema '%s'. Error=%s" % ( + allof_class.__class__.__name__, + allof_class.__class__.__name__, + self.__class__.__name__, + str(ex) + ) + ) return composed_instances def get_oneof_instance(self, model_args, constant_args): """ + Find the oneOf schema that matches the input data (e.g. payload). + If exactly one schema matches the input data, an instance of that schema + is returned. + If zero or more than one schema match the input data, an exception is raised. + In OAS 3.x, the payload MUST, by validation, match exactly one of the + schemas described by oneOf. Args: self: the class we are handling model_args (dict): var_name to var_value - used to make instances + The input data, e.g. the payload that must match a oneOf schema + in the OpenAPI document. constant_args (dict): var_name to var_value - used to make instances + args that every model requires, including configuration, server + and path to item. Returns oneof_instance (instance/None) @@ -957,12 +981,17 @@ def get_oneof_instance(self, model_args, constant_args): return None oneof_instances = [] + # Iterate over each oneOf schema and determine if the input data + # matches the oneOf schemas. for oneof_class in self._composed_schemas()['oneOf']: - # transform js keys to python keys in fixed_model_args + # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) - # extract a dict of only required keys from fixed_model_args + # Extract a dict with the properties that are declared in the oneOf schema. + # Undeclared properties (e.g. properties that are allowed because of the + # additionalProperties attribute in the OAS document) are not added to + # the dict. kwargs = {} var_names = set(oneof_class.openapi_types().keys()) for var_name in var_names: @@ -982,14 +1011,14 @@ def get_oneof_instance(self, model_args, constant_args): pass if len(oneof_instances) == 0: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. Unable to " - "make any instances of the classes in oneOf definition." % + "Invalid inputs given to generate an instance of %s. None " + "of the oneOf schemas matched the input data." % self.__class__.__name__ ) elif len(oneof_instances) > 1: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Multiple " - "oneOf instances were generated when a max of one is allowed." % + "oneOf schemas matched the inputs, but a max of one is allowed." % self.__class__.__name__ ) return oneof_instances[0] @@ -1035,8 +1064,8 @@ def get_anyof_instances(self, model_args, constant_args): pass if len(anyof_instances) == 0: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. Unable to " - "make any instances of the classes in anyOf definition." % + "Invalid inputs given to generate an instance of %s. None of the " + "anyOf schemas matched the inputs." % self.__class__.__name__ ) return anyof_instances @@ -1087,10 +1116,18 @@ def get_unused_args(self, composed_instances, model_args): def validate_get_composed_info(constant_args, model_args, self): """ - For composed schemas/classes, validates the classes to make sure that - they do not share any of the same parameters. If there is no collision - then composed model instances are created and returned tot the calling - self model + For composed schemas, generate schema instances for + all schemas in the oneOf/anyOf/allOf definition. If additional + properties are allowed, also assign those properties on + all matched schemas that contain additionalProperties. + Openapi schemas are python classes. + + Exceptions are raised if: + - no oneOf schema matches the model_args input data + - > 1 oneOf schema matches the model_args input data + - > 1 oneOf schema matches the model_args input data + - no anyOf schema matches the model_args input data + - any of the allOf schemas do not match the model_args input data Args: constant_args (dict): these are the args that every model requires From 9f5ea5601b7e05050d441195c415a24884df2b53 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Wed, 15 Apr 2020 10:43:33 -0700 Subject: [PATCH 095/185] [Python-experimental] Use DER encoding for ECDSA signatures, add parameter to configure hash algorithm (#5924) * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * fix python unit tests for http message signature * Fix error message * format python code * format python code --- python-experimental/signing.mustache | 46 +++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index f52feb8f12..0be0e1c467 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -53,6 +53,10 @@ ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 } +# The cryptographic hash algorithm for the message signature. +HASH_SHA256 = 'sha256' +HASH_SHA512 = 'sha512' + class HttpSigningConfiguration(object): """The configuration parameters for the HTTP signature security scheme. @@ -98,9 +102,15 @@ class HttpSigningConfiguration(object): Supported values are: 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. - The default value is inferred from the private key. - The default value for RSA keys is RSASSA-PSS. - The default value for ECDSA keys is fips-186-3. + If None, the signing algorithm is inferred from the private key. + The default signing algorithm for RSA keys is RSASSA-PSS. + The default signing algorithm for ECDSA keys is fips-186-3. + :param hash_algorithm: The hash algorithm for the signature. Supported values are + sha256 and sha512. + If the signing_scheme is rsa-sha256, the hash algorithm must be set + to None or sha256. + If the signing_scheme is rsa-sha512, the hash algorithm must be set + to None or sha512. :param signature_max_validity: The signature max validity, expressed as a datetime.timedelta value. It must be a positive value. """ @@ -108,6 +118,7 @@ class HttpSigningConfiguration(object): private_key_passphrase=None, signed_headers=None, signing_algorithm=None, + hash_algorithm=None, signature_max_validity=None): self.key_id = key_id if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: @@ -118,6 +129,24 @@ class HttpSigningConfiguration(object): self.private_key_path = private_key_path self.private_key_passphrase = private_key_passphrase self.signing_algorithm = signing_algorithm + self.hash_algorithm = hash_algorithm + if signing_scheme == SCHEME_RSA_SHA256: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm != HASH_SHA256: + raise Exception("Hash algorithm must be sha256 when security scheme is %s" % + SCHEME_RSA_SHA256) + elif signing_scheme == SCHEME_RSA_SHA512: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA512 + elif self.hash_algorithm != HASH_SHA512: + raise Exception("Hash algorithm must be sha512 when security scheme is %s" % + SCHEME_RSA_SHA512) + elif signing_scheme == SCHEME_HS2019: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}: + raise Exception("Invalid hash algorithm") if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: raise Exception("The signature max validity must be a positive value") self.signature_max_validity = signature_max_validity @@ -309,14 +338,14 @@ class HttpSigningConfiguration(object): The prefix is a string that identifies the cryptographc hash. It is used to generate the 'Digest' header as specified in RFC 3230. """ - if self.signing_scheme in {SCHEME_RSA_SHA512, SCHEME_HS2019}: + if self.hash_algorithm == HASH_SHA512: digest = SHA512.new() prefix = 'SHA-512=' - elif self.signing_scheme == SCHEME_RSA_SHA256: + elif self.hash_algorithm == HASH_SHA256: digest = SHA256.new() prefix = 'SHA-256=' else: - raise Exception("Unsupported signing algorithm: {0}".format(self.signing_scheme)) + raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm)) digest.update(data) return digest, prefix @@ -340,7 +369,10 @@ class HttpSigningConfiguration(object): if sig_alg is None: sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: - signature = DSS.new(self.private_key, sig_alg).sign(digest) + # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. + # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 + signature = DSS.new(key=self.private_key, mode=sig_alg, + encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) else: From f91931de3b4069499655f0b12501d5631bbbff58 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Wed, 15 Apr 2020 17:02:56 -0700 Subject: [PATCH 096/185] [Python-experimental] Fix TypeError: unhashable type: 'list' (#5810) * handle scenario when value is a list, fix TypeError: unhashable type: 'list' * Add __hash__ function * use list instead of set * use list instead of set * use list instead of set * use list instead of set * use list instead of set * use list instead of set --- .../methods_setattr_getattr_composed.mustache | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index 9adb2a08a1..9420fe1582 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -41,11 +41,17 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) - values = set() + values = [] + # A composed model stores child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. A named property can exist in + # multiple child models. If the property is present in more than one + # child model, the value must be the same across all the child models. if model_instances: for model_instance in model_instances: if name in model_instance._data_store: - values.add(model_instance._data_store[name]) + v = model_instance._data_store[name] + if v not in values: + values.append(v) len_values = len(values) if len_values == 0: raise ApiKeyError( @@ -53,10 +59,10 @@ path_to_item ) elif len_values == 1: - return list(values)[0] + return values[0] elif len_values > 1: raise ApiValueError( - "Values stored for property {0} in {1} difffer when looking " + "Values stored for property {0} in {1} differ when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item From 1fbc64d84b36d5ab5e831689ed61cfdae8043f17 Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Thu, 16 Apr 2020 03:16:08 +0200 Subject: [PATCH 097/185] [python/asyncio] fix passing proxy parameters to aiohttp (#5943) --- asyncio/rest.mustache | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index e797d0ae7a..f2099c7531 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -65,16 +65,13 @@ class RESTClientObject(object): ssl=ssl_context ) + self.proxy = configuration.proxy + self.proxy_headers = configuration.proxy_headers + # https pool manager - if configuration.proxy: - self.pool_manager = aiohttp.ClientSession( - connector=connector, - proxy=configuration.proxy - ) - else: - self.pool_manager = aiohttp.ClientSession( - connector=connector - ) + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) async def close(self): await self.pool_manager.close() @@ -122,6 +119,11 @@ class RESTClientObject(object): "headers": headers } + if self.proxy: + args["proxy"] = self.proxy + if self.proxy_headers: + args["proxy_headers"] = self.proxy_headers + if query_params: args["url"] += '?' + urlencode(query_params) From abd9642e2fb2333ece9a0029cdea352c073e89c2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 22 Apr 2020 11:47:08 +0800 Subject: [PATCH 098/185] Sync master to 5.0.x (#5968) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change the Model template (#5222) * Add a link to Xero blog post (#5426) * Removal of Encoding in the Query-Params in order to prevent double Encoding. (#5255) This way letting WebClient do its Job in encoding the URL. * update java webclient sample * [kotlin][client] Add Jackson as serialization library (#5236) * [kotlin][client] Add Jackson as serialization library * [kotlin][client] Add kotlin-client-jackson.sh to kotlin-client-all.sh * update kotlin client samples * update doc Co-authored-by: William Cheng * include kotlin jackson in CI tests (#5438) * [Ruby] Add error output (#5428) * Add error output to the log so that we can make sure why the error occurred * Fix forbidden method invocation using default charsets * Update usage.md (#5443) * fix NPE for enum (#5445) * [Java][WebClient] better code format (#5433) * better code format for java webclient * prefix local varaible with localVar * fix issue with online service (#5461) * Support for additionalProperties in the C generator "Client: C" solves #5395 (#5440) * Support for additionalProperties in the C generator. * Support for additionalProperties in the C generator. * [docs] Enable Algolia search (#5472) * Fix #5420 add headers from configuration object (#5422) * Fix #5420 add headers from configuration object * Add baseOptions undefined checking #5420 * Update the samples and replace array to object #5420 * Update sample * [typescript] Clean up modelPropertyNaming across generators (#5427) * [typescript] Clean up modelPropertyNaming across generators Fixes https://github.com/OpenAPITools/openapi-generator/issues/2976 Generators without runtime models conversion use "original" property naming by default. It's still possible to change it via cli options Generators with runtime conversion keep using "camelCase" * Refactoring: use enum instead of string for modelPropertyNaming * Restore the original camelCase for var names, decouple it from property names * Swap toParamName and toVarName logic (looks like I've mistaken them) * Regenerate docs * Remove a no longer used private method * Added support for msvc builds in cpp-qt5-client generator (#5468) * Added support for msvc builds Moved GCC-specific compile flags to non msvc builds, and added equivalent flags for msvc. * CMakeLists condition cleanup * [all] Move feature set setter (#5460) When I originally implemented the feature set code, I added the getter/setter on DefaultCodegen and CodegenConfig as well as on GeneratorMetadata. GeneratorMetadata also includes the library variation features. When I went to add library-specific features, I realized the discrepancy. This removes the public setter from DefaultCodegen/CodegenConfig, and adds a protected modifyFeatureSet which accepts a lambda and hides the builder logic away in the method. This will be a breaking change for anyone who's created a custom generator in 4.2.3, so the impact is very limited. * [Swift5] small improvements to Objc compatibility (#5410) * [swift] make some small improvements * [swift][client] revert model to use allVars * PostProcessModelProperty with allVars * PostProcessModelProperty with vars * [swift] improve objc interoperability * [swift] fix swift4 for CI to pass * [swift] improve objc interoperability * [swift] improve objc interoperability * Swift - try to fix build * [swift] remove pods from git * [scala] [template] scala sttp client (#5429) * scala-sttp-client template * invoker for sttp fixed and tests added * clean up pet api test from redunant comments * docs updated * fix artefact name, model comments and redunant generic * code optimization * cross scala versions 2.11 2.12 2.13 * date serializers extracted and joda enabled as default * basic and bearer authorization added, apikey in query supported * [Ruby] Fix obsolete configuration of Rubocop and Rubocop's warns (#5417) (#5474) * fix obsolute configuration in generated .rubocop.yml * fix style of `expect` with block in generated ruby client's test code * update sample of ruby client * [scala] strip model class name for all scala generators (#5439) * stripped parameter enabled for all scala based generators * scala samples updated * docs generators updated * fix scalatra. regenerated by openapi3 script. manually removed enum default value from scalatra example due bug in schema extraction * [Scala][sttp] various improvements (#5475) * various improvements to scala sttp * update ScalaSttpClientCodegen.java * add windows batch file * test scala sttp in jdk8 * fix tempalte directory * Use the dataType if the baseType is not set (#5372) * Use the dataType if the baseType is not set * add tests for passing enum as parameter * updated requirements file in samples * Update spec to explicitly name objects and prevent `inline_object` * use the correct scripts to generate samples (`bin/openapi3/python-flask*`) * [python] Adds python oneOf/anyOf models + tests (#5341) * Adds oneOf + anyOf schemas, models and tests to python-experimental * Adds setUpClass and tearDownClass * Removes newline in method_init_shared.mustache * Regenerated v3 spec sample for python-experimental * Fxes test for discard_unknown_keys * Moves new models into existing spec, regen python-exp and go-exp * Also fix python-exp windows file * fix CVE-2020-8130 (#5483) * [go] Add Ptr method to const enum values (#5257) * fix rubocop warns in Ruby client's custom spec (#5488) * [C-libcurl] The name in API parameter should not be escaped even though it includes a C key word. (#5487) * [go-experimental] Support aliasing of API keys (#4940) * [go-experimental] Support aliasing of API keys * Use {{.}} inside condition * Use name instead of keyParamName for lookup * x-lookup to x-auth-id-alias * [java] Support aliasing of API keys (#4966) * [java] Support aliasing of API keys * Rebuild Java Jersey2 sample client * x-lookup to x-auth-id-alias * Regenerated * [cli][gradle] Validate now uses parseOptions w/setResolve (#5471) * [cli] Validate now uses parseOptions w/setResolve The validate command now uses ParseOptions#setResolve(true) to match how we parse in CodegenConfigurator and online's Generate. Without this option, the OpenAPI 3 parser skips the "resolve" block, which made lead to validations in the command not matching validations during generation. * [gradle] Validate now uses parseOptions w/setResolve The Graldle validate command now uses ParseOptions#setResolve(true) to match how we parse in CodegenConfigurator and online's Generate. Without this option, the OpenAPI 3 parser skips the "resolve" block, which made lead to validations in the command not matching validations during generation. * [kotlin]Fix ktor doesn't generate nullable types (#5258) * If not required, need `? = null` * run ./bin/kotlin-server-petstore.sh * Added `?` when value is `required` and `isNullable` * Rerun ./bin/kotlin-server-petstore.sh. But No differences * [C++] Add an option to allow having lowercase variables in models, Pistache: allow using reservedWords in models (#5434) * [C++][Pistache] Use reserved words to replace incorrect names discard old decision to truncate reservedWords * [C++][Pistache] Update struct model to use name instead of baseName * [C++][Pistache] Update Petstore sample * [C++] Add option to have lowercase variables * [C++] Update generated docs * [BUG] [JAVA | Spring] Cookie in parameter is not correctly generated (#5393) * Cookie in parameter is not correctly generated * gh-5386: Fix cookie parameter in * gh-5386: Fix cookie parameter in * gh-5386: Update test file * gh-5386: Fix cookie parameter in * gh-5386: Fix cookie parameter in * gh-5386: Regenerate samples * gh-5386: Fix test * Added Spring CookieValue tests Co-authored-by: Gonzalo * Add missing `@Generated` annotation. (#5384) The annotation is present on other generated files when using jaxrs-spec, but it missing on model classes. * [scala] [template] scala model property style (#5486) * Model property naming style generic for scala * scala templates based on abstractScala regererated * docs generators updated * property format tests * add Agoda as the user (#5494) * Hide timestamp in Scala Play server samples (#5495) * hide timestamp in scala play server output * add chameleon82 to scala tech committee * Add a link to tech blog tech.medpeer.co.jp (#5498) * Add links to blog posts about OpenAPI Generator (#5508) * Typescript array alias array (#4981) * Add failing tests for typescript type declaration * Refactor array and map child type string fallback * Add unaliasSchema to typescript getTypeDeclaration * TypeScriptRxjs: Use Blob as file type declaration This was inadvertantly changed in https://github.com/OpenAPITools/openapi-generator/pull/5266 * [core] Sanitize/underscore/camelize cache expiry (#5484) The helper methods for sanitize/underscore/camelize were recently updated to cache values in static maps. This would lead to a memory leak in hosted environments as the maps had no cleanup/expiry. This moves those cached entries to Caffeine caches with expiry based on last access to allow the edge-case performance improvement gains on very large documents, without the memory leak in hosted or embedded environments. * Update README.md * Add a link to the conference paper (#5510) * Add a link to the conference paper * fix author list * [Slim4] Add Data Mocker middleware (#4978) * [Slim4] Store response schemas * [Slim4] Add Data Mocker middleware * [Slim4] Enhance Slim router * [Slim4] Enhance config * [Slim4] Fix data format key in object mocking * [Slim4] Add tests for Data Mocker middleware * [Slim4] Add Mock feature documentation * [Slim4] Refresh samples * [Java][Spring][Spring-Cloud] Fix #5144 - Use conditional package declaration to avoid unnecessary dependencies (#5145) * FIX: Use conditional package declaration to avoid unnecessary dependencies * DEV: Adjusted sample ClientConfiguration.java for async spring-cloud * fix(php): no need to serialize collections, Guzzle does that, fix #2292 (#3984) * fix(php): only serialize collections if !explode, Guzzle handles the rest, fix #2292 * fix(php): update petstore samples Co-authored-by: Mahdi Dibaiee * [php] replace $collectionFormat with $style (#5517) * php - remove $collectionFormat * update php openapi3 petstore sample * [BUG][scala][template] scala generate java.math.BigDecimal instead of scala type (#5514) * [BUG] scala generate java.math.BigDecimal instead of scala type * update docs/generators * [PHP] complete support for form style (#5519) * [BUG][PHP] Parameter property style not fully implemented (related to comment on PR #3984) * [AUTOGENERATED][PHP] Sample Files * update jackson dependency to newer version (#5527) * Fix Swift4 CI tests (#5540) * comment out swift 4 order tests * comment out store tests * Test Dart petstore client in CircleCI (#5544) * test dart2 in circle ci (jdk7) * fix tests * update package * fix dart installation * Add serialization of ModelComposed (#5551) * Fixes kwargs typos, removes E501s (#5552) * Update generic model to support nullable properties (#5568) * [DOC] Add link to integration test wiki in CONTRIBUTING.md (#5570) * Add link to integration test wiki * Add link to integration test wiki * [Kotlin][client] fix file upload (#5548) * [kotlin] fix file upload * [kotlin] fix file upload * [kotlin] fix file upload * [kotlin][client] fix jackson integration * [kotlin] fix file upload * [kotlin] fix file upload * update doc * [Java] Fix exception when OAuth2 token URL is a relative URL (#5535) * Add support for case when OAuth2 token URL is a relative URL * Add support for case when OAuth2 token URL is a relative URL * run scripts under bin * [Java] fix runtime exception when there are multiple auth methods (#5530) * fix runtime exception when there are multiple auth methods * Refactor a bit so that it does not cause conflict with relative url token branch * [markdown] Fix broken links when generating markdown (#5569) * [markdown] Fix broken links when generating markdown The `api.mustache` file generates links to the markdown model files. These links were previously brokeen. Additionally, the defaultPackage for markdown is "/Models", so this looked pretty in the heading for model files. So this prefix has been stripped from the header in `model.mustache`. * Re-generate Petstore samples for markdown * typescript-angular: fix zone-js version for angular 8 (#5585) * Add a link to the slide (#5590) * [Swift] fix URLSession file upload (#5546) * [swift5] - fix URLSession file upload * [swift5] - fix URLSession file upload * [swift5] fix file upload * [swift5] - fix URLSession file upload * [swift] add unit tests for file upload * [swift] update samples copyright * [swift] add option for API prefix (#5567) * [swift] add option for API prefix * [swift] update docs * [haskell-http-client] update stack; exclude problem time versions (#5589) * [go-experimental] Do not generate HTTP signature unit test for every generated SDK (#5588) * Do not generate HTTP signature unit test for every generated SDK * Add golang 1.14 to CI environment * fix unit test issues * remove script commands that were commented out * add support for ed25519 private keys * PR to solve 2 open issues on enums: #5091 and #4293 (#5477) * PR to solve 2 open issues on enums: Issue 5091 needs to generate enums also when the enum is directly in a param to a API call, instead than in a model. I did that by copying and adapting enum code from *model* to *api* Issue 4293 needs to decorate enums, for when enum names or enum values are repeated over the yaml definition. * PR to solve 2 open issues on enums: Issue 5091 needs to generate enums also when the enum is directly in a param to a API call, instead than in a model. I did that by copying and adapting enum code from *model* to *api* Issue 4293 needs to decorate enums, for when enum names or enum values are repeated over the yaml definition. * Enums decorated: with {{projectName}}_{{classVarName}}_{{enumName}}_ in the models, with {{projectName}}_{{classVarName}}_{{enumName}}_ in the operations. * Changes to the c client: - Removed white space. - Removed ToJSON and FromJSON function for the enums, since they are not used - Sanitized project name in the .java file. For example, this solves a problem with the issue #2338, where the yaml file had title: "Skycoin REST API." * Changes to the c client: - Removed white space. - Removed ToJSON and FromJSON function for the enums, since they are not used - Sanitized project name in the .java file. For example, this solves a problem with the issue #2338, where the yaml file had title: "Skycoin REST API." * Adds parseFlattenSpec (#5526) * Adds parseFlattenSpec, updates tests and helper functions * Adds parseSPec invocation inside parseFlattenSpec * Scala-Akka: Add missing body to PATCH requests (#5605) * NodeJS - Adds missing keyword (#5606) * [jaxrs-cxf-cdi] Support PATCH httpMethod (#5574) Update the required CXF version to 3.1.2 since PATCH support appeared with this version. Add the cxf PATCH annotation to the imports so that the generated code when defining a PATCH api compiles. * fix default value for abstract scala and scalatra server impl (#5578) * [Java] Generated API class has wrong dataType and does not compile Issue (#5331) * add unit test assertion * add check for composed schema * add support for x-allOf-name * change x-allOf-name to x-all-of-name * Add more troubleshooting information * Add more troubleshooting information * Add more troubleshooting information * Add more troubleshooting information * [swift5] stop hiding network error (#5603) * [swift5] stop hiding network error * [swift5] stop hiding network error * [scala][templates] java 8 dates support (#5291) * [scala][akka-http-client] java8 dates support * scala-akka readme doc updated * DateSerializers renamed * rename serializers * move date-library option to abstractScala * generators docs updated * enum defined for date libraries * Backport to scala-http-client * fix scala-akka-client date serializers * fix typo in docs * switch scala templates to java8 (jsr-310) date library by default * update scala samples with java8 date library * update scala generators docs with java8 default date library * fix scala-play-server generator cli options as only java8 dateLibrary supported * fix scalaz DateTimeCodecs template to support java8 * scalaz ci test againt java7 removed as it generate scala 2.11.8 client which is java8 based * update doc * Adding Response Interceptor (#5500) * added Response interceptor for native clients * added Response interceptor for native clients * [k6] Add blog post about using the k6 generator (#5608) * [Kotlin] Remove kotlin-reflect dependency when not needed (#5502) * Remove kotlin-reflect dependency when using CodeGen * Update Kotlin tests * Regenerated unit test samples * Remove newline in generated build.gradle files * [typescript-fetch] add interfaces, withInterfaces (#5612) * typescript-fetch: interfaces, first draft * fix name in description * [scala] Regenerate akka sample (#5622) * scala-version 2.11.12 (#5618) * micheleISEP->michelealbano (#5625) * [Powershell] refactor the client generator (#5629) * add api client * add local variables * add configuration * add header/query/form parameter support * add partial header * add auth, fix parameters type * fix accept, content type * url query string * fix path, header * remove dep on C# client * fix method naming with package name * fix object * convert result from json * better response handling * remove tostring method * fix model doc * fix default module * generate api test files * better api, model tests * fix add pet * add appveyor * fix accept, content type * add petstore tests * fix form parameters * test delete * better file handling (upload) * better code sample * add package version, better doc * delete unused files * fix header parameters * clean up api client * update samples * support query parameter * better method and parameter naming * minor formatting change * better doc, fix cookie parameter * better doc * add api prefix support * better api nam prefix option * fix configuration * throw errors for required parameter * fix authentication * add try catch block to sample code * rename model * use debug, clean up comment * revise code * move bin script * update doc * add new file * better map support * [PowerShell] minor improvements and bug fixes (#5635) * add output type, minor format fix * minor test improvement * Port client updates to server (#5634) * Revert "scala-version 2.11.12 (#5618)" This reverts commit 6b984a926a0f99120a4ad80cef73bee19f8614cd. * update release date * Handle negative response from the server (#5649) * Fix integration tests (Travis, CircleCI) (#5672) * fix php tests * fix scala tests * update ts angular v6 rest * fix user create test * fix spring cloud test * comment out user delete * fix angular v7 tests * fix user test * fix tests * fix go exp tests * commented out delete user tests * comment out delete user tests in go openapi 3 * fix clojure tests * [PowerShell] Fixes typo (#5648) * Solving issue #5623 and supporting bools for C client label:"Client: C" (#5624) * Removed stray "printf"s in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java * Support for booleans in C client * Update README.md * Change to C API mustache files to solve issue #5623 * Debugging of C's modle-body.mustache, as suggested by ityuhui * Final changes suggested by ityuhui * [PowerShell] Fix map type (#5638) * fix map type * remove output type, fix appveyor * test macos * comment out failing scala test * fix typo: configuration * Revert "comment out failing scala test" This reverts commit 1dcf84ffcbb7ab520938ae7c75d60a8329f71478. * [powershell-experimental] Protects against stackoverflow when OAS spec has circular references (#5646) * protects against stackoverflow when OAS spec has circular references * protects against stackoverflow when OAS spec has circular references * Adds configuration option to skip certificate check. Fixes a typo. Fixes an issue which was restricting from cookie to get consumed (#5657) * [k6] bugfixes to improve the output script (#5614) * [k6] Skip appDescription escaping * [k6] Fix variable identifier in output * [k6] Fix bug with reserved words handling * [C][Client] Check the pointer before deleting operation to avoid core dump label:"Client C" (#5626) * [C-libcurl] Check the pointer before deleting operation to avoid core dump * [C-libcurl] Check the pointer before deleting operation, update sample * [kotlin][client] Add Jackson to interface properties and remove extra line feed (#5459) * [kotlin][client] Ensure Jackson annotations are consistent with interface vars * [kotlin][client] Rebuild samples * [kotlin][client] Some kotlin client enhancements - Don't use JsonFormat for Date objects, this should be controlled via a custom serializer/deserializer or a turning on and off serialization features of Jackson. I've updated the jacksonObjectMapper config to write the dates as strings, which I think was intended in the original commit. https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/SerializationFeature.html#WRITE_DATES_AS_TIMESTAMPS https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/cfg/MapperConfig.html#getDateFormat-- - Dont' use @JsonFormat(shape = JsonFormat.Shape.OBJECT) for enums. This causes Enums to be formatted as objects with an internal "value" field. In reality, OpenAPI enums are just strings without properties and should be treated as a string. https://www.baeldung.com/jackson-serialize-enums#2-enum-as-json-object - Add's Kotlin use site annotation @get: to JsonProperty for parent interface properties. Otherwise Kotlin will warn: "This annotation is not applicable to target 'member property without backing field or delegate'" - Add's JsonTypeInfo annotations to interfaces for inheritance. This was copied verbatim from the kotlin-spring generator. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-spring/typeInfoAnnotation.mustache * [kotlin][client] Rebuild kotlin samples * Remove scala version in parent pom (#5647) * [asciidoc] Allow the inclusion of additional documentation to t… (#5260) * [asccidoc] Allow the inclusion of additional documentation to the asccidoc generated Resolves #5228 * [jaxrs-reasteasy-eap] Fix invalid Bean Validation annotations for Longs (#5659) * fix issue #5658 * update samples * [PowerShell] Test powershell petstore client in Appveyor (#5674) * remove scala version in parent pom * test ps petstore in appveyor * fix command * build and import * fix import module * fix import * skip module import * run multiple commands * move to test script * test ps exit * fix exit * check last status code * clean tests * exit last code * add import * change dir * skip build failure * fix check * trigger build failure * fail fast * restore c# test * new line comment * add powershell exp to ensure up to date script * [PowerShell][Experimental] Better docstring (#5688) * add docstring to powershell module * add doc string * Nodejs express js packages update (#5675) * Updated to new nodejs packages, depending heavily on express-openapi-validator. Requires quite a change in code. Updated the business-logic in the controllers/Controller.js file. Logger now records also timestamp of events. Files are uploaded according to definition in config.js file * Removed commented-out code; Changed openApi document extensions to suit new express-openapi-validator definition; multipart and file uploading is supported now; Automatic response returns the values the were sent in the request * fixed README documentation, fixed a mistage in package.json/mustache * added generated files that were created when running the ./bin/test file * [go-experimental] Fix nullable support (#5414) * Fix nullable support in go-experimental client * Fix support for models with parents and container fields * Make sure that oneOf interfaces serialize properly even if they're required (non-pointers) on other models * Spaces => tabs * Regenerate samples * Make some methods of nullables pointer-receivers, add tests * Improve the Get/Set logic to make usage more convenient * Address review * [kotlin][client] make base path globally configurable (#5450) * [kotlin][client] make base path configurable * [kotlin][client] update pet project * [kotlin][client] set default base path * [kotlin][client] set default base path * [kotlin][client] set default base path * Add michelealbano to C technical committee (#5692) * [Go][Experimental] Rename extensions from x-basetype to x-go-base-type (#5691) * rename go vendor extension * update go exp petstore samples oas3 * comment out powershell petstore in uptodate script * remove processing of http_signature_test.mustache (#5696) * Fix generation of oneOf interfaces for oneOf usage in properties (#5400) * Fix generation of oneOf interfaces for oneOf usage in properties * Only generate oneOf interface models when oneOf is defined * use basic parsing (#5702) * [python/asyncio] explicitly close client session via async context manager (#5621) * [gradle] Include engine option for handlebars generation (#5686) * [codegen][Go] Fix compilation error of generated go code when schema is free form object (#5391) * Fix code generation for free-form objects in go-experimental * Execute scripts in bin directory * Add more use cases for open-ended types * Add more use cases for open-ended types * Add more use cases for open-ended types * add code comments * Better name for test properties * handle scenario when type is arbitrary * handle interface{} scenario * handle interface{} scenario * add helper function isAnyType * isAnyType function * implementation of isAnyType function * fix javadoc issue * handle interface{} scenario * use equals comparison instead of == * merge from master * Add code documentation * add code comments, remove unused min/max attribute, fix equals method * Handle 'anytype' use case * add code comments * override postProcessModelProperty to set vendor extension * Use vendorExtensions.x-golang-is-container * fix compilation error of generated code * fix compilation error of generated code * fix compilation error of generated code * [Java] Update version of maven-surefire-plugin (#5509) * use more recent version of maven-surefire-plugin * use more recent version of maven-surefire-plugin * higher debug level for troubleshooting ci issue * temporarily increase debug log to help troubleshoot * Use local instance of pet store service for unit test purpose * Add more logging to troubleshoot unit test failures * Add more logging to troubleshoot unit test failures * Add more logging to troubleshoot unit test failures * Add more logging to troubleshoot unit test failures * Add more logging to troubleshoot unit test failures * use random ID for Java unit test instead of fixed id * add code comments and specify URL for java unit test * reenable quiet argument * fix java unit test issues * fix java unit test issues * Revert "fix java unit test issues" This reverts commit e8508416ff0f2aeb568e3f916b013dc967390f74. * fix java unit test issues * Generator for JavaScript/Apollo Client (#5645) Co-authored-by: William Cheng * Add yutaka0m to Kotlin Technical Committee (#5716) * Add Scala client scripts to ensure-uptodate process (#5712) * add scala client to ensure-upto-date * new scala-akka petstore oas3 folder * regenerate scala akka oas2 petstore * remove script * Minor improvments to JS apollo generator (#5714) * minor improvments to js apollo generator * comment out apollo * [Rust Server] Handle text/xml correctly (#5660) * [Rust Server] Handle text/xml correctly Treat application/xml the same as text/xml as per RFC 7303 * [Rust Server] Add test for text/xml * Update samples * 4.3.0 release (#5721) * update samples (#5722) * 5211 - Use allVars instead of vars for Kotlin client (#5396) * [C++] [Qt5] fixed cpp-client-qt5 HttpRequestWorker requests crashing on timeout... (#5651) * - fixed cpp-client-qt5 HttpRequestWorker requests crashing on timeout when they have actually NOT timed out (were calling back into a deleted struct). * #minor fixes after review * Regenerate changed files Co-authored-by: valentin Bisson Co-authored-by: etherealjoy * Fix SSL setting in checkout script (#5725) * fix ssl setting in checkout script * add check for sbt-openapi-generator * [C] fix decode funtion (#5642) * fix function names and add parameter to return decoded bytes length from base64decode function * format base64decode function to avoid unnecessary malloc and fix wrong length assigning * update the pointer assigning for some reason var++ / *var++ cannot be done on int *var, hence making a local variable which is incremented and at the end it is assigned to the pointer. * Update bump.sh to go SNAPSHOT to version (#5727) * Fix CI failures (#5734) * update ci to use petstore 1.0.4 * comment out test * comment out test * comment out update user test * comment out more tests * use latest petstore * comment out updatePetWithForm * comment out update pet test * fix file path in release_version_update_docs (#5724) * better appveyor test (#5739) * better readme, type mapping, new option (#5740) * Remove warning for unused camel case vendor extension for Qt5 client and server (#5731) * [PS][Experimental] Add multiple server support (#5741) * code comment * add get host setting * add multiple server support * add default headers support (#5746) * [C][Client] Support SSL client authentication for the c client (#5719) * [C][Client] Support SSL client authentication * [C][Client] Support SSL client authentication, update sample * [kotlin] Fix #5247 incorrect enum parameter type for arrays (#5435) * [Erlang-Server] security definition context changes don't propagate to handler (#5751) * Map Merge Context & Params handler requires context and params to be merged before returned to user defined request_handler. * post build & shell script * Delete VERSION * [PS][PowerShell] fix passthru, use switch instead of bool (#5768) * fix passthru, use switch * remove line * comment out kotlin vertx server test (#5767) * add support for common verbs (#5771) * fix request.on_complete message when tempfile is nil (#5745) * fix request.on_complete message when tempfile is nil * update faraday client sample * add openapi3 client samples * use prepare instead of new (#5773) * use Initialize instead of prepare (#5777) * add map example (#5778) * [PS][Experimental] Better common verb handling (#5783) * better common verb handling * better debugging * add option to customize common verb * [cli][docker] Better expose version/sha information of builds (#5736) * [cli] Some CLI improvements… * Introduce --version * Introduce --help * Add --sha to version command for short SHA display * Output Version and SHA details * In new --version output, display repo and doc site Additional cleanup to suppress warnings and code quality. * [docker] Adds labels for metadata This adds image labels to store metadata on the online and cli docker images, using standard labels: * org.opencontainers.image.created * org.opencontainers.image.revision * org.opencontainers.image.title * org.opencontainers.image.version These can be inspected via 'docker inspect IMAGE_NAME' and may be useful in tooling/automation or bug reports submitted by users. For more details on these labels, see: https://github.com/opencontainers/image-spec/blob/master/annotations.md * Include version --full for equiv to --version * [cli] Add --global-property for -D replacement (#5687) -D option has been deprecated as it was previously used to: * Pass "system properties" * Pass additional properties This was confusing because we already have --additional-properties and because Java System Properties are passed as -D before program arguments. Confusion around the -D option had existed for some time, but when we introduced the thread-safe GlobalSettings to avoid overwriting Java System Properties, we created a hard break from Java System Properties in the generator. This also disconnected the previous "system properties" from accepting additional properties. Once these newly deprecated methods are removed, we will have a clear separation of concerns between: * Java System Properties * Global generator properties (used as workflow context) * Additional properties (used as generator options) This commit marks multiple places for cleanup in 5.0. These will be breaking changes, and lower effort to break in 5.0 with deprecation warnings now rather than adding sibling properties throughout the code and potentially introducing logic errors. * [dart-dio] Fixes --model-name-suffix having no effect (#5669) Fixes #5409 * [go-experimental][go][client] Remove unreachable code in go client API methods (#5611) * [go-experimental][go][client] Remove unreachable code in go client API methods * Properly regenerate all samples * please add openVALIDATION Project to readme (#5534) * added openVALIDATION Project to readme * Update README.md Co-Authored-By: Akihito Nakano Co-authored-by: Akihito Nakano * [Csharp-client] Complex form parameters are not serialized as application/json (#5787) * [csharp-client] Complex form parameters are now correctly serialized as json. Reference: http://spec.openapis.org/oas/v3.0.3#special-considerations-for-multipart-content * Updated bin/windows csharp sample generation scripts to point to the correct directories * Updated csharp samples Co-authored-by: Olivier Leonard * fix scala-akka java8 serializers (#5742) * fix scala-akka java8 serializers * regenerate samples for akka-http * [typescript-axios][client] Unnecessary imports occurs when using withSeparateModelsAndApi (#5797) * add ts-ignore * add petstore sample * use write verbose in auth, better api doc (#5804) * [PS][Experimental] add withHttpInfo support, fix "null" return (#5811) * add with http support * use full name in tests * using full name in test * skip type check * [PS][Experimental] Add tests for array of object in response (#5814) * debugging array response * fix find pet tests * better tests to ignore order * [codegen] Use once(LOGGER) to reduce amount of identical warning messages (#5808) * Warn once instead of many times when the log statement does not have contextual information * Warn once instead of many times when the log statement does not have contextual information * make name cache configurabl (#5775) * [codegen] Cachesize config seconds (#5816) * make name cache configurable * Address review comments * [Python-experimental] Documentation enhancement for oneOf schema and minor err msg improvement (#5791) * Add documentation to generated code * Improve error message * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Improve documentation * Run sample scripts * Address review comments * Address review comments * Fix problem in python error message * rename hostsetting, validate base url (#5821) * fix array return (#5822) * Scala akka-http server (#5758) * Scala akka-http server base implementation * [scala-akka-http-server] petStore samples * Improved the formatting of generated files * Updated scala-akka-http server samples * [scala-akka-http-server] the groupId, artifactId and artifactVersion default value are used as intended. * Fixed the default operation not being correctly generated on parameterless operations * Added build.sbt.mustache supporting file * Updated scala-akka-http server samples * ScalaAkkaHttpServer: Fixed a String.format call to use Locale.ROOT for locale * [scala-akka-http-server] Fixed defaultValue being escaped during generation * Added scala-akka-http.md * Replaced all "⇒" character with "=>" to retain compatibility with scala 2.13 * [scala-akka-http] Added a config option akkaHttpVersion It's set in the generated build.sbt. * Updated scala-akka-http server samples * [scala-akka-http] More accurate akkaHttpVersion parsing * Updated scala-akka-http.md * [scala-akka-http] Changed the akka-http version check to fix the generation of StringDirectives * Updated scala-akka-http samples * updated scala-akka-http.md Co-authored-by: Olivier Leonard * Minor improvements to scala akka server (#5823) * minor improvements to scala akka server * add samples * update doc * Update swagger parser to 2.0.19 (#5413) * update swagger parser to 2.0.18 * fix online server exception * Revert "fix online server exception" This reverts commit fe3cb5221f362c00b176fa81411eaf368f0e446d. * update parser to 2.0.19 * [jaxrs-cxf-cdi] fix allOf equals and hashCode (#5756) When generating model that use allOf, the equals and hashCode methods must take the parent class into account. * [BUG] [KOTLIN] Fix default value generation for Kotlin Strings (#5776) * fix default value generation for kotlin * add updated pet templates * Revert "add updated pet templates" This reverts commit 7e8168ad * regen pet store projects code * tests for models for C-libcurl generator (#5699) * First try to generate unit tests for the models of the C-libcurl client. Models into models are not supported yet. * Added unit tests for the modules of the C-libcurl client to the git repository. * Support for objects having other objects as properties, for the C-libcurl client generator * Proper formatting of generated code * use allVars to cover all properties (#5835) * support enum in parameters (#5838) * [C++] [Qt5] [Client] fixed cpp-client-qt5 HttpRequestWorker contentCompression variables initialization (#5834) When contentCompression is not enabled, the variables isRequestCompressionEnabled and isResponseCompressionEnabled in HttpRequestWorker are not being initialized. Without initialization the compress function could be called and the request content could be an empty QByteArray instead of original request body. * minor fix to http basic auth (#5839) * Scala akka http server - normalization of some vendor extensions (#5829) * [scala-akka-http-server] Normalized vendor extension "paths" to "x-paths" * [scala-akka-http-server] Normalized vendor extension "hasDefaultValue", "isDefault", "specificMarshallers", "fileParams", "nonFileParams" Co-authored-by: Olivier Leonard * Add Bouill to the Scala technical committee (#5843) * C client generator improvements to support petstore. Solves #5836 (#5837) * C client generator improvement to support: openapi-generator/modules/openapi-generator/src/test/resources/3_0/petstore.yaml * Improvements to the C client generator: - moved base64* from apiClient.c to binary.h/binary.c - changed CR/LF to LF in binary.h/binary.c * C client generator: better support for base64encode / base64decode * Add openapi.yaml file to Java clients (#5765) * Add openapi.yaml file to Java client * Move supporting template file to Java root * Update petstore clients * [codegen] Fix 'super.HashCode' for oneOf and allOf Implementations (retry) (#5830) * Added hasVars after completion of all model post-processing (#5587) * Post ensure-up-to-date * Update to check the size of vars and not assume non-null * update mysql samples * Add default case to handle response code (#5825) * add default case to handle response code * fix default response code * add test for isDefault * fix user id in scala tc * Fix for Issue #4840 [BUG][JAVA][spring-mvc] Generated Code for Map of Maps Return Type does not compile (#5240) * add parent for allOf only (#5851) * Add pythonSrcRoot option to python servers (aiohttp/flask/blueplanet) to support src/ layout projects [and reenable/fix all python server tests] (#5423) * python server: Add pythonSrcRoot option This will allow the python project to be in a subdirectory (as specified in pythonSrcRoot). That could mean following the src layout with sources under src/ or lib/. Multi-language projects might use a sub directory like python/, or whatever makes sense for the project. By default, the pythonSrcRoot is "", meaning the existing behavior is the default. * python server: update template files to support pythonSrcRoot * python server: update docs to add pythonSrcRoot option * python server: add pythonSrcRoot sample script * python server: build sample srclayout project * [Python] copy test files preserving history * [Python] Make a conflict to preserve file copy history * [Python] customize pom.xml for src layout tests * [Python] add python-aiohttp-srclayout tests * [Python] Fix server tests by updating requirements Reverts the PR that disabled python2 server tests: https://github.com/OpenAPITools/openapi-generator/pull/4949 Reverts commits that disabled python3 server tests: 9adfedbfbb45c7059e64b3d9a285710bded4fb62 17ee990baaa80585242c7a07d64e2be4888fcfd0 Issue about the python 3 tests: https://github.com/OpenAPITools/openapi-generator/issues/5235 I couldn't find an issue about the python2 tests being disabled. I'm guessing build errors like the following were the trigger: https://travis-ci.org/github/OpenAPITools/openapi-generator/builds/634238181 Let's see what breaks! * [Python] Copy setup.py to python-aiohttp * [Python] Save history while copying setup.py to python-aiohttp * [Python] Add aiohttp server setup.py * [Python] Fix python server tests with src layout * [Python] bump Flask-Testing version * [Python] Pin pyyaml for py2.7 flask server * [Python] simplify flask server requirements * consolidate server tests * [Python] rebuild python server samples * [Python] Fix python server requirements for older pythons Documented minimum python version for our aiohttp server is 3.5. Documented minimum python version for our flask server is 3.4. Connexion 2.3 is the last version to support python 3.4 and 3.5, so fix the version pinning to correctly select <=2.3 for these EOL python versions. Newer pythons should get the latest if possible as there many relevant bug fixes. Werkzeug also needs to be pinned for these old versions in the aiohttp server just like for the flask server. 3.4 and 3.5 are EOL. We really should increase the minimum supported version, but that is for another PR to do. * stop error globally (#5858) * [PS][Experimental] Add validations to model (#5842) * add validations to model * better error message * improve validation * Updates to allow the setting of the dateTime format string (#5763) * [PS] Select Content-Type in the response (#5872) * better return type handling * update tempalte * better documentation * fix greater than * various enhancement to ps exp generator (#5875) * [C#] dependency upgrade (#5870) * Updating packages version (#5313) * Add support to RestSharp version 106.10.1 Restsharp 106.10.1 needs the Content Lenght as a parameter to AddFile method * Updating RestSharp Version Updating RestSharp Version * Update netcore_project.mustache * Update netcore_testproject.mustache * Update Project.mustache * Updating packages version Updating packages version * Updating packages version Updating packages version * Updating packages version Updating packages version * Updating packages version Updating packages version * Updating packages version Updating packages version * Updating packages version Updating packages version * Execute task async obsolete Use ExecuteAsync instead * update csharp samples Co-authored-by: William Cheng * [csharp] Library upgrade fix (#5848) * On .net45 framework, Restsharp version is updated to 106.10.1 Otherwise, it stays on version 105.1.0 * Added additionalProperties for library versions and target frameworks * Removed unused properties * Added an additional property to test for a specific version of RestSharp * Updated csharp samples * Fixed nuspec.mustache to use library specific additional properties * Updated csharp samples * Updating CI/samples.ci csharp petstore test project file. * Updated csharp.md Co-authored-by: Olivier Leonard * [csharp-client] Restored tests on csharp samples (#5879) * Restored tests on csharp samples * Restored a reference to the file used to test file uploads Co-authored-by: Olivier Leonard * update samples Co-authored-by: Igor Quirino Co-authored-by: Bouillie <34162532+Bouillie@users.noreply.github.com> Co-authored-by: Olivier Leonard * [Csharp-client] Complex form parameters are not serialized as application/json (#5849) * [csharp-client] Complex form parameters are now correctly serialized as json. * Updated csharp samples Co-authored-by: Olivier Leonard * docs: removes Nico from technical committee (#5883) * [PS] better handle special variables (#5885) * add variable * fix reserved words * update ps doc * [PS] add file post-processing to the PowerShell generator (#5864) * add post process to ps generator * add import * fix merge issue * consolidate header selection functions (#5889) * [Java-client] Add maven-compiler-plugin in pom.xml and enable linter checks by default (#5866) * Add maven-compiler-plugin plugin in Java pom.xml and enable linter checks by default * Add maven-compiler-plugin plugin in Java pom.xml and enable linter checks by default * Update enum.mustache (#5793) https://github.com/OpenAPITools/openapi-generator/issues/5792 * Update modelGeneric.mustache (#5378) * Update modelGeneric.mustache If maxlength is specified for a property type enum it there should be .ToString() appended before length check * ran the csharp petstore bar and updated the file Co-authored-by: Shweta Shukla * Fix Scala sttp generator packages (#5890) * Fix Scala sttp generator packages * Change package to parameterised * [Dart] Fix "basic" auth method and Add Bearer token support (#5743) * added auth check and lint * fixed basic auth condition * Added bearer auth * updated samples * update dart petstore samples Co-authored-by: William Cheng * Add date time format annotation on pojo for model query parameters (#5437) * Add date time format annotation on pojo for model query parameters * Regenetare samples * update spring samples Co-authored-by: William Cheng * [mysql] Add basic SQL queries (#5757) * Add basic SQL queries template * Add namedParametersEnabled option * Move model related SQLs into Model folder * Update README template * Refresh samples * [enhancement] [jaxrs-spec] Add builders to models (#4930) * Update formatting in jaxrs-spec POJOs * Add generateBuilders option * Update formatting in jaxrs-spec POJOs * Disable the builders generation by default * Ensure samples are up-to-date * Revert newline change * Run ensure-up-to-date * update doc * fix merge conflicts Co-authored-by: Artem Shubovych Co-authored-by: William Cheng * Update generated build files for REST Assured (#5873) * REST Assured 4.3.0 * Jackson 2.10.3 * Gson 2.8.6, GSON-Fire 1.8.4 * Okio 1.17.5 * Joda-Time 2.10.5 * ThreeTenBP 1.4.3 * Added missing dependencies for Bean Validation * Added missing dependencies for `@Generated` annotation * Refresh REST Assured sample project * [Java][Feign] Bug fix in @Param annotation (#5250) * FIX-5249 fix @Param annotation for Feign-client code generation Use paramName instead of baseName in order to make mapping in @Headers section fit the param-value. * update samples * FIX-5249 fix @Param annotation for Feign-client code generation Use paramName instead of baseName in order to make mapping in @Headers section fit the param-value. Co-authored-by: Christoph Preißner Co-authored-by: William Cheng * [Java] Increase java compiler stack size to handle large files (#5901) * increase java compiler stack size to handle large files * increase java compiler stack size to handle large files * Added emineo to list of companies on website (#5905) * add emineo to the list * [swift5] fix warning (#5900) * update bitwise config (#5904) * [Java] Discriminator lookup should not be case insensitive by default (#5894) * Add 'discriminatorCaseSensitive' property * Discriminator value lookup should not be case insensitive * fix typo * run scripts * execute ./bin/utils/export_docs_generators.sh * fix discriminator mapping, add code comments * minor fix to users.yml * Add a link to optim blog post (#5922) * [Java] Fix inclusive max validation (#5908) Co-authored-by: erikmolin * add bearer auth support to csharp netcore (#5921) * [Python][aiohttp] create venv as rule (#5913) * create venv as rule * create venv as rule II * Fix for Result Model Name collision (#5923) * Fix for Result Model Name collision * Run Scripts Co-authored-by: Sebastian Ohm * [Dart] Remove content type from header when content type is not specified (#5752) * accept empty content type * fixed test * updated samples * additional comment out * update dependency for java client (#5926) * Update axios dependency to the new minor version 0.19.0 (#5867) * Update axios dependency to 0.19.0 Axios (version 0.18.0) used by typescript-axios generator is more than two years old (released in Feb 2018). Axios 0.19.2 released earlier this year contains a lot of fixes and functionality, I recommend updating to 0.19.2. * Ran ./bin/typescript-axios-petstore-all.sh to update package.json in ./samples Co-authored-by: Chandra Yalangi * fixed README/doc of bearer auth support for csharp-netcore (#5931) * fix duplicated semi-colon in c# model (#5934) * [Python-experimental] Use DER encoding for ECDSA signatures, add parameter to configure hash algorithm (#5924) * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * Use DER encoding for ECDSA signatures * fix python unit tests for http message signature * Fix error message * format python code * format python code * [Python-experimental] Fix TypeError: unhashable type: 'list' (#5810) * handle scenario when value is a list, fix TypeError: unhashable type: 'list' * Add __hash__ function * use list instead of set * use list instead of set * use list instead of set * use list instead of set * use list instead of set * use list instead of set * [python/asyncio] fix passing proxy parameters to aiohttp (#5943) * [C][Client]Fix data lost when libcurl write-data callback function is called multiple times (#5828) * [C][Client]Fix the defect of data lost when libcurl write-data callback function (configured by CURLOPT_WRITEFUNCTION) is called multiple times. * [C][Client]Fix data lost when libcurl write-data callback function is called multiple times (Reset count) * [typescript-axios][client] Allow apiKey type Promise. (#5953) * change apiKey type * recreate sample * Add YITU Technology to the user list (#5967) * add yitu to the user list * use yitu technology * Use model as body param for generateAliasAsModel (#4569) * generateAliasAsModel: Use model name as body param * Update samples * resolve merge conflicts in the core generator files * fix merge conflicts in pom.xml * Resolve Elm merge conflicts * [Rust Server] Fix up merge conflicts * Update samples * [Rust Server] Add debug log for rust-server-petstore.sh * update samples * update more samples * fix dart openapi-generator version * remove deprecated c# files * update meta codegen * fix port in pom.xml * fix port in sample * update jaxrs cxf version Co-authored-by: sunn <33183834+etherealjoy@users.noreply.github.com> Co-authored-by: dwlabcube <46682038+dwlabcube@users.noreply.github.com> Co-authored-by: Herve DARRITCHON Co-authored-by: Akihito Nakano Co-authored-by: Johnny Peck Co-authored-by: Michele Albano Co-authored-by: Jim Schubert Co-authored-by: Nikita Co-authored-by: Alexey Makhrov Co-authored-by: val Co-authored-by: Bruno Coelho <4brunu@users.noreply.github.com> Co-authored-by: Aleksandr Nekrasov Co-authored-by: Akira Tanimura Co-authored-by: Justin Co-authored-by: Justin Black Co-authored-by: Jiri Kuncar Co-authored-by: Hui Yu Co-authored-by: Yutaka Miyamae <48900426+yutaka0m@users.noreply.github.com> Co-authored-by: Mateusz Szychowski (Muttley) Co-authored-by: Jorge Rodriguez Co-authored-by: Gonzalo Co-authored-by: ChristianCiach Co-authored-by: Bodo Graumann Co-authored-by: Yuriy Belenko Co-authored-by: Daniel Klessing Co-authored-by: copypasta-g <53397163+copypasta-g@users.noreply.github.com> Co-authored-by: Mahdi Dibaiee Co-authored-by: Sebastien Rosset Co-authored-by: siada Co-authored-by: Samuel Hoffstaetter Co-authored-by: Esteban Gehring Co-authored-by: Jon Schoning Co-authored-by: Marcin Kubala Co-authored-by: anoohya-n <51289018+anoohya-n@users.noreply.github.com> Co-authored-by: Antoine Reilles Co-authored-by: Clemens Angermann Co-authored-by: Mostafa Moradian Co-authored-by: Adam Co-authored-by: Lars Hvam Co-authored-by: sullis Co-authored-by: Vikrant Balyan Co-authored-by: Matt Traynham Co-authored-by: LEZIER-S2 <60382243+LEZIER-S2@users.noreply.github.com> Co-authored-by: Thomas Enderle Co-authored-by: YishTish Co-authored-by: Slavek Kabrda Co-authored-by: Tomasz Prus Co-authored-by: Erica Kastner Co-authored-by: Richard Whitehouse Co-authored-by: valentin Bisson Co-authored-by: etherealjoy Co-authored-by: Hemant Zope <42613258+zhemant@users.noreply.github.com> Co-authored-by: Even André Fiskvik Co-authored-by: ehansen31 Co-authored-by: Timur Platonov Co-authored-by: Josh Burton Co-authored-by: Ilja leyberman <7ilya@gmx.de> Co-authored-by: Bouillie <34162532+Bouillie@users.noreply.github.com> Co-authored-by: Olivier Leonard Co-authored-by: tanmen Co-authored-by: Alex Buchkovsky Co-authored-by: Natan Laverde Co-authored-by: Nicholas Muesch Co-authored-by: jburgess <11861789+jburgess@users.noreply.github.com> Co-authored-by: emileonhardt <40421857+emileonhardt@users.noreply.github.com> Co-authored-by: Jacob Floyd Co-authored-by: Igor Quirino Co-authored-by: Nico König Co-authored-by: https://gitlab.com/selankon Co-authored-by: Shweta Shukla <25539662+shwetashukla@users.noreply.github.com> Co-authored-by: Shweta Shukla Co-authored-by: Bartek Kowalik Co-authored-by: Shinya Sugmoto <34866626+gasugesu@users.noreply.github.com> Co-authored-by: Artem Shubovych Co-authored-by: Artem Shubovych Co-authored-by: Jochen Schalanda Co-authored-by: Chr1st0ph Co-authored-by: Christoph Preißner Co-authored-by: Erikmolin Co-authored-by: erikmolin Co-authored-by: Nicolas Homble Co-authored-by: Sebastian <63457660+sebohdev@users.noreply.github.com> Co-authored-by: Sebastian Ohm Co-authored-by: chandra-gh <63366477+chandra-gh@users.noreply.github.com> Co-authored-by: Chandra Yalangi Co-authored-by: Fabian Freund Co-authored-by: Erik Timmers --- api.mustache | 36 +++-- api_client.mustache | 16 ++- api_doc_example.mustache | 11 +- asyncio/rest.mustache | 25 ++-- configuration.mustache | 55 ++++++++ gitlab-ci.mustache | 38 ++++++ python-experimental/api_client.mustache | 3 +- python-experimental/api_doc_example.mustache | 11 +- python-experimental/model.mustache | 1 + .../method_init_composed.mustache | 27 ++-- .../method_init_normal.mustache | 12 +- .../method_init_shared.mustache | 36 +++-- .../methods_setattr_getattr_composed.mustache | 30 +++-- python-experimental/model_utils.mustache | 123 +++++++++++++----- python-experimental/requirements.mustache | 1 + python-experimental/setup.mustache | 1 + python-experimental/signing.mustache | 68 +++++++--- python_doc_auth_partial.mustache | 3 + travis.mustache | 9 +- 19 files changed, 372 insertions(+), 134 deletions(-) create mode 100644 gitlab-ci.mustache diff --git a/api.mustache b/api.mustache index f1a110bd47..f2c5541835 100644 --- a/api.mustache +++ b/api.mustache @@ -10,7 +10,7 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( +from {{packageName}}.exceptions import ( # noqa: F401 ApiTypeError, ApiValueError ) @@ -99,20 +99,36 @@ class {{classname}}(object): """ {{#servers.0}} - local_var_hosts = [{{#servers}}'{{{url}}}'{{^-last}}, {{/-last}}{{/servers}}] # noqa: E501 + local_var_hosts = [ +{{#servers}} + '{{{url}}}'{{^-last}},{{/-last}} +{{/servers}} + ] local_var_host = local_var_hosts[0] if kwargs.get('_host_index'): - if int(kwags.get('_host_index')) < 0 or int(kawgs.get('_host_index')) >= len(local_var_hosts): - raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) - local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] + _host_index = int(kwargs.get('_host_index')) + if _host_index < 0 or _host_index >= len(local_var_hosts): + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" + % len(local_var_host) + ) + local_var_host = local_var_hosts[_host_index] {{/servers.0}} local_var_params = locals() - all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = [ +{{#allParams}} + '{{paramName}}'{{#hasMore}},{{/hasMore}} +{{/allParams}} + ] + all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout' + ] + ) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: diff --git a/api_client.mustache b/api_client.mustache index 08de3bab85..c69e7d5945 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -63,7 +63,7 @@ class ApiClient(object): def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration() + configuration = Configuration.get_default_copy() self.configuration = configuration self.pool_threads = pool_threads @@ -76,13 +76,25 @@ class ApiClient(object): self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' self.client_side_validation = configuration.client_side_validation + {{#asyncio}} + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + {{/asyncio}} + {{^asyncio}} def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() + {{/asyncio}} - def close(self): + {{#asyncio}}async {{/asyncio}}def close(self): + {{#asyncio}} + await self.rest_client.close() + {{/asyncio}} if self._pool: self._pool.close() self._pool.join() diff --git a/api_doc_example.mustache b/api_doc_example.mustache index e86c5d6011..dadb8f6a96 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -5,24 +5,17 @@ import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} -{{#hasAuthMethods}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" # Enter a context with an instance of the API client +{{#hasAuthMethods}} with {{{packageName}}}.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) - {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} - {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} -# Enter a context with an instance of the API client with {{{packageName}}}.ApiClient() as api_client: +{{/hasAuthMethods}} # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} -{{/hasAuthMethods}} try: {{#summary}} # {{{.}}} diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 4585f1c6ad..f2099c7531 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -10,7 +10,6 @@ import ssl import aiohttp import certifi -import asyncio # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode @@ -66,19 +65,16 @@ class RESTClientObject(object): ssl=ssl_context ) + self.proxy = configuration.proxy + self.proxy_headers = configuration.proxy_headers + # https pool manager - if configuration.proxy: - self.pool_manager = aiohttp.ClientSession( - connector=connector, - proxy=configuration.proxy - ) - else: - self.pool_manager = aiohttp.ClientSession( - connector=connector - ) + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) - def __del__(self): - asyncio.ensure_future(self.pool_manager.close()) + async def close(self): + await self.pool_manager.close() async def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, @@ -123,6 +119,11 @@ class RESTClientObject(object): "headers": headers } + if self.proxy: + args["proxy"] = self.proxy + if self.proxy_headers: + args["proxy_headers"] = self.proxy_headers + if query_params: args["url"] += '?' + urlencode(query_params) diff --git a/configuration.mustache b/configuration.mustache index 0645bc4675..6581e603ad 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -4,6 +4,7 @@ from __future__ import absolute_import +import copy import logging {{^asyncio}} import multiprocessing @@ -31,6 +32,17 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. {{#hasHttpSignatureMethods}} :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration @@ -117,9 +129,12 @@ class Configuration(object): {{/hasAuthMethods}} """ + _default = None + def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, username=None, password=None, + discard_unknown_keys=False, {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} @@ -152,6 +167,7 @@ class Configuration(object): self.password = password """Password for HTTP basic authentication """ + self.discard_unknown_keys = discard_unknown_keys {{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host @@ -241,6 +257,45 @@ class Configuration(object): # Disable client side validation self.client_side_validation = True + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + @property def logger_file(self): """The logger file. diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache new file mode 100644 index 0000000000..2cabff63c7 --- /dev/null +++ b/gitlab-ci.mustache @@ -0,0 +1,38 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.nosetest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + {{#useNose}} + - nosetests + {{/useNose}} + {{^useNose}} + - pytest --cov={{{packageName}}} + {{/useNose}} + +nosetest-2.7: + extends: .nosetest + image: python:2.7-alpine +nosetest-3.3: + extends: .nosetest + image: python:3.3-alpine +nosetest-3.4: + extends: .nosetest + image: python:3.4-alpine +nosetest-3.5: + extends: .nosetest + image: python:3.5-alpine +nosetest-3.6: + extends: .nosetest + image: python:3.6-alpine +nosetest-3.7: + extends: .nosetest + image: python:3.7-alpine +nosetest-3.8: + extends: .nosetest + image: python:3.8-alpine diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 78f502b00d..774dae89c6 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -21,6 +21,7 @@ from {{packageName}}.exceptions import ApiValueError from {{packageName}}.model_utils import ( ModelNormal, ModelSimple, + ModelComposed, date, datetime, deserialize_file, @@ -240,7 +241,7 @@ class ApiClient(object): if isinstance(obj, dict): obj_dict = obj - elif isinstance(obj, ModelNormal): + elif isinstance(obj, ModelNormal) or isinstance(obj, ModelComposed): # Convert model obj to dict # Convert attribute name to json key in # model definition for request diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index 565d00a3b9..ae7b8a6979 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -4,20 +4,15 @@ import time import {{{packageName}}} from pprint import pprint {{> python_doc_auth_partial}} -{{#hasAuthMethods}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" # Enter a context with an instance of the API client +{{#hasAuthMethods}} with {{{packageName}}}.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{/hasAuthMethods}} {{^hasAuthMethods}} -# Enter a context with an instance of the API client -with {{{packageName}}}.ApiClient(configuration) as api_client: +with {{{packageName}}}.ApiClient() as api_client: +{{/hasAuthMethods}} # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) -{{/hasAuthMethods}} {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 0ca198ddf9..ef7da57282 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -7,6 +7,7 @@ import re # noqa: F401 import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index 5ed5993fe9..e00bf129b2 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -11,32 +11,39 @@ {{> python-experimental/model_templates/method_init_shared }} - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { {{#requiredVars}} '{{name}}': {{name}}, {{/requiredVars}} } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] -{{#requiredVars}} - self.{{name}} = {{name}} -{{/requiredVars}} + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index b053427a79..d26506c56c 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -8,14 +8,14 @@ {{> python-experimental/model_templates/method_init_shared }} - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} for var_name, var_value in six.iteritems(kwargs): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 2f3b70ea69..9dd5bc2b6f 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,11 +1,23 @@ def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} -{{/hasMore}}{{/requiredVars}} - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} +{{#requiredVars}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/requiredVars}} _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -18,6 +30,14 @@ _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted - If omitted no type conversion is done.{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ \ No newline at end of file + If omitted no type conversion is done. +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration \ No newline at end of file diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index e5eee88a96..9420fe1582 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -41,21 +41,29 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) + values = [] + # A composed model stores child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. A named property can exist in + # multiple child models. If the property is present in more than one + # child model, the value must be the same across all the child models. if model_instances: - values = set() for model_instance in model_instances: if name in model_instance._data_store: - values.add(model_instance._data_store[name]) - if len(values) == 1: - return list(values)[0] + v = model_instance._data_store[name] + if v not in values: + values.append(v) + len_values = len(values) + if len_values == 0: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif len_values == 1: + return values[0] + elif len_values > 1: raise ApiValueError( - "Values stored for property {0} in {1} difffer when looking " + "Values stored for property {0} in {1} differ when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item - ) - - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) \ No newline at end of file + ) \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index c3d9e7d536..8b60618c1d 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -464,7 +464,11 @@ def get_required_type_classes(required_types_mixed): def change_keys_js_to_python(input_dict, model_class): """ Converts from javascript_key keys in the input_dict to python_keys in - the output dict using the mapping in model_class + the output dict using the mapping in model_class. + If the input_dict contains a key which does not declared in the model_class, + the key is added to the output dict as is. The assumption is the model_class + may have undeclared properties (additionalProperties attribute in the OAS + document). """ output_dict = {} @@ -677,8 +681,9 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us - raise get_type_error(input_value, path_to_item, valid_classes, - key_type=key_type) + if configuration is None or not configuration.discard_unknown_keys: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) for valid_class in valid_classes_coercible: try: if issubclass(valid_class, OpenApiModel): @@ -827,7 +832,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances = model_instance._composed_instances + model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -935,53 +940,88 @@ def get_allof_instances(self, model_args, constant_args): # and use it to make the instance kwargs.update(constant_args) - allof_instance = allof_class(**kwargs) - composed_instances.append(allof_instance) + try: + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) + except Exception as ex: + raise ApiValueError( + "Invalid inputs given to generate an instance of '%s'. The " + "input data was invalid for the allOf schema '%s' in the composed " + "schema '%s'. Error=%s" % ( + allof_class.__class__.__name__, + allof_class.__class__.__name__, + self.__class__.__name__, + str(ex) + ) + ) return composed_instances def get_oneof_instance(self, model_args, constant_args): """ + Find the oneOf schema that matches the input data (e.g. payload). + If exactly one schema matches the input data, an instance of that schema + is returned. + If zero or more than one schema match the input data, an exception is raised. + In OAS 3.x, the payload MUST, by validation, match exactly one of the + schemas described by oneOf. Args: self: the class we are handling model_args (dict): var_name to var_value - used to make instances + The input data, e.g. the payload that must match a oneOf schema + in the OpenAPI document. constant_args (dict): var_name to var_value - used to make instances + args that every model requires, including configuration, server + and path to item. Returns - oneof_instance (instance) + oneof_instance (instance/None) """ - oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return oneof_instance + return None + oneof_instances = [] + # Iterate over each oneOf schema and determine if the input data + # matches the oneOf schemas. for oneof_class in self._composed_schemas()['oneOf']: - # transform js keys to python keys in fixed_model_args + # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) - # extract a dict of only required keys from fixed_model_args + # Extract a dict with the properties that are declared in the oneOf schema. + # Undeclared properties (e.g. properties that are allowed because of the + # additionalProperties attribute in the OAS document) are not added to + # the dict. kwargs = {} var_names = set(oneof_class.openapi_types().keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - break + oneof_instances.append(oneof_instance) except Exception: pass - if oneof_instance is None: + if len(oneof_instances) == 0: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. Unable to " - "make any instances of the classes in oneOf definition." % + "Invalid inputs given to generate an instance of %s. None " + "of the oneOf schemas matched the input data." % self.__class__.__name__ ) - return oneof_instance + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf schemas matched the inputs, but a max of one is allowed." % + self.__class__.__name__ + ) + return oneof_instances[0] def get_anyof_instances(self, model_args, constant_args): @@ -1011,6 +1051,10 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: @@ -1020,8 +1064,8 @@ def get_anyof_instances(self, model_args, constant_args): pass if len(anyof_instances) == 0: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. Unable to " - "make any instances of the classes in anyOf definition." % + "Invalid inputs given to generate an instance of %s. None of the " + "anyOf schemas matched the inputs." % self.__class__.__name__ ) return anyof_instances @@ -1072,10 +1116,18 @@ def get_unused_args(self, composed_instances, model_args): def validate_get_composed_info(constant_args, model_args, self): """ - For composed schemas/classes, validates the classes to make sure that - they do not share any of the same parameters. If there is no collision - then composed model instances are created and returned tot the calling - self model + For composed schemas, generate schema instances for + all schemas in the oneOf/anyOf/allOf definition. If additional + properties are allowed, also assign those properties on + all matched schemas that contain additionalProperties. + Openapi schemas are python classes. + + Exceptions are raised if: + - no oneOf schema matches the model_args input data + - > 1 oneOf schema matches the model_args input data + - > 1 oneOf schema matches the model_args input data + - no anyOf schema matches the model_args input data + - any of the allOf schemas do not match the model_args input data Args: constant_args (dict): these are the args that every model requires @@ -1117,16 +1169,16 @@ def validate_get_composed_info(constant_args, model_args, self): # set any remaining values unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0: - if len(additional_properties_model_instances) == 0: - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - for var_name, var_value in six.iteritems(unused_args): - for instance in additional_properties_model_instances: - setattr(instance, var_name, var_value) + if len(unused_args) > 0 and \ + len(additional_properties_model_instances) == 0 and \ + (self._configuration is None or + not self._configuration.discard_unknown_keys): + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + # no need to add additional_properties to var_name_to_model_instances here # because additional_properties_model_instances will direct us to that # instance when we use getattr or setattr @@ -1135,5 +1187,6 @@ def validate_get_composed_info(constant_args, model_args, self): return [ composed_instances, var_name_to_model_instances, - additional_properties_model_instances + additional_properties_model_instances, + unused_args ] diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache index eb358efd5b..a56bedffbf 100644 --- a/python-experimental/requirements.mustache +++ b/python-experimental/requirements.mustache @@ -1,3 +1,4 @@ +nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 2fe84efcee..796475c456 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -21,6 +21,7 @@ REQUIRES = [ "six >= 1.10", "certifi", "python-dateutil", + "nulltype", {{#asyncio}} "aiohttp >= 3.0.0", {{/asyncio}} diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index 300efa007b..0be0e1c467 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -7,13 +7,12 @@ from Crypto.IO import PEM, PKCS8 from Crypto.Hash import SHA256, SHA512 from Crypto.PublicKey import RSA, ECC from Crypto.Signature import PKCS1_v1_5, pss, DSS -from datetime import datetime from email.utils import formatdate import json import os import re from six.moves.urllib.parse import urlencode, urlparse -from time import mktime +from time import time # The constants below define a subset of HTTP headers that can be included in the # HTTP signature scheme. Additional headers may be included in the signature. @@ -54,6 +53,10 @@ ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 } +# The cryptographic hash algorithm for the message signature. +HASH_SHA256 = 'sha256' +HASH_SHA512 = 'sha512' + class HttpSigningConfiguration(object): """The configuration parameters for the HTTP signature security scheme. @@ -99,9 +102,15 @@ class HttpSigningConfiguration(object): Supported values are: 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. - The default value is inferred from the private key. - The default value for RSA keys is RSASSA-PSS. - The default value for ECDSA keys is fips-186-3. + If None, the signing algorithm is inferred from the private key. + The default signing algorithm for RSA keys is RSASSA-PSS. + The default signing algorithm for ECDSA keys is fips-186-3. + :param hash_algorithm: The hash algorithm for the signature. Supported values are + sha256 and sha512. + If the signing_scheme is rsa-sha256, the hash algorithm must be set + to None or sha256. + If the signing_scheme is rsa-sha512, the hash algorithm must be set + to None or sha512. :param signature_max_validity: The signature max validity, expressed as a datetime.timedelta value. It must be a positive value. """ @@ -109,6 +118,7 @@ class HttpSigningConfiguration(object): private_key_passphrase=None, signed_headers=None, signing_algorithm=None, + hash_algorithm=None, signature_max_validity=None): self.key_id = key_id if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: @@ -119,6 +129,24 @@ class HttpSigningConfiguration(object): self.private_key_path = private_key_path self.private_key_passphrase = private_key_passphrase self.signing_algorithm = signing_algorithm + self.hash_algorithm = hash_algorithm + if signing_scheme == SCHEME_RSA_SHA256: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm != HASH_SHA256: + raise Exception("Hash algorithm must be sha256 when security scheme is %s" % + SCHEME_RSA_SHA256) + elif signing_scheme == SCHEME_RSA_SHA512: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA512 + elif self.hash_algorithm != HASH_SHA512: + raise Exception("Hash algorithm must be sha512 when security scheme is %s" % + SCHEME_RSA_SHA512) + elif signing_scheme == SCHEME_HS2019: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}: + raise Exception("Invalid hash algorithm") if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: raise Exception("The signature max validity must be a positive value") self.signature_max_validity = signature_max_validity @@ -228,12 +256,6 @@ class HttpSigningConfiguration(object): "Signing algorithm {0} is not compatible with private key".format( self.signing_algorithm)) - def _get_unix_time(self, ts): - """Converts and returns a datetime object to UNIX time, the number of seconds - elapsed since January 1, 1970 UTC. - """ - return (ts - datetime(1970, 1, 1)).total_seconds() - def _get_signed_header_info(self, resource_path, method, headers, body, query_params): """Build the HTTP headers (name, value) that need to be included in the HTTP signature scheme. @@ -262,15 +284,16 @@ class HttpSigningConfiguration(object): if query_params: request_target += "?" + urlencode(query_params) - # Get current time and generate RFC 1123 (HTTP/1.1) date/time string. - now = datetime.now() - stamp = mktime(now.timetuple()) - cdate = formatdate(timeval=stamp, localtime=False, usegmt=True) + # Get UNIX time, e.g. seconds since epoch, not including leap seconds. + now = time() + # Format date per RFC 7231 section-7.1.1.2. An example is: + # Date: Wed, 21 Oct 2015 07:28:00 GMT + cdate = formatdate(timeval=now, localtime=False, usegmt=True) # The '(created)' value MUST be a Unix timestamp integer value. # Subsecond precision is not supported. - created = int(self._get_unix_time(now)) + created = int(now) if self.signature_max_validity is not None: - expires = self._get_unix_time(now + self.signature_max_validity) + expires = now + self.signature_max_validity.total_seconds() signed_headers_list = [] request_headers_dict = {} @@ -315,14 +338,14 @@ class HttpSigningConfiguration(object): The prefix is a string that identifies the cryptographc hash. It is used to generate the 'Digest' header as specified in RFC 3230. """ - if self.signing_scheme in {SCHEME_RSA_SHA512, SCHEME_HS2019}: + if self.hash_algorithm == HASH_SHA512: digest = SHA512.new() prefix = 'SHA-512=' - elif self.signing_scheme == SCHEME_RSA_SHA256: + elif self.hash_algorithm == HASH_SHA256: digest = SHA256.new() prefix = 'SHA-256=' else: - raise Exception("Unsupported signing algorithm: {0}".format(self.signing_scheme)) + raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm)) digest.update(data) return digest, prefix @@ -346,7 +369,10 @@ class HttpSigningConfiguration(object): if sig_alg is None: sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: - signature = DSS.new(self.private_key, sig_alg).sign(digest) + # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. + # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 + signature = DSS.new(key=self.private_key, mode=sig_alg, + encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) else: diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 9f5b49f821..d8cfc4ad11 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -45,4 +45,7 @@ configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' configuration.access_token = 'YOUR_ACCESS_TOKEN' {{/isOAuth}} {{/authMethods}} + +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" {{/hasAuthMethods}} diff --git a/travis.mustache b/travis.mustache index 388de83128..195488737d 100644 --- a/travis.mustache +++ b/travis.mustache @@ -10,6 +10,13 @@ python: - "3.7" - "3.8" # command to install dependencies -install: "pip install -r requirements.txt" +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" # command to run tests +{{#useNose}} script: nosetests +{{/useNose}} +{{^useNose}} +script: pytest --cov={{{packageName}}} +{{/useNose}} From 50238bff045990043f962761d55eff6948e77aa5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 22 Apr 2020 11:59:27 +0800 Subject: [PATCH 099/185] Revert "Sync master to 5.0.x (#5968)" This reverts commit 90dd7a03418ff4554ae8351b325eb86ee5794e92. --- api.mustache | 36 ++--- api_client.mustache | 16 +-- api_doc_example.mustache | 11 +- asyncio/rest.mustache | 25 ++-- configuration.mustache | 55 -------- gitlab-ci.mustache | 38 ------ python-experimental/api_client.mustache | 3 +- python-experimental/api_doc_example.mustache | 11 +- python-experimental/model.mustache | 1 - .../method_init_composed.mustache | 27 ++-- .../method_init_normal.mustache | 12 +- .../method_init_shared.mustache | 36 ++--- .../methods_setattr_getattr_composed.mustache | 30 ++--- python-experimental/model_utils.mustache | 123 +++++------------- python-experimental/requirements.mustache | 1 - python-experimental/setup.mustache | 1 - python-experimental/signing.mustache | 68 +++------- python_doc_auth_partial.mustache | 3 - travis.mustache | 9 +- 19 files changed, 134 insertions(+), 372 deletions(-) delete mode 100644 gitlab-ci.mustache diff --git a/api.mustache b/api.mustache index f2c5541835..f1a110bd47 100644 --- a/api.mustache +++ b/api.mustache @@ -10,7 +10,7 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( # noqa: F401 +from {{packageName}}.exceptions import ( ApiTypeError, ApiValueError ) @@ -99,36 +99,20 @@ class {{classname}}(object): """ {{#servers.0}} - local_var_hosts = [ -{{#servers}} - '{{{url}}}'{{^-last}},{{/-last}} -{{/servers}} - ] + local_var_hosts = [{{#servers}}'{{{url}}}'{{^-last}}, {{/-last}}{{/servers}}] # noqa: E501 local_var_host = local_var_hosts[0] if kwargs.get('_host_index'): - _host_index = int(kwargs.get('_host_index')) - if _host_index < 0 or _host_index >= len(local_var_hosts): - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" - % len(local_var_host) - ) - local_var_host = local_var_hosts[_host_index] + if int(kwags.get('_host_index')) < 0 or int(kawgs.get('_host_index')) >= len(local_var_hosts): + raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) + local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] {{/servers.0}} local_var_params = locals() - all_params = [ -{{#allParams}} - '{{paramName}}'{{#hasMore}},{{/hasMore}} -{{/allParams}} - ] - all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout' - ] - ) + all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: diff --git a/api_client.mustache b/api_client.mustache index c69e7d5945..08de3bab85 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -63,7 +63,7 @@ class ApiClient(object): def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration.get_default_copy() + configuration = Configuration() self.configuration = configuration self.pool_threads = pool_threads @@ -76,25 +76,13 @@ class ApiClient(object): self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' self.client_side_validation = configuration.client_side_validation - {{#asyncio}} - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc_value, traceback): - await self.close() - {{/asyncio}} - {{^asyncio}} def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() - {{/asyncio}} - {{#asyncio}}async {{/asyncio}}def close(self): - {{#asyncio}} - await self.rest_client.close() - {{/asyncio}} + def close(self): if self._pool: self._pool.close() self._pool.join() diff --git a/api_doc_example.mustache b/api_doc_example.mustache index dadb8f6a96..e86c5d6011 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -5,17 +5,24 @@ import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} -# Enter a context with an instance of the API client {{#hasAuthMethods}} +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Enter a context with an instance of the API client with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} {{/hasAuthMethods}} {{^hasAuthMethods}} +# Enter a context with an instance of the API client with {{{packageName}}}.ApiClient() as api_client: -{{/hasAuthMethods}} # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} +{{/hasAuthMethods}} try: {{#summary}} # {{{.}}} diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index f2099c7531..4585f1c6ad 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -10,6 +10,7 @@ import ssl import aiohttp import certifi +import asyncio # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode @@ -65,16 +66,19 @@ class RESTClientObject(object): ssl=ssl_context ) - self.proxy = configuration.proxy - self.proxy_headers = configuration.proxy_headers - # https pool manager - self.pool_manager = aiohttp.ClientSession( - connector=connector - ) + if configuration.proxy: + self.pool_manager = aiohttp.ClientSession( + connector=connector, + proxy=configuration.proxy + ) + else: + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) - async def close(self): - await self.pool_manager.close() + def __del__(self): + asyncio.ensure_future(self.pool_manager.close()) async def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, @@ -119,11 +123,6 @@ class RESTClientObject(object): "headers": headers } - if self.proxy: - args["proxy"] = self.proxy - if self.proxy_headers: - args["proxy_headers"] = self.proxy_headers - if query_params: args["url"] += '?' + urlencode(query_params) diff --git a/configuration.mustache b/configuration.mustache index 6581e603ad..0645bc4675 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -4,7 +4,6 @@ from __future__ import absolute_import -import copy import logging {{^asyncio}} import multiprocessing @@ -32,17 +31,6 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. {{#hasHttpSignatureMethods}} :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration @@ -129,12 +117,9 @@ class Configuration(object): {{/hasAuthMethods}} """ - _default = None - def __init__(self, host="{{{basePath}}}", api_key=None, api_key_prefix=None, username=None, password=None, - discard_unknown_keys=False, {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} @@ -167,7 +152,6 @@ class Configuration(object): self.password = password """Password for HTTP basic authentication """ - self.discard_unknown_keys = discard_unknown_keys {{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host @@ -257,45 +241,6 @@ class Configuration(object): # Disable client side validation self.client_side_validation = True - def __deepcopy__(self, memo): - cls = self.__class__ - result = cls.__new__(cls) - memo[id(self)] = result - for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): - setattr(result, k, copy.deepcopy(v, memo)) - # shallow copy of loggers - result.logger = copy.copy(self.logger) - # use setters to configure loggers - result.logger_file = self.logger_file - result.debug = self.debug - return result - - @classmethod - def set_default(cls, default): - """Set default instance of configuration. - - It stores default configuration, which can be - returned by get_default_copy method. - - :param default: object of Configuration - """ - cls._default = copy.deepcopy(default) - - @classmethod - def get_default_copy(cls): - """Return new instance of configuration. - - This method returns newly created, based on default constructor, - object of Configuration class or returns a copy of default - configuration passed by the set_default method. - - :return: The configuration object. - """ - if cls._default is not None: - return copy.deepcopy(cls._default) - return Configuration() - @property def logger_file(self): """The logger file. diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache deleted file mode 100644 index 2cabff63c7..0000000000 --- a/gitlab-ci.mustache +++ /dev/null @@ -1,38 +0,0 @@ -# ref: https://docs.gitlab.com/ee/ci/README.html - -stages: - - test - -.nosetest: - stage: test - script: - - pip install -r requirements.txt - - pip install -r test-requirements.txt - {{#useNose}} - - nosetests - {{/useNose}} - {{^useNose}} - - pytest --cov={{{packageName}}} - {{/useNose}} - -nosetest-2.7: - extends: .nosetest - image: python:2.7-alpine -nosetest-3.3: - extends: .nosetest - image: python:3.3-alpine -nosetest-3.4: - extends: .nosetest - image: python:3.4-alpine -nosetest-3.5: - extends: .nosetest - image: python:3.5-alpine -nosetest-3.6: - extends: .nosetest - image: python:3.6-alpine -nosetest-3.7: - extends: .nosetest - image: python:3.7-alpine -nosetest-3.8: - extends: .nosetest - image: python:3.8-alpine diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 774dae89c6..78f502b00d 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -21,7 +21,6 @@ from {{packageName}}.exceptions import ApiValueError from {{packageName}}.model_utils import ( ModelNormal, ModelSimple, - ModelComposed, date, datetime, deserialize_file, @@ -241,7 +240,7 @@ class ApiClient(object): if isinstance(obj, dict): obj_dict = obj - elif isinstance(obj, ModelNormal) or isinstance(obj, ModelComposed): + elif isinstance(obj, ModelNormal): # Convert model obj to dict # Convert attribute name to json key in # model definition for request diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index ae7b8a6979..565d00a3b9 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -4,15 +4,20 @@ import time import {{{packageName}}} from pprint import pprint {{> python_doc_auth_partial}} -# Enter a context with an instance of the API client {{#hasAuthMethods}} +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Enter a context with an instance of the API client with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{/hasAuthMethods}} {{^hasAuthMethods}} -with {{{packageName}}}.ApiClient() as api_client: -{{/hasAuthMethods}} +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) +{{/hasAuthMethods}} {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index ef7da57282..0ca198ddf9 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -7,7 +7,6 @@ import re # noqa: F401 import sys # noqa: F401 import six # noqa: F401 -import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index e00bf129b2..5ed5993fe9 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -11,39 +11,32 @@ {{> python-experimental/model_templates/method_init_shared }} + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, } - required_args = { + model_args = { {{#requiredVars}} '{{name}}': {{name}}, {{/requiredVars}} } - # remove args whose value is Null because they are unset - required_arg_names = list(required_args.keys()) - for required_arg_name in required_arg_names: - if required_args[required_arg_name] is nulltype.Null: - del required_args[required_arg_name] - model_args = {} - model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} for var_name, var_value in six.iteritems(kwargs): - if var_name in unused_args and \ - self._configuration is not None and \ - self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: - # discard variable. - continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index d26506c56c..b053427a79 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -8,14 +8,14 @@ {{> python-experimental/model_templates/method_init_shared }} + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} for var_name, var_value in six.iteritems(kwargs): - if var_name not in self.attribute_map and \ - self._configuration is not None and \ - self._configuration.discard_unknown_keys and \ - self.additional_properties_type is None: - # discard variable. - continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 9dd5bc2b6f..2f3b70ea69 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,23 +1,11 @@ def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI -{{#requiredVars}} -{{#-first}} - Args: -{{/-first}} -{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}} -{{/defaultValue}} -{{#-last}} - -{{/-last}} -{{/requiredVars}} - Keyword Args: -{{#requiredVars}} -{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 -{{/defaultValue}} -{{/requiredVars}} +{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} +{{/hasMore}}{{/requiredVars}} + Keyword Args:{{#requiredVars}}{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -30,14 +18,6 @@ _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted - If omitted no type conversion is done. -{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 -{{/optionalVars}} - """ - - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration \ No newline at end of file + If omitted no type conversion is done.{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + """ \ No newline at end of file diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index 9420fe1582..e5eee88a96 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -41,29 +41,21 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) - values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. if model_instances: + values = set() for model_instance in model_instances: if name in model_instance._data_store: - v = model_instance._data_store[name] - if v not in values: - values.append(v) - len_values = len(values) - if len_values == 0: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif len_values == 1: - return values[0] - elif len_values > 1: + values.add(model_instance._data_store[name]) + if len(values) == 1: + return list(values)[0] raise ApiValueError( - "Values stored for property {0} in {1} differ when looking " + "Values stored for property {0} in {1} difffer when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item - ) \ No newline at end of file + ) + + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 8b60618c1d..c3d9e7d536 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -464,11 +464,7 @@ def get_required_type_classes(required_types_mixed): def change_keys_js_to_python(input_dict, model_class): """ Converts from javascript_key keys in the input_dict to python_keys in - the output dict using the mapping in model_class. - If the input_dict contains a key which does not declared in the model_class, - the key is added to the output dict as is. The assumption is the model_class - may have undeclared properties (additionalProperties attribute in the OAS - document). + the output dict using the mapping in model_class """ output_dict = {} @@ -681,9 +677,8 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us - if configuration is None or not configuration.discard_unknown_keys: - raise get_type_error(input_value, path_to_item, valid_classes, - key_type=key_type) + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) for valid_class in valid_classes_coercible: try: if issubclass(valid_class, OpenApiModel): @@ -832,7 +827,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances.extend(model_instance._composed_instances) + model_instances = model_instance._composed_instances for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -940,88 +935,53 @@ def get_allof_instances(self, model_args, constant_args): # and use it to make the instance kwargs.update(constant_args) - try: - allof_instance = allof_class(**kwargs) - composed_instances.append(allof_instance) - except Exception as ex: - raise ApiValueError( - "Invalid inputs given to generate an instance of '%s'. The " - "input data was invalid for the allOf schema '%s' in the composed " - "schema '%s'. Error=%s" % ( - allof_class.__class__.__name__, - allof_class.__class__.__name__, - self.__class__.__name__, - str(ex) - ) - ) + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) return composed_instances def get_oneof_instance(self, model_args, constant_args): """ - Find the oneOf schema that matches the input data (e.g. payload). - If exactly one schema matches the input data, an instance of that schema - is returned. - If zero or more than one schema match the input data, an exception is raised. - In OAS 3.x, the payload MUST, by validation, match exactly one of the - schemas described by oneOf. Args: self: the class we are handling model_args (dict): var_name to var_value - The input data, e.g. the payload that must match a oneOf schema - in the OpenAPI document. + used to make instances constant_args (dict): var_name to var_value - args that every model requires, including configuration, server - and path to item. + used to make instances Returns - oneof_instance (instance/None) + oneof_instance (instance) """ + oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return None + return oneof_instance - oneof_instances = [] - # Iterate over each oneOf schema and determine if the input data - # matches the oneOf schemas. for oneof_class in self._composed_schemas()['oneOf']: - # transform js keys from input data to python keys in fixed_model_args + # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. + # extract a dict of only required keys from fixed_model_args kwargs = {} var_names = set(oneof_class.openapi_types().keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - oneof_instances.append(oneof_instance) + break except Exception: pass - if len(oneof_instances) == 0: + if oneof_instance is None: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. None " - "of the oneOf schemas matched the input data." % + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in oneOf definition." % self.__class__.__name__ ) - elif len(oneof_instances) > 1: - raise ApiValueError( - "Invalid inputs given to generate an instance of %s. Multiple " - "oneOf schemas matched the inputs, but a max of one is allowed." % - self.__class__.__name__ - ) - return oneof_instances[0] + return oneof_instance def get_anyof_instances(self, model_args, constant_args): @@ -1051,10 +1011,6 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - # and use it to make the instance kwargs.update(constant_args) try: @@ -1064,8 +1020,8 @@ def get_anyof_instances(self, model_args, constant_args): pass if len(anyof_instances) == 0: raise ApiValueError( - "Invalid inputs given to generate an instance of %s. None of the " - "anyOf schemas matched the inputs." % + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in anyOf definition." % self.__class__.__name__ ) return anyof_instances @@ -1116,18 +1072,10 @@ def get_unused_args(self, composed_instances, model_args): def validate_get_composed_info(constant_args, model_args, self): """ - For composed schemas, generate schema instances for - all schemas in the oneOf/anyOf/allOf definition. If additional - properties are allowed, also assign those properties on - all matched schemas that contain additionalProperties. - Openapi schemas are python classes. - - Exceptions are raised if: - - no oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - no anyOf schema matches the model_args input data - - any of the allOf schemas do not match the model_args input data + For composed schemas/classes, validates the classes to make sure that + they do not share any of the same parameters. If there is no collision + then composed model instances are created and returned tot the calling + self model Args: constant_args (dict): these are the args that every model requires @@ -1169,16 +1117,16 @@ def validate_get_composed_info(constant_args, model_args, self): # set any remaining values unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) - + if len(unused_args) > 0: + if len(additional_properties_model_instances) == 0: + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + for var_name, var_value in six.iteritems(unused_args): + for instance in additional_properties_model_instances: + setattr(instance, var_name, var_value) # no need to add additional_properties to var_name_to_model_instances here # because additional_properties_model_instances will direct us to that # instance when we use getattr or setattr @@ -1187,6 +1135,5 @@ def validate_get_composed_info(constant_args, model_args, self): return [ composed_instances, var_name_to_model_instances, - additional_properties_model_instances, - unused_args + additional_properties_model_instances ] diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache index a56bedffbf..eb358efd5b 100644 --- a/python-experimental/requirements.mustache +++ b/python-experimental/requirements.mustache @@ -1,4 +1,3 @@ -nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 796475c456..2fe84efcee 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -21,7 +21,6 @@ REQUIRES = [ "six >= 1.10", "certifi", "python-dateutil", - "nulltype", {{#asyncio}} "aiohttp >= 3.0.0", {{/asyncio}} diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index 0be0e1c467..300efa007b 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -7,12 +7,13 @@ from Crypto.IO import PEM, PKCS8 from Crypto.Hash import SHA256, SHA512 from Crypto.PublicKey import RSA, ECC from Crypto.Signature import PKCS1_v1_5, pss, DSS +from datetime import datetime from email.utils import formatdate import json import os import re from six.moves.urllib.parse import urlencode, urlparse -from time import time +from time import mktime # The constants below define a subset of HTTP headers that can be included in the # HTTP signature scheme. Additional headers may be included in the signature. @@ -53,10 +54,6 @@ ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 } -# The cryptographic hash algorithm for the message signature. -HASH_SHA256 = 'sha256' -HASH_SHA512 = 'sha512' - class HttpSigningConfiguration(object): """The configuration parameters for the HTTP signature security scheme. @@ -102,15 +99,9 @@ class HttpSigningConfiguration(object): Supported values are: 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. - If None, the signing algorithm is inferred from the private key. - The default signing algorithm for RSA keys is RSASSA-PSS. - The default signing algorithm for ECDSA keys is fips-186-3. - :param hash_algorithm: The hash algorithm for the signature. Supported values are - sha256 and sha512. - If the signing_scheme is rsa-sha256, the hash algorithm must be set - to None or sha256. - If the signing_scheme is rsa-sha512, the hash algorithm must be set - to None or sha512. + The default value is inferred from the private key. + The default value for RSA keys is RSASSA-PSS. + The default value for ECDSA keys is fips-186-3. :param signature_max_validity: The signature max validity, expressed as a datetime.timedelta value. It must be a positive value. """ @@ -118,7 +109,6 @@ class HttpSigningConfiguration(object): private_key_passphrase=None, signed_headers=None, signing_algorithm=None, - hash_algorithm=None, signature_max_validity=None): self.key_id = key_id if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: @@ -129,24 +119,6 @@ class HttpSigningConfiguration(object): self.private_key_path = private_key_path self.private_key_passphrase = private_key_passphrase self.signing_algorithm = signing_algorithm - self.hash_algorithm = hash_algorithm - if signing_scheme == SCHEME_RSA_SHA256: - if self.hash_algorithm is None: - self.hash_algorithm = HASH_SHA256 - elif self.hash_algorithm != HASH_SHA256: - raise Exception("Hash algorithm must be sha256 when security scheme is %s" % - SCHEME_RSA_SHA256) - elif signing_scheme == SCHEME_RSA_SHA512: - if self.hash_algorithm is None: - self.hash_algorithm = HASH_SHA512 - elif self.hash_algorithm != HASH_SHA512: - raise Exception("Hash algorithm must be sha512 when security scheme is %s" % - SCHEME_RSA_SHA512) - elif signing_scheme == SCHEME_HS2019: - if self.hash_algorithm is None: - self.hash_algorithm = HASH_SHA256 - elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}: - raise Exception("Invalid hash algorithm") if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: raise Exception("The signature max validity must be a positive value") self.signature_max_validity = signature_max_validity @@ -256,6 +228,12 @@ class HttpSigningConfiguration(object): "Signing algorithm {0} is not compatible with private key".format( self.signing_algorithm)) + def _get_unix_time(self, ts): + """Converts and returns a datetime object to UNIX time, the number of seconds + elapsed since January 1, 1970 UTC. + """ + return (ts - datetime(1970, 1, 1)).total_seconds() + def _get_signed_header_info(self, resource_path, method, headers, body, query_params): """Build the HTTP headers (name, value) that need to be included in the HTTP signature scheme. @@ -284,16 +262,15 @@ class HttpSigningConfiguration(object): if query_params: request_target += "?" + urlencode(query_params) - # Get UNIX time, e.g. seconds since epoch, not including leap seconds. - now = time() - # Format date per RFC 7231 section-7.1.1.2. An example is: - # Date: Wed, 21 Oct 2015 07:28:00 GMT - cdate = formatdate(timeval=now, localtime=False, usegmt=True) + # Get current time and generate RFC 1123 (HTTP/1.1) date/time string. + now = datetime.now() + stamp = mktime(now.timetuple()) + cdate = formatdate(timeval=stamp, localtime=False, usegmt=True) # The '(created)' value MUST be a Unix timestamp integer value. # Subsecond precision is not supported. - created = int(now) + created = int(self._get_unix_time(now)) if self.signature_max_validity is not None: - expires = now + self.signature_max_validity.total_seconds() + expires = self._get_unix_time(now + self.signature_max_validity) signed_headers_list = [] request_headers_dict = {} @@ -338,14 +315,14 @@ class HttpSigningConfiguration(object): The prefix is a string that identifies the cryptographc hash. It is used to generate the 'Digest' header as specified in RFC 3230. """ - if self.hash_algorithm == HASH_SHA512: + if self.signing_scheme in {SCHEME_RSA_SHA512, SCHEME_HS2019}: digest = SHA512.new() prefix = 'SHA-512=' - elif self.hash_algorithm == HASH_SHA256: + elif self.signing_scheme == SCHEME_RSA_SHA256: digest = SHA256.new() prefix = 'SHA-256=' else: - raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm)) + raise Exception("Unsupported signing algorithm: {0}".format(self.signing_scheme)) digest.update(data) return digest, prefix @@ -369,10 +346,7 @@ class HttpSigningConfiguration(object): if sig_alg is None: sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: - # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. - # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, - encoding='der').sign(digest) + signature = DSS.new(self.private_key, sig_alg).sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) else: diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index d8cfc4ad11..9f5b49f821 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -45,7 +45,4 @@ configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' configuration.access_token = 'YOUR_ACCESS_TOKEN' {{/isOAuth}} {{/authMethods}} - -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" {{/hasAuthMethods}} diff --git a/travis.mustache b/travis.mustache index 195488737d..388de83128 100644 --- a/travis.mustache +++ b/travis.mustache @@ -10,13 +10,6 @@ python: - "3.7" - "3.8" # command to install dependencies -install: - - "pip install -r requirements.txt" - - "pip install -r test-requirements.txt" +install: "pip install -r requirements.txt" # command to run tests -{{#useNose}} script: nosetests -{{/useNose}} -{{^useNose}} -script: pytest --cov={{{packageName}}} -{{/useNose}} From 1d3d5233bcbb969e6d1f28659d18a530c6289c05 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 23 Apr 2020 22:59:31 -0700 Subject: [PATCH 100/185] [python-experimental] Minor doc update, code comments and exception handling (#5945) * add support for any type, i.e. when 'type' attribute is not specified in OAS schema * fix typos, add code comments * Handle case when 'type' attribute is not present in the OAS schema * fix python formatting rule * fix python formatting rule * remove 'object' as a type --- python-experimental/model_utils.mustache | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 8b60618c1d..58da408a19 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -74,7 +74,7 @@ COERCION_INDEX_BY_TYPE = { ModelComposed: 0, ModelNormal: 1, ModelSimple: 2, - none_type: 3, + none_type: 3, # The type of 'None'. list: 4, dict: 5, float: 6, @@ -83,7 +83,7 @@ COERCION_INDEX_BY_TYPE = { datetime: 9, date: 10, str: 11, - file_type: 12, + file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type. } # these are used to limit what type conversions we try to do @@ -352,11 +352,11 @@ def order_response_types(required_types): Args: required_types (list/tuple): collection of classes or instance of - list or dict with classs information inside it + list or dict with class information inside it. Returns: (list): coercion order sorted collection of classes or instance - of list or dict with classs information inside it + of list or dict with class information inside it. """ def index_getter(class_or_instance): @@ -373,7 +373,9 @@ def order_response_types(required_types): elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelSimple)): return COERCION_INDEX_BY_TYPE[ModelSimple] - return COERCION_INDEX_BY_TYPE[class_or_instance] + elif class_or_instance in COERCION_INDEX_BY_TYPE: + return COERCION_INDEX_BY_TYPE[class_or_instance] + raise ApiValueError("Unsupported type: %s" % class_or_instance) sorted_types = sorted( required_types, @@ -391,7 +393,7 @@ def remove_uncoercible(required_types_classes, current_item, from_server, these should be ordered by COERCION_INDEX_BY_TYPE from_server (bool): a boolean of whether the data is from the server if false, the data is from the client - current_item (any): the current item to be converted + current_item (any): the current item (input data) to be converted Keyword Args: must_convert (bool): if True the item to convert is of the wrong From c72785752643dbd47ad235817b11e72a491c2b42 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 23 Apr 2020 23:16:31 -0700 Subject: [PATCH 101/185] [Python experimental] Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info (#6033) * Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info * Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info --- configuration.mustache | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index 6581e603ad..7fdcd89427 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -271,6 +271,15 @@ class Configuration(object): result.debug = self.debug return result + def __setattr__(self, name, value): + object.__setattr__(self, name, value) +{{#hasHttpSignatureMethods}} + if name == "signing_info" and value is not None: + # Ensure the host paramater from signing info is the same as + # Configuration.host. + value.host = self.host +{{/hasHttpSignatureMethods}} + @classmethod def set_default(cls, default): """Set default instance of configuration. From deecddb4a25b612e54e47941dade989759719d72 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 24 Apr 2020 09:01:02 -0700 Subject: [PATCH 102/185] [CORE] Fixes composed schema discriminator map (#4906) * Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap * Requires that discriminators be required properties * Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples * Adds oneOf and anyOf invalidDiscriminator tests * Updates incorrect addOneOfInterfaceModel invocation * Runs ensure-up-to-date * Adds updates from Sebastien Rosset * Removes newlines * Uses df.isString * Fixes tests be correctly setting df.isString * Updates discriminatorExplicitMappingVerbose description per PR feedback * Adds description of how mappedModels is populated * Adds the suggestion exception raising when a MappedModel mappingName is null * Actually resolves merge conflicts * Switches two methods to package private because they are needed for testing * Allow nulls in MappedModel.getMappingName * Updates CLI flag name to legacyDiscriminatorBehavior, default=true Co-authored-by: William Cheng --- api_client.mustache | 9 ++++++--- model.mustache | 5 +++-- .../model_templates/classvars.mustache | 16 ++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index c69e7d5945..de25b7cf97 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -643,9 +643,12 @@ class ApiClient(object): :param klass: class literal. :return: model object. """ + has_discriminator = False + if (hasattr(klass, 'get_real_child_model') + and klass.discriminator_value_class_map): + has_discriminator = True - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): + if not klass.openapi_types and has_discriminator is False: return data kwargs = {} @@ -659,7 +662,7 @@ class ApiClient(object): instance = klass(**kwargs) - if hasattr(instance, 'get_real_child_model'): + if has_discriminator: klass_name = instance.get_real_child_model(data) if klass_name: instance = self.__deserialize(data, klass_name) diff --git a/model.mustache b/model.mustache index 70f6e7489a..112246604d 100644 --- a/model.mustache +++ b/model.mustache @@ -52,8 +52,9 @@ class {{classname}}(object): {{#discriminator}} discriminator_value_class_map = { - {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, - {{/-last}}{{/children}} +{{#children}} + '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} +{{/children}} } {{/discriminator}} diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 60fff484ef..8b49e58edb 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -115,15 +115,11 @@ @staticmethod def discriminator(): - return {{^discriminator}}None{{/discriminator}}{{#discriminator}}{ - '{{{discriminatorName}}}': { -{{#children}} - '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}, -{{/children}} -{{^children}} + {{^discriminator}}return None{{/discriminator}}{{#discriminator}}val = { {{#mappedModels}} - '{{mappingName}}': {{{modelName}}}, + '{{mappingName}}': {{{modelName}}}, {{/mappedModels}} -{{/children}} - }, - }{{/discriminator}} \ No newline at end of file + } + if not val: + return None + return {'{{{discriminatorName}}}': val}{{/discriminator}} \ No newline at end of file From 6f5e0b5ed9a739d56baec8ac5af25de8a0335fe7 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 24 Apr 2020 09:10:32 -0700 Subject: [PATCH 103/185] [Python experimental] Readme improvements (#6031) * Python experimental readme improvements * Python experimental readme improvements * execute scripts in bin directory --- common_README.mustache | 4 +- configuration.mustache | 56 +++++----- python-experimental/README_common.mustache | 4 +- python_doc_auth_partial.mustache | 116 ++++++++++++++++----- 4 files changed, 123 insertions(+), 57 deletions(-) diff --git a/common_README.mustache b/common_README.mustache index 991002aa17..37060d6d1f 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -1,13 +1,13 @@ ```python from __future__ import print_function +{{#apiInfo}}{{#apis}}{{^hasMore}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/hasMore}}{{/apis}}{{/apiInfo}} import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{> python_doc_auth_partial}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" + # Enter a context with an instance of the API client with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class diff --git a/configuration.mustache b/configuration.mustache index 7fdcd89427..dceab63e67 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -62,10 +62,12 @@ class Configuration(object): name: JSESSIONID # cookie name You can programmatically set the cookie: - conf = {{{packageName}}}.Configuration( - api_key={'cookieAuth': 'abc123'} - api_key_prefix={'cookieAuth': 'JSESSIONID'} - ) + +conf = {{{packageName}}}.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + The following cookie will be added to the HTTP request: Cookie: JSESSIONID abc123 {{/hasApiKeyMethods}} @@ -80,10 +82,12 @@ class Configuration(object): scheme: basic Configure API client with HTTP basic authentication: - conf = {{{packageName}}}.Configuration( - username='the-user', - password='the-password', - ) + +conf = {{{packageName}}}.Configuration( + username='the-user', + password='the-password', +) + {{/hasHttpBasicMethods}} {{#hasHttpSignatureMethods}} @@ -107,24 +111,24 @@ class Configuration(object): load balancers may add/modify/remove headers. Include the HTTP headers that you know are not going to be modified in transit. - conf = {{{packageName}}}.Configuration( - signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( - key_id = 'my-key-id', - private_key_path = 'rsa.pem', - signing_scheme = signing.SCHEME_HS2019, - signing_algorithm = signing.ALGORITHM_RSASSA_PSS, - signed_headers = [signing.HEADER_REQUEST_TARGET, - signing.HEADER_CREATED, - signing.HEADER_EXPIRES, - signing.HEADER_HOST, - signing.HEADER_DATE, - signing.HEADER_DIGEST, - 'Content-Type', - 'User-Agent' - ], - signature_max_validity = datetime.timedelta(minutes=5) - ) - ) +conf = {{{packageName}}}.Configuration( + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS, + signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET, + {{{packageName}}}.signing.HEADER_CREATED, + {{{packageName}}}.signing.HEADER_EXPIRES, + {{{packageName}}}.signing.HEADER_HOST, + {{{packageName}}}.signing.HEADER_DATE, + {{{packageName}}}.signing.HEADER_DIGEST, + 'Content-Type', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) {{/hasHttpSignatureMethods}} {{/hasAuthMethods}} """ diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index b474eb264a..7d9811fdfb 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -1,12 +1,12 @@ ```python from __future__ import print_function +{{#apiInfo}}{{#apis}}{{^hasMore}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/hasMore}}{{/apis}}{{/apiInfo}} import time import {{{packageName}}} from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{> python_doc_auth_partial}} -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" + # Enter a context with an instance of the API client with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index d8cfc4ad11..3086d770b1 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -1,51 +1,113 @@ +# Defining the host is optional and defaults to {{{basePath}}} +# See configuration.py for a list of all supported configuration parameters. +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}" +) + {{#hasAuthMethods}} +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. {{#authMethods}} -configuration = {{{packageName}}}.Configuration() {{#isBasic}} {{#isBasicBasic}} + # Configure HTTP basic authorization: {{{name}}} -configuration.username = 'YOUR_USERNAME' -configuration.password = 'YOUR_PASSWORD' +configuration = {{{packageName}}}.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) {{/isBasicBasic}} {{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} -configuration.access_token = 'YOUR_BEARER_TOKEN' +configuration = {{{packageName}}}.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) {{/isBasicBearer}} {{#isHttpSignature}} -# Configure HTTP signature authorization: {{{name}}} -# You can specify the signing key-id, private key path, signing scheme, signing algorithm, -# list of signed headers and signature max validity. -configuration.signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( - key_id = 'my-key-id', - private_key_path = 'rsa.pem', - signing_scheme = signing.SCHEME_HS2019, - signing_algorithm = signing.ALGORITHM_RSASSA_PSS, - signed_headers = [signing.HEADER_REQUEST_TARGET, - signing.HEADER_CREATED, - signing.HEADER_EXPIRES, - signing.HEADER_HOST, - signing.HEADER_DATE, - signing.HEADER_DIGEST, - 'Content-Type', - 'Content-Length', - 'User-Agent' - ], - signature_max_validity = datetime.timedelta(minutes=5) + +# Configure HTTP message signature: {{{name}}} +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See {{{packageName}}}.signing for a list of all supported parameters. +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}", + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = {{{packageName}}}.signing.SCHEME_RSA_SHA256, + signed_headers = [ + {{{packageName}}}.signing.HEADER_REQUEST_TARGET, + {{{packageName}}}.signing.HEADER_CREATED, + {{{packageName}}}.signing.HEADER_EXPIRES, + {{{packageName}}}.signing.HEADER_HOST, + {{{packageName}}}.signing.HEADER_DATE, + {{{packageName}}}.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) ) {{/isHttpSignature}} {{/isBasic}} {{#isApiKey}} + # Configure API key authorization: {{{name}}} -configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}", + api_key = { + '{{{keyParamName}}}': 'YOUR_API_KEY' + } +) # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer' {{/isApiKey}} {{#isOAuth}} + # Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}" +) configuration.access_token = 'YOUR_ACCESS_TOKEN' {{/isOAuth}} {{/authMethods}} - -# Defining host is optional and default to {{{basePath}}} -configuration.host = "{{{basePath}}}" {{/hasAuthMethods}} From fa5f7e53df7ecd50ccacea3e4aacc93dbee2e309 Mon Sep 17 00:00:00 2001 From: Justin Niessner Date: Sun, 26 Apr 2020 16:33:42 -0400 Subject: [PATCH 104/185] [Python] Fix Python UTF-8 Encoding Issue (#5679) * Try decoding but don't bail on error * Switch binary and ByteArray to bytes * Read content type and parse appropriately * Remove response parsing * Remove response parsing and just return the data * Update petshop examples w/ new generator code * Fix copy/paste error with naming * Update petstore examples * Move response decoding to inside _preload_content block * Update the clients again * Use a raw string for the regex pattern * Regenerate petstore clients * Add bytes to python primitives as it's supported in 2.7 and 3 * Add bytes to the exports from model_utils * Import bytes from model_utils * Add conditional typing for regex pattern to match variable type * Regenerate petstore clients * Use read() instead of text() for asyncio * Regenerate petstore clients * Remove unused six import * Regenerate petstore clients * Add newline to kick Circle to re-run * Remove whitespace from tox.ini * Update more examples after ensure_updated * Add sample updates that didn't run with the --batch flag * Remove extra bracket in regex to remove warning * Stop printing debug messages * Add bytes examples to python doc generators * Update generated FakeApi docs * Regenerate api_client.py * Remove print statements from generated clients * Update bytes example in FakeApi.md. Again. I swear. * Add yet another seemingly missing doc update * Catch the error, decode the body, and re-throw * Remove the updates now that the change is non-breaking * Regenerate client * Add bytes deserialization test * Update exception parsing * Add exception parsing for python-experimental * Regenerate client with minor changes * Revert test changes * Regenerate model_utils.py * Update confusing test name * Remove bytes from mapping and examples * Add back in the old binary/ByteArray to str mapping * Update docs and api_client template * Add experimental api_client changes * Regenerate samples again * Add Tornado handling to early return * Try fixing Tornado python returns * More documentation changes * Re-generate the client code * Remove bytes from test_format_test * Remove more leftover bytes usages * Switch bytes validation back to string * Fix format_test template and regenerate * Remove unused bytes var * Remove bytes import from models and regenerate * Remove bytes import from test_deserialization * Reduce nested ifs * Remove byte logic for now * Regenerate client after latest changes * Remove another bytes usage * Regenerate after removing dangling byte string usage * Reduce the scope of the try/catch in api_client * Regenerate after try/catch cleanup * Swap catch for except * Regenerate Python client after api_client change * Fix lint error on the generated api_client * Add binary format test back in w/ string * Add decoding to python-experimental and regenerate * Import re into python-experimental api_client * Ensure file upload json response is utf-8 encoded bytes --- api_client.mustache | 47 ++++++++++++++------ asyncio/rest.mustache | 2 +- python-experimental/api_client.mustache | 57 +++++++++++++++++-------- rest.mustache | 5 --- tornado/rest.mustache | 7 +-- 5 files changed, 76 insertions(+), 42 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index de25b7cf97..66d3577f3c 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -22,7 +22,7 @@ import tornado.gen from {{packageName}}.configuration import Configuration import {{modelPackage}} from {{packageName}} import rest -from {{packageName}}.exceptions import ApiValueError +from {{packageName}}.exceptions import ApiValueError, ApiException class ApiClient(object): @@ -186,22 +186,43 @@ class ApiClient(object): # use server/host defined in path or operation instead url = _host + resource_path - # perform request and return response - response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) + try: + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + e.body = e.body.decode('utf-8') if six.PY3 else e.body + raise e + + content_type = response_data.getheader('content-type') self.last_response = response_data return_data = response_data - if _preload_content: - # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None + + if not _preload_content: + {{^tornado}} + return return_data + {{/tornado}} + {{#tornado}} + raise tornado.gen.Return(return_data) + {{/tornado}} + + if six.PY3 and response_type not in ["file", "bytes"]: + match = None + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None {{^tornado}} if _return_http_data_only: diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index f2099c7531..44531fce5a 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -166,7 +166,7 @@ class RESTClientObject(object): r = await self.pool_manager.request(**args) if _preload_content: - data = await r.text() + data = await r.read() r = RESTResponse(r, data) # log response body diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 774dae89c6..5285a7b806 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -7,6 +7,7 @@ import atexit import mimetypes from multiprocessing.pool import ThreadPool import os +import re # python 2 and python 3 compatibility library import six @@ -17,7 +18,7 @@ import tornado.gen from {{packageName}} import rest from {{packageName}}.configuration import Configuration -from {{packageName}}.exceptions import ApiValueError +from {{packageName}}.exceptions import ApiValueError, ApiException from {{packageName}}.model_utils import ( ModelNormal, ModelSimple, @@ -176,26 +177,48 @@ class ApiClient(object): # use server/host defined in path or operation instead url = _host + resource_path - # perform request and return response - response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) + try: + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + e.body = e.body.decode('utf-8') if six.PY3 else e.body + raise e + + content_type = response_data.getheader('content-type') self.last_response = response_data return_data = response_data - if _preload_content: - # deserialize response data - if response_type: - return_data = self.deserialize( - response_data, - response_type, - _check_type - ) - else: - return_data = None + + if not _preload_content: + {{^tornado}} + return (return_data) + {{/tornado}} + {{#tornado}} + raise tornado.gen.Return(return_data) + {{/tornado}} + return return_data + + if six.PY3 and response_type not in ["file", "bytes"]: + match = None + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type: + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) + else: + return_data = None {{^tornado}} if _return_http_data_only: diff --git a/rest.mustache b/rest.mustache index 772efe91b3..fe7abfdfc0 100644 --- a/rest.mustache +++ b/rest.mustache @@ -209,11 +209,6 @@ class RESTClientObject(object): if _preload_content: r = RESTResponse(r) - # In the python 3, the response.data is bytes. - # we need to decode it to string. - if six.PY3: - r.data = r.data.decode('utf8') - # log response body logger.debug("response body: %s", r.data) diff --git a/tornado/rest.mustache b/tornado/rest.mustache index e7a760f370..2679760ea5 100644 --- a/tornado/rest.mustache +++ b/tornado/rest.mustache @@ -8,7 +8,6 @@ import logging import re # python 2 and python 3 compatibility library -import six from six.moves.urllib.parse import urlencode import tornado import tornado.gen @@ -28,11 +27,7 @@ class RESTResponse(io.IOBase): self.reason = resp.reason if resp.body: - # In Python 3, the response body is utf-8 encoded bytes. - if six.PY3: - self.data = resp.body.decode('utf-8') - else: - self.data = resp.body + self.data = resp.body else: self.data = None From e7ba20df13cedd7cbe3b2bae43aa1bb59c11a9b5 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 3 May 2020 11:44:04 -0700 Subject: [PATCH 105/185] Adds memoization and deserialization through 2 or more discriminators (#6124) * Adds cached_property decorator, adds feature to move through n discriminators * Adds v3 sample with 2 discriminators * Adds tests of Shape, Tringle, and Quadrilateral traveling through 2 discriminators * Adds test_deserialization.py:test_deserialize_shape * Simplifes XTriangle sample spec schemas * Simplifies Shape schema definition, updates go+python-experimental samples * Fixes python-experimental test_dog tests * Separates off python-experimental spec --- python-experimental/model.mustache | 3 + .../model_templates/classvars.mustache | 4 +- .../method_discriminator.mustache | 6 +- .../method_init_composed.mustache | 2 + .../method_init_normal.mustache | 1 + .../method_init_shared.mustache | 21 ++- .../method_set_attribute.mustache | 5 +- .../model_templates/model_composed.mustache | 2 +- .../model_templates/model_normal.mustache | 4 +- .../model_templates/model_simple.mustache | 4 +- python-experimental/model_utils.mustache | 161 ++++++++++++------ 11 files changed, 142 insertions(+), 71 deletions(-) diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index ef7da57282..9afb17b527 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -13,6 +13,9 @@ from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 8b49e58edb..fe54e34f5b 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -94,7 +94,7 @@ additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -113,7 +113,7 @@ {{/optionalVars}} } - @staticmethod + @cached_property def discriminator(): {{^discriminator}}return None{{/discriminator}}{{#discriminator}}val = { {{#mappedModels}} diff --git a/python-experimental/model_templates/method_discriminator.mustache b/python-experimental/model_templates/method_discriminator.mustache index c4baa722ff..de06fb461e 100644 --- a/python-experimental/model_templates/method_discriminator.mustache +++ b/python-experimental/model_templates/method_discriminator.mustache @@ -1,10 +1,10 @@ @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index e00bf129b2..a5d948f0dd 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -4,6 +4,7 @@ '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', @@ -16,6 +17,7 @@ '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { {{#requiredVars}} diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index d26506c56c..8433c49f2f 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -4,6 +4,7 @@ '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) {{> python-experimental/model_templates/method_init_shared }} diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 9dd5bc2b6f..1631d57eec 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,4 +1,5 @@ - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#requiredVars}} @@ -31,6 +32,21 @@ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) {{#optionalVars}} {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 {{/optionalVars}} @@ -40,4 +56,5 @@ self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item - self._configuration = _configuration \ No newline at end of file + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) \ No newline at end of file diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache index bcafb71368..f4a36e42f2 100644 --- a/python-experimental/model_templates/method_set_attribute.mustache +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -6,9 +6,8 @@ path_to_item.extend(self._path_to_item) path_to_item.append(name) - openapi_types = self.openapi_types() - if name in openapi_types: - required_types_mixed = openapi_types[name] + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: raise ApiKeyError( "{0} has no key '{1}'".format(type(self).__name__, name), diff --git a/python-experimental/model_templates/model_composed.mustache b/python-experimental/model_templates/model_composed.mustache index d53d89cef2..002b2a5789 100644 --- a/python-experimental/model_templates/model_composed.mustache +++ b/python-experimental/model_templates/model_composed.mustache @@ -26,7 +26,7 @@ class {{unescapedDescription}}(ModelComposed): {{> python-experimental/model_templates/method_init_composed }} - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache index 8bfe6ada48..f9d82ef2a8 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/python-experimental/model_templates/model_normal.mustache @@ -24,9 +24,7 @@ class {{unescapedDescription}}(ModelNormal): {{/optionalVars}} } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} {{> python-experimental/model_templates/method_init_normal}}{{#discriminator}} diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index 465918dfa5..95b8a81715 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -11,8 +11,6 @@ class {{unescapedDescription}}(ModelSimple): {{> python-experimental/model_templates/classvars }} - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None {{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 58da408a19..e6b1df6b0e 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -35,6 +35,24 @@ else: from builtins import int, str +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on fuction methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + try: + return vars(self)[self.result_key] + except KeyError: + result = self._fn() + setattr(self, self.result_key, result) + return result + + class OpenApiModel(object): """The base class for all OpenAPIModels""" @@ -42,6 +60,55 @@ class OpenApiModel(object): {{> python-experimental/model_templates/methods_shared }} + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # we don't have a discriminator + # or we have already visited this class before and are sure that we + # want to instantiate it this time + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_classes = [] + oneof_anyof_classes.extend(cls._composed_schemas.get('oneOf', ())) + oneof_anyof_classes.extend(cls._composed_schemas.get('anyOf', ())) + new_cls = cls.get_discriminator_class(kwargs) + if new_cls is None: + disc_prop_name_py = list(cls.discriminator.keys())[0] + disc_prop_name_js = cls.attribute_map[disc_prop_name_py] + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + disc_prop_name_js, kwargs.get(disc_prop_name_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (disc_prop_name_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are coming from the chosen new_cls use cls instead + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -473,10 +540,12 @@ def change_keys_js_to_python(input_dict, model_class): document). """ + if getattr(model_class, 'attribute_map', None) is None: + return input_dict output_dict = {} reversed_attr_map = {value: key for key, value in - six.iteritems(model_class.attribute_map)} - for javascript_key, value in six.iteritems(input_dict): + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: # if the key is unknown, it is in error or it is an @@ -553,21 +622,6 @@ def deserialize_primitive(data, klass, path_to_item): ) -def fix_model_input_data(model_data, model_class): - # this is only called on classes where the input data is a dict - fixed_model_data = change_keys_js_to_python( - model_data, - model_class - ) - if model_class._composed_schemas() is not None: - for allof_class in model_class._composed_schemas()['allOf']: - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - allof_class - ) - return fixed_model_data - - def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -596,23 +650,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _configuration=configuration, _from_server=from_server) - used_model_class = model_class - if model_class.discriminator() is not None: - used_model_class = model_class.get_discriminator_class( - from_server, model_data) - - if issubclass(used_model_class, ModelSimple): - instance = used_model_class(value=model_data, **kw_args) + if issubclass(model_class, ModelSimple): + instance = model_class(value=model_data, **kw_args) return instance if isinstance(model_data, list): - instance = used_model_class(*model_data, **kw_args) + instance = model_class(*model_data, **kw_args) if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - model_data, - used_model_class - ) - kw_args.update(fixed_model_data) - instance = used_model_class(**kw_args) + kw_args.update(model_data) + instance = model_class(**kw_args) return instance @@ -833,7 +878,7 @@ def model_to_dict(model_instance, serialize=True): result = {} model_instances = [model_instance] - if model_instance._composed_schemas() is not None: + if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): @@ -914,6 +959,17 @@ def get_py3_class_name(input_class): return input_class.__name__ +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(self, *args, **kwargs): + from_server = kwargs.get('_from_server', False) + if from_server: + kwargs = change_keys_js_to_python(kwargs, self.__class__) + return fn(self, *args, **kwargs) + return wrapped_init + + def get_allof_instances(self, model_args, constant_args): """ Args: @@ -927,18 +983,17 @@ def get_allof_instances(self, model_args, constant_args): composed_instances (list) """ composed_instances = [] - for allof_class in self._composed_schemas()['allOf']: - - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_args, allof_class) + for allof_class in self._composed_schemas['allOf']: + # no need to handle changing js keys to python because + # for composed schemas, allof parameters are included in the + # composed schema and were changed to python keys in __new__ # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(allof_class.openapi_types().keys()) + var_names = set(allof_class.openapi_types.keys()) for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] + if var_name in model_args: + kwargs[var_name] = model_args[var_name] # and use it to make the instance kwargs.update(constant_args) @@ -950,8 +1005,8 @@ def get_allof_instances(self, model_args, constant_args): "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( - allof_class.__class__.__name__, - allof_class.__class__.__name__, + allof_class.__name__, + allof_class.__name__, self.__class__.__name__, str(ex) ) @@ -979,13 +1034,13 @@ def get_oneof_instance(self, model_args, constant_args): Returns oneof_instance (instance/None) """ - if len(self._composed_schemas()['oneOf']) == 0: + if len(self._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in self._composed_schemas()['oneOf']: + for oneof_class in self._composed_schemas['oneOf']: # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) @@ -995,7 +1050,7 @@ def get_oneof_instance(self, model_args, constant_args): # additionalProperties attribute in the OAS document) are not added to # the dict. kwargs = {} - var_names = set(oneof_class.openapi_types().keys()) + var_names = set(oneof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1039,16 +1094,16 @@ def get_anyof_instances(self, model_args, constant_args): anyof_instances (list) """ anyof_instances = [] - if len(self._composed_schemas()['anyOf']) == 0: + if len(self._composed_schemas['anyOf']) == 0: return anyof_instances - for anyof_class in self._composed_schemas()['anyOf']: + for anyof_class in self._composed_schemas['anyOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) # extract a dict of only required keys from these_model_vars kwargs = {} - var_names = set(anyof_class.openapi_types().keys()) + var_names = set(anyof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1089,7 +1144,7 @@ def get_var_name_to_model_instances(self, composed_instances): all_instances = [self] all_instances.extend(composed_instances) for instance in all_instances: - for var_name in instance.openapi_types(): + for var_name in instance.openapi_types: if var_name not in var_name_to_model_instances: var_name_to_model_instances[var_name] = [instance] else: @@ -1105,7 +1160,7 @@ def get_unused_args(self, composed_instances, model_args): if var_name_py in unused_args: del unused_args[var_name_py] for instance in composed_instances: - if instance.__class__ in self._composed_schemas()['allOf']: + if instance.__class__ in self._composed_schemas['allOf']: for var_name_py in instance.attribute_map: if var_name_py in unused_args: del unused_args[var_name_py] @@ -1125,9 +1180,7 @@ def validate_get_composed_info(constant_args, model_args, self): Openapi schemas are python classes. Exceptions are raised if: - - no oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data + - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data @@ -1136,7 +1189,7 @@ def validate_get_composed_info(constant_args, model_args, self): model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating - This class contains self._composed_schemas() + This class contains self._composed_schemas Returns: composed_info (list): length three From 98407305933c0ed240c68d33ff818a5f118b0996 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Sun, 10 May 2020 19:02:41 -0700 Subject: [PATCH 106/185] [python-experimental] Raise builtin AttributeError instead of custom ApiKeyError (#6229) * Use AttributeError instead of ApiKeyError because that's what the hasattr builtin function uses * Use AttributeError instead of ApiKeyError because that's what the hasattr builtin function uses * fix unit tests * create ApiAttributeError exception * fix formatting * run samples scripts --- __init__package.mustache | 1 + exceptions.mustache | 19 +++++++++++++++++++ .../method_set_attribute.mustache | 5 +++-- .../methods_setattr_getattr_composed.mustache | 10 ++++++---- .../methods_setattr_getattr_normal.mustache | 5 +++-- python-experimental/model_utils.mustache | 1 + 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/__init__package.mustache b/__init__package.mustache index 72376acdc3..aee16448ad 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -18,6 +18,7 @@ from {{packageName}}.exceptions import OpenApiException from {{packageName}}.exceptions import ApiTypeError from {{packageName}}.exceptions import ApiValueError from {{packageName}}.exceptions import ApiKeyError +from {{packageName}}.exceptions import ApiAttributeError from {{packageName}}.exceptions import ApiException # import models into sdk package {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} diff --git a/exceptions.mustache b/exceptions.mustache index dd012f34a0..b187ee9d47 100644 --- a/exceptions.mustache +++ b/exceptions.mustache @@ -56,6 +56,25 @@ class ApiValueError(OpenApiException, ValueError): super(ApiValueError, self).__init__(full_msg) +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + class ApiKeyError(OpenApiException, KeyError): def __init__(self, msg, path_to_item=None): """ diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache index f4a36e42f2..15067fff80 100644 --- a/python-experimental/model_templates/method_set_attribute.mustache +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -9,8 +9,9 @@ if name in self.openapi_types: required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), path_to_item ) elif self.additional_properties_type is not None: diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index 9420fe1582..dd118d30f9 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -24,8 +24,9 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), path_to_item ) @@ -54,8 +55,9 @@ values.append(v) len_values = len(values) if len_values == 0: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), path_to_item ) elif len_values == 1: diff --git a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache index f92663ab20..9fc6344908 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache @@ -18,7 +18,8 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), [name] ) \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index e6b1df6b0e..0be7362f6f 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -14,6 +14,7 @@ import six from {{packageName}}.exceptions import ( ApiKeyError, + ApiAttributeError, ApiTypeError, ApiValueError, ) From f300c07e53edac12409ebd6c7267626a324b1113 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Mon, 11 May 2020 03:18:34 -0700 Subject: [PATCH 107/185] [python-experimental] Improve error message for regex matching, add unit tests. (#6226) * Improve error message * Add unit tests for regular expressions --- python-experimental/model_utils.mustache | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 0be7362f6f..6aad98176f 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -405,14 +405,15 @@ def check_validations(validations, input_variable_path, input_values): if ('regex' in current_validations and not re.search(current_validations['regex']['pattern'], input_values, flags=flags)): - raise ApiValueError( - r"Invalid value for `%s`, must be a follow pattern or equal to " - r"`%s` with flags=`%s`" % ( - input_variable_path[0], - current_validations['regex']['pattern'], - flags - ) - ) + err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'] + ) + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + err_msg = r"%s with flags=`%s`" % (err_msg, flags) + raise ApiValueError(err_msg) def order_response_types(required_types): From 7accc67412e54a64de91087492a0aef9d2762604 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Mon, 11 May 2020 16:57:49 -0700 Subject: [PATCH 108/185] [codegen][Python-experimental] Discriminator NPE fix, handle 'null' type, #4906 enhancements (#5809) * Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap * Requires that discriminators be required properties * Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples * Adds oneOf and anyOf invalidDiscriminator tests * Runs ensure up to date * Updates incorrect addOneOfInterfaceModel invocation * Runs ensure-up-to-date * Fix NPE when at least one extension is defined but not x-discriminator-value * Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap * Requires that discriminators be required properties * Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples * Adds oneOf and anyOf invalidDiscriminator tests * Updates incorrect addOneOfInterfaceModel invocation * Runs ensure-up-to-date * Adds updates from Sebastien Rosset * Removes newlines * Add documentation and new getValidDiscriminatorMappings function * Add documentation and new getValidDiscriminatorMappings function * Add documentation and new getValidDiscriminatorMappings function * Add documentation and new getValidDiscriminatorMappings function * Add documentation and new getValidDiscriminatorMappings function * Add documentation and new getValidDiscriminatorMappings function * throw exception if discriminator mappingName argument is null * handle scenario when composed schema has 'null' type * remove extraneous characters in comments * Uses df.isString * Traverse discriminators to resolve discriminator mapping * Fixes tests be correctly setting df.isString * Remove unused method * Updates discriminatorExplicitMappingVerbose description per PR feedback * Adds description of how mappedModels is populated * Adds the suggestion exception raising when a MappedModel mappingName is null * Actually resolves merge conflicts * Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap * Requires that discriminators be required properties * Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples * Adds oneOf and anyOf invalidDiscriminator tests * Updates incorrect addOneOfInterfaceModel invocation * Runs ensure-up-to-date * Adds updates from Sebastien Rosset * Removes newlines * Uses df.isString * Fixes tests be correctly setting df.isString * Updates discriminatorExplicitMappingVerbose description per PR feedback * Adds description of how mappedModels is populated * Adds the suggestion exception raising when a MappedModel mappingName is null * Actually resolves merge conflicts * Switches two methods to package private because they are needed for testing * Allow nulls in MappedModel.getMappingName * Remove exception when mappingName is null value * Remove exception when mappingName is null value * resolve merge conflicts * resolve merge conflicts * Execute scripts in the bin directory * Fix CI issues and address PR review comments: better documentation and fix white space issues. * Fix CI issues and address PR review comments: better documentation and fix white space issues. * run sample scripts * resolve merge conflicts * fix end-of-line issue * resolve merge conflicts * resolve merge issues * Handle case when discriminator is not specified in input data * minor changes and add code comments * Refactor get_discriminator code * Add unit test with missing discriminator property * improve get_discriminator function * Run sample scripts * add unit tests for recursive get_discriminator_class * fix unit test issues * fix formatting issues * fix formatting issues * fix formatting issues * fix index out of range exception * fix formatting issues * fix formatting issues * fix formatting issues. Finally figured out how to check formatting in local workspace Co-authored-by: Justin Black Co-authored-by: William Cheng --- .../method_discriminator.mustache | 12 -- .../model_templates/model_composed.mustache | 4 +- .../model_templates/model_normal.mustache | 4 +- python-experimental/model_utils.mustache | 145 ++++++++++++++++-- 4 files changed, 134 insertions(+), 31 deletions(-) delete mode 100644 python-experimental/model_templates/method_discriminator.mustache diff --git a/python-experimental/model_templates/method_discriminator.mustache b/python-experimental/model_templates/method_discriminator.mustache deleted file mode 100644 index de06fb461e..0000000000 --- a/python-experimental/model_templates/method_discriminator.mustache +++ /dev/null @@ -1,12 +0,0 @@ - @classmethod - def get_discriminator_class(cls, data): - """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator - discr_propertyname_py = list(discriminator.keys())[0] - discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if discr_propertyname_js in data: - class_name = data[discr_propertyname_js] - else: - class_name = data[discr_propertyname_py] - class_name_to_discr_class = discriminator[discr_propertyname_py] - return class_name_to_discr_class.get(class_name) \ No newline at end of file diff --git a/python-experimental/model_templates/model_composed.mustache b/python-experimental/model_templates/model_composed.mustache index 002b2a5789..7e9e86cbfc 100644 --- a/python-experimental/model_templates/model_composed.mustache +++ b/python-experimental/model_templates/model_composed.mustache @@ -51,6 +51,4 @@ class {{unescapedDescription}}(ModelComposed): {{{.}}}, {{/oneOf}} ], - }{{#discriminator}} - -{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file + } \ No newline at end of file diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache index f9d82ef2a8..21254c55d1 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/python-experimental/model_templates/model_normal.mustache @@ -26,6 +26,4 @@ class {{unescapedDescription}}(ModelNormal): _composed_schemas = {} -{{> python-experimental/model_templates/method_init_normal}}{{#discriminator}} - -{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file +{{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 6aad98176f..9111fcb830 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -66,31 +66,78 @@ class OpenApiModel(object): # pick a new schema/class to instantiate because a discriminator # propertyName value was passed in + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) + if (oneof_anyof_classes and none_type in oneof_anyof_classes and + len(args) == 1 and args[0] is None): + # The input data is the 'null' value AND one of the oneOf/anyOf children + # is the 'null' type (which is introduced in OAS schema >= 3.1). + return None + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) if ( cls.discriminator is None or cls in visited_composed_classes ): - # we don't have a discriminator - # or we have already visited this class before and are sure that we - # want to instantiate it this time + # This openapi schema (cls) does not have a discriminator + # Or we have already visited this class before and are sure that we + # want to instantiate it this time. + # + # If we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here return super(OpenApiModel, cls).__new__(cls) - oneof_anyof_classes = [] - oneof_anyof_classes.extend(cls._composed_schemas.get('oneOf', ())) - oneof_anyof_classes.extend(cls._composed_schemas.get('anyOf', ())) - new_cls = cls.get_discriminator_class(kwargs) + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get('_path_to_item', ()) + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) if new_cls is None: - disc_prop_name_py = list(cls.discriminator.keys())[0] - disc_prop_name_js = cls.attribute_map[disc_prop_name_py] path_to_item = kwargs.get('_path_to_item', ()) disc_prop_value = kwargs.get( - disc_prop_name_js, kwargs.get(disc_prop_name_py)) + discr_propertyname_js, kwargs.get(discr_propertyname_py)) raise ApiValueError( "Cannot deserialize input data due to invalid discriminator " "value. The OpenAPI document has no mapping for discriminator " "property '%s'='%s' at path: %s" % - (disc_prop_name_js, disc_prop_value, path_to_item) + (discr_propertyname_js, disc_prop_value, path_to_item) ) if new_cls in visited_composed_classes: @@ -101,7 +148,7 @@ class OpenApiModel(object): kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) if cls._composed_schemas.get('allOf') and oneof_anyof_child: - # validate that we can make self because when we make the + # Validate that we can make self because when we make the # new_cls it will not include the allOf validations in self self_inst = super(OpenApiModel, cls).__new__(cls) self_inst.__init__(*args, **kwargs) @@ -131,7 +178,29 @@ class ModelNormal(OpenApiModel): class ModelComposed(OpenApiModel): """the parent class of models whose type == object in their - swagger/openapi and have oneOf/allOf/anyOf""" + swagger/openapi and have oneOf/allOf/anyOf + + When one sets a property we use var_name_to_model_instances to store the value in + the correct class instances + run any type checking + validation code. + When one gets a property we use var_name_to_model_instances to get the value + from the correct class instances. + This allows multiple composed schemas to contain the same property with additive + constraints on the value. + + _composed_schemas (dict) stores the anyOf/allOf/oneOf classes + key (str): allOf/oneOf/anyOf + value (list): the classes in the XOf definition. + Note: none_type can be included when the openapi document version >= 3.1.0 + _composed_instances (list): stores a list of instances of the composed schemas + defined in _composed_schemas. When properties are accessed in the self instance, + they are returned from the self._data_store or the data stores in the instances + in self._composed_schemas + _var_name_to_model_instances (dict): maps between a variable name on self and + the composed instances (self included) which contain that data + key (str): property name + value (list): list of class instances, self or instances in _composed_instances + which contain the value that the key is referring to. + """ {{> python-experimental/model_templates/methods_setattr_getattr_composed }} @@ -624,6 +693,56 @@ def deserialize_primitive(data, klass, path_to_item): ) +def get_discriminator_class(model_class, + discr_name, + discr_value, cls_visited): + """Returns the child class specified by the discriminator. + + Args: + model_class (OpenApiModel): the model class. + discr_name (string): the name of the discriminator property. + discr_value (any): the discriminator value. + cls_visited (list): list of model classes that have been visited. + Used to determine the discriminator class without + visiting circular references indefinitely. + + Returns: + used_model_class (class/None): the chosen child class that will be used + to deserialize the data, for example dog.Dog. + If a class is not found, None is returned. + """ + + if model_class in cls_visited: + # The class has already been visited and no suitable class was found. + return None + cls_visited.append(model_class) + used_model_class = None + if discr_name in model_class.discriminator: + class_name_to_discr_class = model_class.discriminator[discr_name] + used_model_class = class_name_to_discr_class.get(discr_value) + if used_model_class is None: + # We didn't find a discriminated class in class_name_to_discr_class. + # The discriminator mapping may exist in a descendant (anyOf, oneOf) + # or ancestor (allOf). + # Ancestor example: in the "Dog -> Mammal -> Chordate -> Animal" + # hierarchy, the discriminator mappings may be defined at any level + # in the hieararchy. + # Descendant example: a schema is oneOf[Plant, Mammal], and each + # oneOf child may itself be an allOf with some arbitrary hierarchy, + # and a graph traversal is required to find the discriminator. + composed_children = model_class._composed_schemas.get('oneOf', ()) + \ + model_class._composed_schemas.get('anyOf', ()) + \ + model_class._composed_schemas.get('allOf', ()) + for cls in composed_children: + # Check if the schema has inherited discriminators. + if cls.discriminator is not None: + used_model_class = get_discriminator_class( + cls, discr_name, discr_value, cls_visited) + if used_model_class is not None: + return used_model_class + return used_model_class + + def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. From 89b5c2f58ca57a41d6c8178e022c46987270a270 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Tue, 12 May 2020 23:09:25 -0700 Subject: [PATCH 109/185] [Python-experimental] JSON schema 'null' type should be modeled as 'none_type' (#6121) * Handle null type * Handle null type * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * improve documentation * Handle 'null' type * Handle 'null' type. Add unit tests * Add NullType for go * Add NullType for go * fix modeling of AnyType for go-experimental * execute scripts in bin directory * Add review comments * Add 'null' type in oneOf * Improve OAS YAML file for golang openapi3 samples * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * Handle AnyType and NullType * handle anytype for go-experimental * Log warning instead of error * anyOf/oneOf * Change x-golang-is-container extension to x-golang-has-wrapper * Add code comments * Handle Object and any type * Handle Object and any type * Handle object and any type * add code comments * handle additional properties * handle additional properties * handle additional properties * handle anytype and objecttype for go-exerimental * Move golang changes to a separate branch * Move golang changes to a separate branch * Better names for the OAS document test properties * Move golang changes to a separate branch * Run samples scripts * Run samples scripts * fix unit test issues * Handle none type * Fix index out of range exception * fix formatting issues * fix formatting issues * fix formatting issues. Finally figured out how to check formatting in local workspace * fix formatting issues * run samples scripts --- python-experimental/model_utils.mustache | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 9111fcb830..fcbb59e791 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -1153,7 +1153,7 @@ def get_oneof_instance(self, model_args, constant_args): and path to item. Returns - oneof_instance (instance/None) + oneof_instance (instance) """ if len(self._composed_schemas['oneOf']) == 0: return None @@ -1162,6 +1162,13 @@ def get_oneof_instance(self, model_args, constant_args): # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. for oneof_class in self._composed_schemas['oneOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if oneof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) @@ -1207,9 +1214,11 @@ def get_anyof_instances(self, model_args, constant_args): Args: self: the class we are handling model_args (dict): var_name to var_value - used to make instances + The input data, e.g. the payload that must match at least one + anyOf child schema in the OpenAPI document. constant_args (dict): var_name to var_value - used to make instances + args that every model requires, including configuration, server + and path to item. Returns anyof_instances (list) @@ -1219,6 +1228,13 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances for anyof_class in self._composed_schemas['anyOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if anyof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) From ffce474665c03cf625ec9982c09024ec16611d9f Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Wed, 13 May 2020 09:11:43 -0700 Subject: [PATCH 110/185] [python-experimental] Support schema property which has $ref to 'oneOf' schema (#6262) * Add reference to oneOf schema * Add model showing unit test failure with ref to oneOf schema * Updates get_discriminator_class to return visited_composed_classes * Fixes broken test, adds is_valid_type * move unit test to test_drawing.py file * Add more unit tests * invoke git pull from spacether fork * invoke git pull from spacether fork * Improve unit tests Co-authored-by: Justin Black --- python-experimental/model_utils.mustache | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index fcbb59e791..3c99e7fb99 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -872,6 +872,31 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, return input_value +def is_valid_type(input_class_simple, valid_classes): + """ + Args: + input_class_simple (class): the class of the input_value that we are + checking + valid_classes (tuple): the valid classes that the current item + should be + Returns: + bool + """ + valid_type = input_class_simple in valid_classes + if not valid_type and issubclass(input_class_simple, OpenApiModel): + for valid_class in valid_classes: + if not valid_class.discriminator: + continue + discr_propertyname_py = list(valid_class.discriminator.keys())[0] + discriminator_classes = ( + valid_class.discriminator[discr_propertyname_py].values() + ) + valid_type = is_valid_type(input_class_simple, discriminator_classes) + if valid_type: + return True + return valid_type + + def validate_and_convert_types(input_value, required_types_mixed, path_to_item, from_server, _check_type, configuration=None): """Raises a TypeError is there is a problem, otherwise returns value @@ -904,7 +929,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, valid_classes, child_req_types_by_current_type = results input_class_simple = get_simple_class(input_value) - valid_type = input_class_simple in set(valid_classes) + valid_type = is_valid_type(input_class_simple, valid_classes) if not valid_type: if configuration: # if input_value is not valid_type try to convert it From 804fd584b87f9e95428738817faee2327b164f88 Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Sun, 17 May 2020 09:06:12 -0700 Subject: [PATCH 111/185] [python-experimental] Support schema property which has $ref to 'oneOf' schema and child schema is null type (#6275) * Handle null type * Handle null type * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * improve documentation * Handle 'null' type * Handle 'null' type. Add unit tests * Add NullType for go * Add NullType for go * fix modeling of AnyType for go-experimental * execute scripts in bin directory * Add review comments * Add 'null' type in oneOf * Improve OAS YAML file for golang openapi3 samples * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * Handle AnyType and NullType * handle anytype for go-experimental * Log warning instead of error * anyOf/oneOf * Change x-golang-is-container extension to x-golang-has-wrapper * Add code comments * Handle Object and any type * Handle Object and any type * Handle object and any type * add code comments * handle additional properties * handle additional properties * handle additional properties * handle anytype and objecttype for go-exerimental * Move golang changes to a separate branch * Move golang changes to a separate branch * Better names for the OAS document test properties * Move golang changes to a separate branch * Run samples scripts * Run samples scripts * fix unit test issues * Handle none type * Fix index out of range exception * fix formatting issues * fix formatting issues * fix formatting issues. Finally figured out how to check formatting in local workspace * fix formatting issues * Add reference to oneOf schema * Add model showing unit test failure with ref to oneOf schema * Updates get_discriminator_class to return visited_composed_classes * Fixes broken test, adds is_valid_type * run samples scripts * move unit test to test_drawing.py file * Add more unit tests * invoke git pull from spacether fork * invoke git pull from spacether fork * Improve unit tests * Add is_nullable_type util function * Add unit test for null value * Add 'ShapeOrNull' type to handle the oneOf/anyOf scenario when the child schema is the null type * Support schema property which has to 'oneOf' schema and child schema is null type * Support schema property which has to 'oneOf' schema and child schema is null type * Support schema property which has to 'oneOf' schema and child schema is null type * Mustache template should use invokerPackage tag to generate import * handle null type in oneOf/anyOf * handle null type in oneOf/anyOf * Add more unit test for nullable shape * resolve merge conflicts * resolve merge conflicts * handle null type in oneOf/anyOf Co-authored-by: Justin Black --- python-experimental/model_utils.mustache | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 3c99e7fb99..ce0191f3ea 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -872,6 +872,32 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, return input_value +def is_type_nullable(input_type): + """ + Returns true if None is an allowed value for the specified input_type. + + A type is nullable if at least one of the following conditions is true: + 1. The OAS 'nullable' attribute has been specified, + 1. The type is the 'null' type, + 1. The type is a anyOf/oneOf composed schema, and a child schema is + the 'null' type. + Args: + input_type (type): the class of the input_value that we are + checking + Returns: + bool + """ + if input_type is none_type: + return True + if issubclass(input_type, ModelComposed): + # If oneOf/anyOf, check if the 'null' type is one of the allowed types. + for t in input_type._composed_schemas.get('oneOf', ()): + if is_type_nullable(t): return True + for t in input_type._composed_schemas.get('anyOf', ()): + if is_type_nullable(t): return True + return False + + def is_valid_type(input_class_simple, valid_classes): """ Args: @@ -883,9 +909,14 @@ def is_valid_type(input_class_simple, valid_classes): bool """ valid_type = input_class_simple in valid_classes - if not valid_type and issubclass(input_class_simple, OpenApiModel): + if not valid_type and ( + issubclass(input_class_simple, OpenApiModel) or + input_class_simple is none_type): for valid_class in valid_classes: - if not valid_class.discriminator: + if input_class_simple is none_type and is_type_nullable(valid_class): + # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. + return True + if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): continue discr_propertyname_py = list(valid_class.discriminator.keys())[0] discriminator_classes = ( From 0b4f3a43a64d20b6cfb3a454263183664f79341d Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Sun, 17 May 2020 09:11:01 -0700 Subject: [PATCH 112/185] [codegen][python-experimental] Add configuration knob to disable JSON schema validation (#6227) * Add knob to disable JSON schema structural validation * Add knob to disable JSON schema structural validation * Fix formatting issues * execute sample scripts * execute sample scripts * fix multipleOf validation issue * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation * Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation. Fix for python 2 * address review comments --- configuration.mustache | 29 ++++++++ python-experimental/api.mustache | 3 +- .../model_templates/classvars.mustache | 6 ++ .../method_set_attribute.mustache | 3 +- python-experimental/model_utils.mustache | 67 +++++++++++++++---- 5 files changed, 93 insertions(+), 15 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index dceab63e67..d1705eed25 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -14,8 +14,15 @@ import urllib3 import six from six.moves import http_client as httplib +from {{packageName}}.exceptions import ApiValueError +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + class Configuration(object): """NOTE: This class is auto generated by OpenAPI Generator @@ -43,6 +50,19 @@ class Configuration(object): then all undeclared properties received by the server are injected into the additional properties map. In that case, there are undeclared properties, and nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. {{#hasHttpSignatureMethods}} :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration @@ -139,6 +159,7 @@ conf = {{{packageName}}}.Configuration( api_key=None, api_key_prefix=None, username=None, password=None, discard_unknown_keys=False, + disabled_client_side_validations="", {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} @@ -172,6 +193,7 @@ conf = {{{packageName}}}.Configuration( """Password for HTTP basic authentication """ self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations {{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host @@ -277,6 +299,13 @@ conf = {{{packageName}}}.Configuration( def __setattr__(self, name, value): object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s {{#hasHttpSignatureMethods}} if name == "signing_info" and value is not None: # Ensure the host paramater from signing info is the same as diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 4cf1d423e8..44fc3a8997 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -376,7 +376,8 @@ class Endpoint(object): check_validations( self.validations, (param,), - kwargs[param] + kwargs[param], + configuration=self.api_client.configuration ) if kwargs['_check_input_type'] is False: diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index fe54e34f5b..471c16c10a 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -57,6 +57,9 @@ {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} }, {{/pattern}} +{{#multipleOf}} + 'multiple_of': {{multipleOf}}, +{{/multipleOf}} }, {{/hasValidation}} {{/requiredVars}} @@ -87,6 +90,9 @@ {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} }, {{/pattern}} +{{#multipleOf}} + 'multiple_of': {{multipleOf}}, +{{/multipleOf}} }, {{/hasValidation}} {{/optionalVars}} diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache index 15067fff80..fddbc7c2ea 100644 --- a/python-experimental/model_templates/method_set_attribute.mustache +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -45,6 +45,7 @@ check_validations( self.validations, (name,), - value + value, + self._configuration ) self.__dict__['_data_store'][name] = value \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index ce0191f3ea..1c163a915a 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -369,17 +369,50 @@ def check_allowed_values(allowed_values, input_variable_path, input_values): ) -def check_validations(validations, input_variable_path, input_values): +def is_json_validation_enabled(schema_keyword, configuration=None): + """Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + """ + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + +def check_validations( + validations, input_variable_path, input_values, + configuration=None): """Raises an exception if the input_values are invalid Args: - validations (dict): the validation dictionary - input_variable_path (tuple): the path to the input variable + validations (dict): the validation dictionary. + input_variable_path (tuple): the path to the input variable. input_values (list/str/int/float/date/datetime): the values that we - are checking + are checking. + configuration (Configuration): the configuration class. """ + current_validations = validations[input_variable_path] - if ('max_length' in current_validations and + if (is_json_validation_enabled('multipleOf', configuration) and + 'multiple_of' in current_validations and + isinstance(input_values, (int, float)) and + not (float(input_values) / current_validations['multiple_of']).is_integer()): + # Note 'multipleOf' will be as good as the floating point arithmetic. + raise ApiValueError( + "Invalid value for `%s`, value must be a multiple of " + "`%s`" % ( + input_variable_path[0], + current_validations['multiple_of'] + ) + ) + + if (is_json_validation_enabled('maxLength', configuration) and + 'max_length' in current_validations and len(input_values) > current_validations['max_length']): raise ApiValueError( "Invalid value for `%s`, length must be less than or equal to " @@ -389,7 +422,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('min_length' in current_validations and + if (is_json_validation_enabled('minLength', configuration) and + 'min_length' in current_validations and len(input_values) < current_validations['min_length']): raise ApiValueError( "Invalid value for `%s`, length must be greater than or equal to " @@ -399,7 +433,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('max_items' in current_validations and + if (is_json_validation_enabled('maxItems', configuration) and + 'max_items' in current_validations and len(input_values) > current_validations['max_items']): raise ApiValueError( "Invalid value for `%s`, number of items must be less than or " @@ -409,7 +444,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('min_items' in current_validations and + if (is_json_validation_enabled('minItems', configuration) and + 'min_items' in current_validations and len(input_values) < current_validations['min_items']): raise ValueError( "Invalid value for `%s`, number of items must be greater than or " @@ -432,7 +468,8 @@ def check_validations(validations, input_variable_path, input_values): max_val = input_values min_val = input_values - if ('exclusive_maximum' in current_validations and + if (is_json_validation_enabled('exclusiveMaximum', configuration) and + 'exclusive_maximum' in current_validations and max_val >= current_validations['exclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than `%s`" % ( @@ -441,7 +478,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('inclusive_maximum' in current_validations and + if (is_json_validation_enabled('maximum', configuration) and + 'inclusive_maximum' in current_validations and max_val > current_validations['inclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than or equal to " @@ -451,7 +489,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('exclusive_minimum' in current_validations and + if (is_json_validation_enabled('exclusiveMinimum', configuration) and + 'exclusive_minimum' in current_validations and min_val <= current_validations['exclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than `%s`" % @@ -461,7 +500,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) - if ('inclusive_minimum' in current_validations and + if (is_json_validation_enabled('minimum', configuration) and + 'inclusive_minimum' in current_validations and min_val < current_validations['inclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than or equal " @@ -471,7 +511,8 @@ def check_validations(validations, input_variable_path, input_values): ) ) flags = current_validations.get('regex', {}).get('flags', 0) - if ('regex' in current_validations and + if (is_json_validation_enabled('pattern', configuration) and + 'regex' in current_validations and not re.search(current_validations['regex']['pattern'], input_values, flags=flags)): err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( From c9608838a5c9b085f0d78f95d5a12ea1df0d945f Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 21 May 2020 18:59:31 -0700 Subject: [PATCH 113/185] [Python-experimental] Should accept float value serialized without decimal point (#6386) * Mustache template should use invokerPackage tag to generate import * A float may be serialized as an integer, e.g. '3' is a valid serialized float * A float may be serialized as an integer, e.g. '3' is a valid serialized float * add unit tests --- python-experimental/model_utils.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 1c163a915a..7c566933a5 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -229,6 +229,7 @@ COERCION_INDEX_BY_TYPE = { UPCONVERSION_TYPE_PAIRS = ( (str, datetime), (str, date), + (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. (list, ModelComposed), (dict, ModelComposed), (list, ModelNormal), From 95d0e6f9ab7f0f727486cefd9d3b0bde6046330f Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 22 May 2020 09:44:15 -0700 Subject: [PATCH 114/185] [python-experimental] Add support for pep 3134, attach cause of exception (#6388) * Mustache template should use invokerPackage tag to generate import * Add exception cause * using six module for exception chaining in Python 3.x --- python-experimental/model_utils.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 7c566933a5..c1c3c934aa 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -725,14 +725,14 @@ def deserialize_primitive(data, klass, path_to_item): # '7' -> 7.0 -> '7.0' != '7' raise ValueError('This is not a float') return converted_value - except (OverflowError, ValueError): + except (OverflowError, ValueError) as ex: # parse can raise OverflowError - raise ApiValueError( + six.raise_from(ApiValueError( "{0}Failed to parse {1} as {2}".format( additional_message, repr(data), get_py3_class_name(klass) ), path_to_item=path_to_item - ) + ), ex) def get_discriminator_class(model_class, @@ -1220,7 +1220,7 @@ def get_allof_instances(self, model_args, constant_args): allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: - raise ApiValueError( + six.raise_from(ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( @@ -1229,7 +1229,7 @@ def get_allof_instances(self, model_args, constant_args): self.__class__.__name__, str(ex) ) - ) + ), ex) return composed_instances From 18c73295920f08c0fedf27e9be17d1b2db1ef50b Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Fri, 22 May 2020 19:09:12 -0700 Subject: [PATCH 115/185] [Python-experimental] Rename from_server variable to json_variable_naming (#6390) * Mustache template should use invokerPackage tag to generate import * Add unit test showing how to construct objects from a JSON dict * rename from_server to json_variable_naming * rename from_server to json_variable_naming * fix code so it can execute in python 2.x * rename variable * fix typo * fix typo * fix deprecation warning * fix deprecation warning * fix deprecation warning --- .../method_init_composed.mustache | 4 +- .../method_init_normal.mustache | 2 +- .../method_init_shared.mustache | 10 ++-- .../method_set_attribute.mustache | 2 +- python-experimental/model_utils.mustache | 54 +++++++++++-------- 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index a5d948f0dd..67750cb17a 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -1,7 +1,7 @@ required_properties = set([ '_data_store', '_check_type', - '_from_server', + '_spec_property_naming', '_path_to_item', '_configuration', '_visited_composed_classes', @@ -15,7 +15,7 @@ constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, - '_from_server': _from_server, + '_spec_property_naming': _spec_property_naming, '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index 8433c49f2f..9a3aeaefea 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -1,7 +1,7 @@ required_properties = set([ '_data_store', '_check_type', - '_from_server', + '_spec_property_naming', '_path_to_item', '_configuration', '_visited_composed_classes', diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 1631d57eec..3a77f7e8a8 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,5 +1,5 @@ @convert_js_args_to_python_args - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _spec_property_naming=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#requiredVars}} @@ -26,8 +26,10 @@ _path_to_item (tuple/list): This is a list of keys or values to drill down to the model in received_data when deserializing a response - _from_server (bool): True if the data is from the server - False if the data is from the client (default) + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted @@ -54,7 +56,7 @@ self._data_store = {} self._check_type = _check_type - self._from_server = _from_server + self._spec_property_naming = _spec_property_naming self._path_to_item = _path_to_item self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) \ No newline at end of file diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/python-experimental/model_templates/method_set_attribute.mustache index fddbc7c2ea..8ba0529cd0 100644 --- a/python-experimental/model_templates/method_set_attribute.mustache +++ b/python-experimental/model_templates/method_set_attribute.mustache @@ -33,7 +33,7 @@ if self._check_type: value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, + value, required_types_mixed, path_to_item, self._spec_property_naming, self._check_type, configuration=self._configuration) if (name,) in self.allowed_values: check_allowed_values( diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index c1c3c934aa..a0d2dd2e5b 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -564,15 +564,17 @@ def order_response_types(required_types): return sorted_types -def remove_uncoercible(required_types_classes, current_item, from_server, +def remove_uncoercible(required_types_classes, current_item, spec_property_naming, must_convert=True): """Only keeps the type conversions that are possible Args: required_types_classes (tuple): tuple of classes that are required these should be ordered by COERCION_INDEX_BY_TYPE - from_server (bool): a boolean of whether the data is from the server - if false, the data is from the client + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. current_item (any): the current item (input data) to be converted Keyword Args: @@ -602,7 +604,7 @@ def remove_uncoercible(required_types_classes, current_item, from_server, continue class_pair = (current_type_simple, required_type_class_simplified) - if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[from_server]: + if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[spec_property_naming]: results_classes.append(required_type_class) elif class_pair in UPCONVERSION_TYPE_PAIRS: results_classes.append(required_type_class) @@ -786,7 +788,7 @@ def get_discriminator_class(model_class, def deserialize_model(model_data, model_class, path_to_item, check_type, - configuration, from_server): + configuration, spec_property_naming): """Deserializes model_data to model instance. Args: @@ -796,8 +798,10 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, check_type (bool): whether to check the data tupe for the values in the model configuration (Configuration): the instance to use to convert files - from_server (bool): True if the data is from the server - False if the data is from the client + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. Returns: model instance @@ -811,7 +815,7 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, kw_args = dict(_check_type=check_type, _path_to_item=path_to_item, _configuration=configuration, - _from_server=from_server) + _spec_property_naming=spec_property_naming) if issubclass(model_class, ModelSimple): instance = model_class(value=model_data, **kw_args) @@ -862,7 +866,7 @@ def deserialize_file(response_data, configuration, content_disposition=None): def attempt_convert_item(input_value, valid_classes, path_to_item, - configuration, from_server, key_type=False, + configuration, spec_property_naming, key_type=False, must_convert=False, check_type=True): """ Args: @@ -870,8 +874,10 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, valid_classes (any): the classes that are valid path_to_item (list): the path to the item to convert configuration (Configuration): the instance to use to convert files - from_server (bool): True if data is from the server, False is data is - from the client + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in @@ -887,7 +893,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, """ valid_classes_ordered = order_response_types(valid_classes) valid_classes_coercible = remove_uncoercible( - valid_classes_ordered, input_value, from_server) + valid_classes_ordered, input_value, spec_property_naming) if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us @@ -899,7 +905,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, if issubclass(valid_class, OpenApiModel): return deserialize_model(input_value, valid_class, path_to_item, check_type, - configuration, from_server) + configuration, spec_property_naming) elif valid_class == file_type: return deserialize_file(input_value, configuration) return deserialize_primitive(input_value, valid_class, @@ -971,7 +977,7 @@ def is_valid_type(input_class_simple, valid_classes): def validate_and_convert_types(input_value, required_types_mixed, path_to_item, - from_server, _check_type, configuration=None): + spec_property_naming, _check_type, configuration=None): """Raises a TypeError is there is a problem, otherwise returns value Args: @@ -982,8 +988,10 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, path_to_item: (list) the path to the data being validated this stores a list of keys or indices to get to the data being validated - from_server (bool): True if data is from the server - False if data is from the client + spec_property_naming (bool): True if the variable names in the input + data are serialized names as specified in the OpenAPI document. + False if the variables names in the input data are python + variable names in PEP-8 snake case. _check_type: (boolean) if true, type will be checked and conversion will be attempted. configuration: (Configuration): the configuration class to use @@ -1011,7 +1019,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, valid_classes, path_to_item, configuration, - from_server, + spec_property_naming, key_type=False, must_convert=True ) @@ -1024,14 +1032,14 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, if len(valid_classes) > 1 and configuration: # there are valid classes which are not the current class valid_classes_coercible = remove_uncoercible( - valid_classes, input_value, from_server, must_convert=False) + valid_classes, input_value, spec_property_naming, must_convert=False) if valid_classes_coercible: converted_instance = attempt_convert_item( input_value, valid_classes_coercible, path_to_item, configuration, - from_server, + spec_property_naming, key_type=False, must_convert=False ) @@ -1058,7 +1066,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, inner_value, inner_required_types, inner_path, - from_server, + spec_property_naming, _check_type, configuration=configuration ) @@ -1076,7 +1084,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, inner_val, inner_required_types, inner_path, - from_server, + spec_property_naming, _check_type, configuration=configuration ) @@ -1182,8 +1190,8 @@ def convert_js_args_to_python_args(fn): from functools import wraps @wraps(fn) def wrapped_init(self, *args, **kwargs): - from_server = kwargs.get('_from_server', False) - if from_server: + spec_property_naming = kwargs.get('_spec_property_naming', False) + if spec_property_naming: kwargs = change_keys_js_to_python(kwargs, self.__class__) return fn(self, *args, **kwargs) return wrapped_init From a9e712e3cb31c5fe2d32d4a4dbe196a3fb7fe7aa Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Sun, 24 May 2020 17:21:00 -0700 Subject: [PATCH 116/185] [Python-experimental] Fix type error if oneof/anyof child schema is null type (#6387) * Mustache template should use invokerPackage tag to generate import * Fix runtime exception when composed schema has 'null' type * Fix runtime exception when composed schema has 'null' type --- python-experimental/model_utils.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index a0d2dd2e5b..c9a527ab6f 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -779,7 +779,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls.discriminator is not None: + if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: From 2b908e159d2da083b1f61ff746160dda491064cd Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 27 May 2020 20:33:43 -0700 Subject: [PATCH 117/185] python-experimental updates ancestor + adds descendant discriminator tests (#6417) * Updates comments in new method * Adds missing line in model_utils.py * Removes biology examples, adds ParentPet ancestor example + test, adds Pig schemas * Updates comment and var names in get_discriminator_class, adds testMammal test * Updates comment --- python-experimental/model_utils.mustache | 71 ++++++++++++++---------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index c9a527ab6f..49ad6f35e3 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -83,26 +83,22 @@ class OpenApiModel(object): cls.discriminator is None or cls in visited_composed_classes ): - # This openapi schema (cls) does not have a discriminator - # Or we have already visited this class before and are sure that we - # want to instantiate it this time. + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. # - # If we are making an instance of a composed schema Descendent - # which allOf includes Ancestor, then Ancestor contains - # a discriminator that includes Descendent. - # So if we make an instance of Descendent, we have to make an - # instance of Ancestor to hold the allOf properties. - # This code detects that use case and makes the instance of Ancestor - # For example: - # When making an instance of Dog, _visited_composed_classes = (Dog,) - # then we make an instance of Animal to include in dog._composed_instances - # so when we are here, cls is Animal - # cls.discriminator != None - # cls not in _visited_composed_classes - # new_cls = Dog - # but we know we know that we already have Dog - # because it is in visited_composed_classes - # so make Animal here + # Here's an example of use case 2: If Animal has a discriminator + # petType and we pass in "Dog", and the class Dog + # allOf includes Animal, we move through Animal + # once using the discriminator, and pick Dog. + # Then in the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + return super(OpenApiModel, cls).__new__(cls) # Get the name and value of the discriminator property. @@ -141,7 +137,22 @@ class OpenApiModel(object): ) if new_cls in visited_composed_classes: - # if we are coming from the chosen new_cls use cls instead + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here return super(OpenApiModel, cls).__new__(cls) oneof_anyof_child = new_cls in oneof_anyof_classes @@ -766,18 +777,20 @@ def get_discriminator_class(model_class, used_model_class = class_name_to_discr_class.get(discr_value) if used_model_class is None: # We didn't find a discriminated class in class_name_to_discr_class. + # So look in the ancestor or descendant discriminators # The discriminator mapping may exist in a descendant (anyOf, oneOf) # or ancestor (allOf). - # Ancestor example: in the "Dog -> Mammal -> Chordate -> Animal" + # Ancestor example: in the GrandparentAnimal -> ParentPet -> ChildCat # hierarchy, the discriminator mappings may be defined at any level - # in the hieararchy. - # Descendant example: a schema is oneOf[Plant, Mammal], and each - # oneOf child may itself be an allOf with some arbitrary hierarchy, - # and a graph traversal is required to find the discriminator. - composed_children = model_class._composed_schemas.get('oneOf', ()) + \ - model_class._composed_schemas.get('anyOf', ()) + \ - model_class._composed_schemas.get('allOf', ()) - for cls in composed_children: + # in the hierarchy. + # Descendant example: mammal -> whale/zebra/Pig -> BasquePig/DanishPig + # if we try to make BasquePig from mammal, we need to travel through + # the oneOf descendant discriminators to find BasquePig + descendant_classes = model_class._composed_schemas.get('oneOf', ()) + \ + model_class._composed_schemas.get('anyOf', ()) + ancestor_classes = model_class._composed_schemas.get('allOf', ()) + possible_classes = descendant_classes + ancestor_classes + for cls in possible_classes: # Check if the schema has inherited discriminators. if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( From 35b2b7d7c20a1fa04885c711eacfb5b1740e0e1b Mon Sep 17 00:00:00 2001 From: Sebastien Rosset Date: Thu, 28 May 2020 09:40:48 -0700 Subject: [PATCH 118/185] [codegen][python-experimental] Composed schema with additionalProperties (#6290) * Mustache template should use invokerPackage tag to generate import * Add a unit test for allOf and additionalProperties * Fix getAdditionalProperties * Add code comments * Add code comments * set nullable for additionalproperties * add variants of additionalProperties * Add more unit tests * Handle additionalProperties for composed schemas * improve code comments * Add code comments * Add code comments * Add code comments * Add code comments * Add code comments * Add assertions in unit tests * Add new property to support the 'additionalProperties' keyword with composed schemas * run sample scripts * fix unit tests to handle additionalProperties * Handle additional properties and composed schema * Handle additional properties and composed schema * Add support for additionalProperties and composed schema * Format java code * Add more unit tests for Python * Handle reference in additionalProperty keyword * Handle reference in additionalProperty keyword * Add use case for additionalProperties and reference * run sample scripts * resolve schema reference * Add OpenAPI argument * Add OpenAPI argument * Add OpenAPI argument * Add OpenAPI argument * Add OpenAPI argument * Handle additional property keyword with reference * Handle additional property keyword with reference * Handle additional property keyword with reference * Handle additional property keyword with reference * add additionalproperties attribute with boolean values * Run sample scripts * handle additional properties * Handle additionalProperties boolean values * Run sample scripts * fix javadoc issues * fix javadoc issues * Add Locale to String.toLowerCase * execute sample scripts * handle additional properties * Add code comments * Handle imports of referenced models in additional properties * Handle isNullable class * handle nullable type * improve documentation, run sample scripts * improve documentation, run sample scripts * execute sample scripts * execute sample scripts * Execute sample scripts * Run samples scripts * set legacyAdditionalPropertiesBehavior to true by default, except python * create separate yaml file to avoid having lots of changes in the pr * create separate yaml file to avoid having lots of changes in the pr * create separate yaml file to avoid having lots of changes in the pr * create separate yaml file to avoid having lots of changes in the pr * create separate yaml file to avoid having lots of changes in the pr * create separate yaml file to avoid having lots of changes in the pr * Change name of CLI option * Generate doc * Add TODO statement * add code comments * run samples scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * refactor cli option for additional properties * refactor cli option for additional properties * run samples scripts * run sample scripts * run sample scripts * run sample scripts * run sample scripts * Add yaml comments * small refactor * small refactor * run sample scripts * run sample scripts * fix unit tests * Set disallowAdditionalPropertiesIfNotPresent flag * reduced size of test yaml file * simplify code and add imports directly * rename some of the properties used in tests * Handle more scenarios for nullable types * add code comments * Adds *args input to __init__ method to fix test testFruitNullValue * Resolve merge issues * run samples scripts * run doc generator * fix merge conflicts Co-authored-by: Justin Black --- python-experimental/model.mustache | 1 + .../model_templates/classvars.mustache | 2 ++ .../method_init_shared.mustache | 23 ++++++++++++++++++- python-experimental/model_utils.mustache | 22 +++++++++--------- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 9afb17b527..0790c61435 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -10,6 +10,7 @@ import six # noqa: F401 import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 + ApiTypeError, ModelComposed, ModelNormal, ModelSimple, diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 471c16c10a..9fc3f83433 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -100,6 +100,8 @@ additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} + _nullable = {{#isNullable}}True{{/isNullable}}{{^isNullable}}False{{/isNullable}} + @cached_property def openapi_types(): """ diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 3a77f7e8a8..78059150f2 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -1,5 +1,5 @@ @convert_js_args_to_python_args - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _spec_property_naming=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#requiredVars}} @@ -54,6 +54,27 @@ {{/optionalVars}} """ +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + self._data_store = {} self._check_type = _check_type self._spec_property_naming = _spec_property_naming diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 49ad6f35e3..b1db9b329c 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -66,16 +66,8 @@ class OpenApiModel(object): # pick a new schema/class to instantiate because a discriminator # propertyName value was passed in - # Build a list containing all oneOf and anyOf descendants. - oneof_anyof_classes = None - if cls._composed_schemas is not None: - oneof_anyof_classes = ( - cls._composed_schemas.get('oneOf', ()) + - cls._composed_schemas.get('anyOf', ())) - if (oneof_anyof_classes and none_type in oneof_anyof_classes and - len(args) == 1 and args[0] is None): - # The input data is the 'null' value AND one of the oneOf/anyOf children - # is the 'null' type (which is introduced in OAS schema >= 3.1). + if len(args) == 1 and args[0] is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. return None visited_composed_classes = kwargs.get('_visited_composed_classes', ()) @@ -155,6 +147,12 @@ class OpenApiModel(object): # so make Animal here return super(OpenApiModel, cls).__new__(cls) + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) oneof_anyof_child = new_cls in oneof_anyof_classes kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) @@ -950,8 +948,10 @@ def is_type_nullable(input_type): """ if input_type is none_type: return True + if issubclass(input_type, OpenApiModel) and input_type._nullable: + return True if issubclass(input_type, ModelComposed): - # If oneOf/anyOf, check if the 'null' type is one of the allowed types. + # If oneOf/anyOf, check if the 'null' type is one of the allowed types. for t in input_type._composed_schemas.get('oneOf', ()): if is_type_nullable(t): return True for t in input_type._composed_schemas.get('anyOf', ()): From 591899af81d946eb990d0190010fbf5aa18a09fc Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 1 Jun 2020 00:25:37 -0700 Subject: [PATCH 119/185] [python-experimental] Quicken package loading (#6437) * apis and models contains all apis and models, omits loading them in the package namespace * Runs git add -a and commits it * Fixes test_outer_enum.py * Fixes test_fruit.py * Updates test_fruit and test_mammal * Fixes test_parent_pet * Updates test_discard_unknown_properties.py * Updates test_deserialization.py * Updates v2 docs md files for apis + the readme * Fixes v2 tests * v2 doc updates * Updates v3 docs * Reverts python_doc_auth_partial.mustache * Adds sys to v3 tests * Adds FILES update Co-authored-by: Justin Black --- python-experimental/README_common.mustache | 39 ++++++++++++++++++-- python-experimental/__init__api.mustache | 3 ++ python-experimental/__init__apis.mustache | 19 ++++++++++ python-experimental/__init__model.mustache | 8 ++-- python-experimental/__init__models.mustache | 18 +++++++++ python-experimental/__init__package.mustache | 17 +-------- python-experimental/api_doc_example.mustache | 6 ++- python-experimental/api_test.mustache | 36 ++++++++++++++++++ python-experimental/model_test.mustache | 10 +++-- 9 files changed, 129 insertions(+), 27 deletions(-) create mode 100644 python-experimental/__init__api.mustache create mode 100644 python-experimental/__init__apis.mustache create mode 100644 python-experimental/__init__models.mustache create mode 100644 python-experimental/api_test.mustache diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index 7d9811fdfb..0f6dcb41d6 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -4,13 +4,22 @@ from __future__ import print_function import time import {{{packageName}}} from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{#apiInfo}} +{{#apis}} +{{#-first}} +from {{apiPackage}} import {{classVarName}} +{{#imports}} +{{{import}}} +{{/imports}} +{{#operations}} +{{#operation}} +{{#-first}} {{> python_doc_auth_partial}} # Enter a context with an instance of the API client with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) + api_instance = {{classVarName}}.{{{classname}}}(api_client) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} @@ -20,7 +29,12 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: pprint(api_response){{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +{{/-first}} +{{/operation}} +{{/operations}} +{{/-first}} +{{/apis}} +{{/apiInfo}} ``` ## Documentation for API Endpoints @@ -77,3 +91,22 @@ Class | Method | HTTP request | Description {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} {{/hasMore}}{{/apis}}{{/apiInfo}} + +## Notes for Large OpenAPI documents +If the OpenAPI document is large, imports in {{{packageName}}}.apis and {{{packageName}}}.models may fail with a +RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: + +Solution 1: +Use specific imports for apis and models like: +- `from {{{packageName}}}.api.default_api import DefaultApi` +- `from {{{packageName}}}.model.pet import Pet` + +Solution 1: +Before importing the package, adjust the maximum recursion limit as shown below: +``` +import sys +sys.setrecursionlimit(1500) +import {{{packageName}}} +from {{{packageName}}}.apis import * +from {{{packageName}}}.models import * +``` diff --git a/python-experimental/__init__api.mustache b/python-experimental/__init__api.mustache new file mode 100644 index 0000000000..d37ee6c78b --- /dev/null +++ b/python-experimental/__init__api.mustache @@ -0,0 +1,3 @@ +# do not import all apis into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from {{packageName}.apis import DefaultApi, PetApi \ No newline at end of file diff --git a/python-experimental/__init__apis.mustache b/python-experimental/__init__apis.mustache new file mode 100644 index 0000000000..b5b7065e1e --- /dev/null +++ b/python-experimental/__init__apis.mustache @@ -0,0 +1,19 @@ +# coding: utf-8 + +# flake8: noqa + +# import all apis into this package +# if you have many ampis here with many many models used in each api this may +# raise a RecursionError +# to avoid this, import only the api that you directly need like: +# from {{packagename}}.api.pet_api import PetApi +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +# import apis into api package +{{#apiInfo}} +{{#apis}} +from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/python-experimental/__init__model.mustache b/python-experimental/__init__model.mustache index ca86cb8a62..cfe32b7849 100644 --- a/python-experimental/__init__model.mustache +++ b/python-experimental/__init__model.mustache @@ -1,7 +1,5 @@ -# coding: utf-8 - -# flake8: noqa -{{>partial_header}} - # we can not import model classes here because that would create a circular # reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from {{packageName}.models import ModelA, ModelB diff --git a/python-experimental/__init__models.mustache b/python-experimental/__init__models.mustache new file mode 100644 index 0000000000..abe69dc035 --- /dev/null +++ b/python-experimental/__init__models.mustache @@ -0,0 +1,18 @@ +# coding: utf-8 + +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from from {{modelPackage}}.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +{{#models}} +{{#model}} +from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} +{{/model}} +{{/models}} diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache index 1d74d016ab..a949d50850 100644 --- a/python-experimental/__init__package.mustache +++ b/python-experimental/__init__package.mustache @@ -8,13 +8,6 @@ from __future__ import absolute_import __version__ = "{{packageVersion}}" -# import apis into sdk package -{{#apiInfo}} -{{#apis}} -from {{apiPackage}}.{{classVarName}} import {{classname}} -{{/apis}} -{{/apiInfo}} - # import ApiClient from {{packageName}}.api_client import ApiClient @@ -26,14 +19,8 @@ from {{packageName}}.signing import HttpSigningConfiguration # import exceptions from {{packageName}}.exceptions import OpenApiException +from {{packageName}}.exceptions import ApiAttributeError from {{packageName}}.exceptions import ApiTypeError from {{packageName}}.exceptions import ApiValueError from {{packageName}}.exceptions import ApiKeyError -from {{packageName}}.exceptions import ApiException - -# import models into sdk package -{{#models}} -{{#model}} -from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} -{{/model}} -{{/models}} +from {{packageName}}.exceptions import ApiException \ No newline at end of file diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index ae7b8a6979..23cf85e9df 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -2,6 +2,10 @@ from __future__ import print_function import time import {{{packageName}}} +from {{apiPackage}} import {{classVarName}} +{{#imports}} +{{{.}}} +{{/imports}} from pprint import pprint {{> python_doc_auth_partial}} # Enter a context with an instance of the API client @@ -12,7 +16,7 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: with {{{packageName}}}.ApiClient() as api_client: {{/hasAuthMethods}} # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) + api_instance = {{classVarName}}.{{{classname}}}(api_client) {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} diff --git a/python-experimental/api_test.mustache b/python-experimental/api_test.mustache new file mode 100644 index 0000000000..e04b32f96e --- /dev/null +++ b/python-experimental/api_test.mustache @@ -0,0 +1,36 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +import {{packageName}} +from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 + + +class {{#operations}}Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + self.api = {{classname}}() # noqa: E501 + + def tearDown(self): + pass + + {{#operation}} + def test_{{operationId}}(self): + """Test case for {{{operationId}}} + +{{#summary}} + {{{summary}}} # noqa: E501 +{{/summary}} + """ + pass + + {{/operation}} +{{/operations}} + +if __name__ == '__main__': + unittest.main() diff --git a/python-experimental/model_test.mustache b/python-experimental/model_test.mustache index 4fd1263b5f..5b9a91d2d0 100644 --- a/python-experimental/model_test.mustache +++ b/python-experimental/model_test.mustache @@ -3,12 +3,16 @@ {{>partial_header}} from __future__ import absolute_import - +import sys import unittest +import {{packageName}} {{#models}} {{#model}} -import {{packageName}} +{{#imports}} +{{{.}}} +{{/imports}} +from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} class Test{{unescapedDescription}}(unittest.TestCase): @@ -23,7 +27,7 @@ class Test{{unescapedDescription}}(unittest.TestCase): def test{{unescapedDescription}}(self): """Test {{unescapedDescription}}""" # FIXME: construct object with mandatory attributes with example values - # model = {{packageName}}.{{unescapedDescription}}() # noqa: E501 + # model = {{unescapedDescription}}() # noqa: E501 pass {{/model}} From 4e0e68b51b2a767eec3f45506ae3452e1145d033 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 4 Jun 2020 16:50:53 +0200 Subject: [PATCH 120/185] [BUG][python] Support named arrays (#6493) * [python] Support named arrays * Fix named array type * Use ModelSimple * Reset samples * Regenerated * Animal farm test * Array of enums * Clean-up * Clean-up * Clean-up * Fix array type generation * simplify * array model is not alias * Array model has one value field * ensure up-to-date * ./bin/utils/ensure-up-to-date --batch * Solve issue with missing import for array model * regenerate --- python-experimental/model.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 0790c61435..490629c5a3 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -37,7 +37,12 @@ from {{packageName}}.model_utils import ( # noqa: F401 {{> python-experimental/model_templates/model_simple }} {{/isAlias}} {{^isAlias}} +{{#isArrayModel}} +{{> python-experimental/model_templates/model_simple }} +{{/isArrayModel}} +{{^isArrayModel}} {{> python-experimental/model_templates/model_normal }} +{{/isArrayModel}} {{/isAlias}} {{/interfaces}} {{#interfaces}} From a56947578ed10024277bbcd1539be7c109be1c40 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Thu, 4 Jun 2020 08:46:35 -0700 Subject: [PATCH 121/185] [Python] Fixed docstrings in api.mustache (#6391) * [Python] Fixed docstrings Fixes https://github.com/swagger-api/swagger-codegen/issues/9630 * Updated generated files * Fixed python-experimental * Updated generated files * Fully fixed the format of the docstrings * Updated generated files * Updated generated files in openapi3 --- api.mustache | 23 +++++++++++++++++------ model.mustache | 2 +- python-experimental/api.mustache | 1 + python-experimental/api_client.mustache | 15 +++++++++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/api.mustache b/api.mustache index f2c5541835..18ced57845 100644 --- a/api.mustache +++ b/api.mustache @@ -38,6 +38,7 @@ class {{classname}}(object): {{/notes}} This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True + {{#sortParamsByRequiredFlag}} >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} @@ -46,20 +47,24 @@ class {{classname}}(object): {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async_req bool: execute request asynchronously {{#allParams}} - :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} + :param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} + :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} {{/allParams}} + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. + :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. - :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + :return: Returns the result object. If the method is called asynchronously, returns the request thread. + :rtype: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} """ kwargs['_return_http_data_only'] = True return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 @@ -72,6 +77,7 @@ class {{classname}}(object): {{/notes}} This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True + {{#sortParamsByRequiredFlag}} >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) {{/sortParamsByRequiredFlag}} @@ -80,22 +86,27 @@ class {{classname}}(object): {{/sortParamsByRequiredFlag}} >>> result = thread.get() - :param async_req bool: execute request asynchronously {{#allParams}} - :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}} + :param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} + :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} {{/allParams}} + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers + :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. + :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. - :return: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}} + :return: Returns the result object. If the method is called asynchronously, returns the request thread. + :rtype: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}} """ {{#servers.0}} diff --git a/model.mustache b/model.mustache index 112246604d..2b3299a6f2 100644 --- a/model.mustache +++ b/model.mustache @@ -107,7 +107,7 @@ class {{classname}}(object): {{/description}} :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type: {{dataType}} + :type {{name}}: {{dataType}} """ {{^isNullable}} {{#required}} diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 44fc3a8997..92e909165d 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -66,6 +66,7 @@ class {{classname}}(object): {{/notes}} This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True + >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) >>> result = thread.get() diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index 5285a7b806..d17177a832 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -291,6 +291,7 @@ class ApiClient(object): ({str: (bool, str, int, float, date, datetime, str, none_type)},) :param _check_type: boolean, whether to check the types of the data received from the server + :type _check_type: bool :return: deserialized object. """ @@ -350,22 +351,28 @@ class ApiClient(object): (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},) - :param files dict: key -> field name, value -> a list of open file + :param files: key -> field name, value -> a list of open file objects for `multipart/form-data`. + :type files: dict :param async_req bool: execute request asynchronously + :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers + :type _return_http_data_only: bool, optional :param collection_formats: dict of collection formats for path, query, header, and post parameters. + :type collection_formats: dict, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. + :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _check_type: boolean describing if the data back from the server should have its type checked. + :type _check_type: bool, optional :return: If async_req parameter is True, the request will be called asynchronously. @@ -559,9 +566,9 @@ class ApiClient(object): :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. - :resource_path: A string representation of the HTTP request resource path. - :method: A string representation of the HTTP request method. - :body: A object representing the body of the HTTP request. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. The object type is the return value of sanitize_for_serialization(). """ if not auth_settings: From 21847dba944a51a18071d850492118919f160a18 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 11 Jun 2020 04:06:39 +0200 Subject: [PATCH 122/185] [Python] Update docstring and fix a typo (#6612) * [Python] Update docstring and fix a typo * regenerate --- python-experimental/__init__apis.mustache | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/python-experimental/__init__apis.mustache b/python-experimental/__init__apis.mustache index b5b7065e1e..da3937f8c5 100644 --- a/python-experimental/__init__apis.mustache +++ b/python-experimental/__init__apis.mustache @@ -2,18 +2,21 @@ # flake8: noqa -# import all apis into this package -# if you have many ampis here with many many models used in each api this may -# raise a RecursionError -# to avoid this, import only the api that you directly need like: -# from {{packagename}}.api.pet_api import PetApi +# Import all APIs into this package. +# If you have many APIs here with many many models used in each API this may +# raise a `RecursionError`. +# In order to avoid this, import only the API that you directly need like: +# +# from {{packagename}}.api.pet_api import PetApi +# # or import this package, but before doing it, use: -# import sys -# sys.setrecursionlimit(n) +# +# import sys +# sys.setrecursionlimit(n) -# import apis into api package +# Import APIs into API package: {{#apiInfo}} {{#apis}} from {{apiPackage}}.{{classVarName}} import {{classname}} {{/apis}} -{{/apiInfo}} \ No newline at end of file +{{/apiInfo}} From d3a6d482e238b62cf3bffbc5ef2c1a613da961d1 Mon Sep 17 00:00:00 2001 From: Warren Gray Date: Thu, 11 Jun 2020 02:40:10 -0400 Subject: [PATCH 123/185] [python-client] Enable per-request auth settings (#6569) * Enable per-request access token in Python client. * Add missing regenerated sample files. * Rework to the more general case of overriding the auth settings for a request. * Add unit tests. * Update api_client.mustache so that request_auth overrides all other auth settings when specified. --- api.mustache | 10 ++++++-- api_client.mustache | 57 ++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/api.mustache b/api.mustache index 18ced57845..1dcbb86078 100644 --- a/api.mustache +++ b/api.mustache @@ -103,6 +103,10 @@ class {{classname}}(object): number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. @@ -137,7 +141,8 @@ class {{classname}}(object): 'async_req', '_return_http_data_only', '_preload_content', - '_request_timeout' + '_request_timeout', + '_request_auth' ] ) @@ -266,6 +271,7 @@ class {{classname}}(object): {{#servers.0}} _host=local_var_host, {{/servers.0}} - collection_formats=collection_formats) + collection_formats=collection_formats, + _request_auth=local_var_params.get('_request_auth')) {{/operation}} {{/operations}} diff --git a/api_client.mustache b/api_client.mustache index 66d3577f3c..7eb04b6943 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -132,7 +132,8 @@ class ApiClient(object): query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): config = self.configuration @@ -173,7 +174,9 @@ class ApiClient(object): post_params.extend(self.files_parameters(files)) # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings) + self.update_params_for_auth( + header_params, query_params, auth_settings, + request_auth=_request_auth) # body if body: @@ -347,7 +350,8 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -377,6 +381,10 @@ class ApiClient(object): number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_token: dict, optional :return: If async_req parameter is True, the request will be called asynchronously. @@ -390,7 +398,8 @@ class ApiClient(object): body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout, _host) + _preload_content, _request_timeout, _host, + _request_auth) return self.pool.apply_async(self.__call_api, (resource_path, method, path_params, @@ -403,7 +412,7 @@ class ApiClient(object): collection_formats, _preload_content, _request_timeout, - _host)) + _host, _request_auth)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, @@ -550,29 +559,45 @@ class ApiClient(object): else: return content_types[0] - def update_params_for_auth(self, headers, querys, auth_settings): + def update_params_for_auth(self, headers, querys, auth_settings, + request_auth=None): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. + :param request_auth: if set, the provided settings will + override the token in the configuration. """ if not auth_settings: return + if request_auth: + self._apply_auth_params(headers, querys, request_auth) + return + for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) + self._apply_auth_params(headers, querys, auth_setting) + + def _apply_auth_params(self, headers, querys, auth_setting): + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) def __deserialize_file(self, response): """Deserializes body to file From 247544d20d2079917f8d5ca05cb768e3cccbafe9 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 11 Jun 2020 18:19:57 +0200 Subject: [PATCH 124/185] [feature][python] Support aliasing of API keys (#6469) * [python] Support aliasing of API keys * Support for aliasing and prefix * Make more realistic usage * Regenerate * Document alias in generated code * Support override of aliased keys * Use diferent id and name for api keys * ensure up-to-date * Simple example without x-auth-id-alias * regenerate docs * Regenerate * Provide separate spec for x-auth-id-alias * Apply suggestions from code review * regenerated --- configuration.mustache | 12 ++++++++---- python_doc_auth_partial.mustache | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index d1705eed25..f74ae45f28 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -423,15 +423,16 @@ conf = {{{packageName}}}.Configuration( self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier): + def get_api_key_with_prefix(self, identifier, alias=None): """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. :return: The token for api key authentication. """ if self.refresh_api_key_hook is not None: self.refresh_api_key_hook(self) - key = self.api_key.get(identifier) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) if key: prefix = self.api_key_prefix.get(identifier) if prefix: @@ -462,12 +463,15 @@ conf = {{{packageName}}}.Configuration( auth = {} {{#authMethods}} {{#isApiKey}} - if '{{keyParamName}}' in self.api_key: + if '{{name}}' in self.api_key{{#vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/vendorExtensions.x-auth-id-alias}}: auth['{{name}}'] = { 'type': 'api_key', 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, 'key': '{{keyParamName}}', - 'value': self.get_api_key_with_prefix('{{keyParamName}}') + 'value': self.get_api_key_with_prefix( + '{{name}}',{{#vendorExtensions.x-auth-id-alias}} + alias='{{.}}',{{/vendorExtensions.x-auth-id-alias}} + ), } {{/isApiKey}} {{#isBasic}} diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 3086d770b1..460c2df938 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -95,11 +95,11 @@ configuration = {{{packageName}}}.Configuration( configuration = {{{packageName}}}.Configuration( host = "{{{basePath}}}", api_key = { - '{{{keyParamName}}}': 'YOUR_API_KEY' + '{{name}}': 'YOUR_API_KEY' } ) # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer' +# configuration.api_key_prefix['{{name}}'] = 'Bearer' {{/isApiKey}} {{#isOAuth}} From 265154ebccf289a907571d7e6faf9e2e9d964bcb Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 15 Jun 2020 21:53:43 +0200 Subject: [PATCH 125/185] [Python] Add attribute_map to simple model (#6669) * [python] Add missing attribute_map definition * regenerated --- python-experimental/model_templates/model_simple.mustache | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index 95b8a81715..bc582ff796 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -11,6 +11,8 @@ class {{unescapedDescription}}(ModelSimple): {{> python-experimental/model_templates/classvars }} + attribute_map = {} + _composed_schemas = None {{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file From 2d731f53cdc30beeb303c99718cb4946d9f2f49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Herv=C3=A9?= Date: Tue, 16 Jun 2020 16:52:45 +0200 Subject: [PATCH 126/185] [Python] Remove duplicate definition of Endpoint class (#6667) * Remove duplicate definition of Endpoint class The class is copied in every API modules, we can share it alongside the API client. * Regenerate examples --- python-experimental/api.mustache | 226 +----------------------- python-experimental/api_client.mustache | 226 +++++++++++++++++++++++- 2 files changed, 226 insertions(+), 226 deletions(-) diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 92e909165d..3d0b4a06af 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -10,11 +10,7 @@ import sys # noqa: F401 # python 2 and python 3 compatibility library import six -from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( - ApiTypeError, - ApiValueError -) +from {{packageName}}.api_client import ApiClient, Endpoint from {{packageName}}.model_utils import ( # noqa: F401 check_allowed_values, check_validations, @@ -293,223 +289,3 @@ class {{classname}}(object): ) {{/operation}} {{/operations}} - - -class Endpoint(object): - def __init__(self, settings=None, params_map=None, root_map=None, - headers_map=None, api_client=None, callable=None): - """Creates an endpoint - - Args: - settings (dict): see below key value pairs - 'response_type' (tuple/None): response type - 'auth' (list): a list of auth type keys - 'endpoint_path' (str): the endpoint path - 'operation_id' (str): endpoint string identifier - 'http_method' (str): POST/PUT/PATCH/GET etc - 'servers' (list): list of str servers that this endpoint is at - params_map (dict): see below key value pairs - 'all' (list): list of str endpoint parameter names - 'required' (list): list of required parameter names - 'nullable' (list): list of nullable parameter names - 'enum' (list): list of parameters with enum values - 'validation' (list): list of parameters with validations - root_map - 'validations' (dict): the dict mapping endpoint parameter tuple - paths to their validation dictionaries - 'allowed_values' (dict): the dict mapping endpoint parameter - tuple paths to their allowed_values (enum) dictionaries - 'openapi_types' (dict): param_name to openapi type - 'attribute_map' (dict): param_name to camelCase name - 'location_map' (dict): param_name to 'body', 'file', 'form', - 'header', 'path', 'query' - collection_format_map (dict): param_name to `csv` etc. - headers_map (dict): see below key value pairs - 'accept' (list): list of Accept header strings - 'content_type' (list): list of Content-Type header strings - api_client (ApiClient) api client instance - callable (function): the function which is invoked when the - Endpoint is called - """ - self.settings = settings - self.params_map = params_map - self.params_map['all'].extend([ - 'async_req', - '_host_index', - '_preload_content', - '_request_timeout', - '_return_http_data_only', - '_check_input_type', - '_check_return_type' - ]) - self.params_map['nullable'].extend(['_request_timeout']) - self.validations = root_map['validations'] - self.allowed_values = root_map['allowed_values'] - self.openapi_types = root_map['openapi_types'] - extra_types = { - 'async_req': (bool,), - '_host_index': (int,), - '_preload_content': (bool,), - '_request_timeout': (none_type, int, (int,), [int]), - '_return_http_data_only': (bool,), - '_check_input_type': (bool,), - '_check_return_type': (bool,) - } - self.openapi_types.update(extra_types) - self.attribute_map = root_map['attribute_map'] - self.location_map = root_map['location_map'] - self.collection_format_map = root_map['collection_format_map'] - self.headers_map = headers_map - self.api_client = api_client - self.callable = callable - - def __validate_inputs(self, kwargs): - for param in self.params_map['enum']: - if param in kwargs: - check_allowed_values( - self.allowed_values, - (param,), - kwargs[param] - ) - - for param in self.params_map['validation']: - if param in kwargs: - check_validations( - self.validations, - (param,), - kwargs[param], - configuration=self.api_client.configuration - ) - - if kwargs['_check_input_type'] is False: - return - - for key, value in six.iteritems(kwargs): - fixed_val = validate_and_convert_types( - value, - self.openapi_types[key], - [key], - False, - kwargs['_check_input_type'], - configuration=self.api_client.configuration - ) - kwargs[key] = fixed_val - - def __gather_params(self, kwargs): - params = { - 'body': None, - 'collection_format': {}, - 'file': {}, - 'form': [], - 'header': {}, - 'path': {}, - 'query': [] - } - - for param_name, param_value in six.iteritems(kwargs): - param_location = self.location_map.get(param_name) - if param_location is None: - continue - if param_location: - if param_location == 'body': - params['body'] = param_value - continue - base_name = self.attribute_map[param_name] - if (param_location == 'form' and - self.openapi_types[param_name] == (file_type,)): - params['file'][param_name] = [param_value] - elif (param_location == 'form' and - self.openapi_types[param_name] == ([file_type],)): - # param_value is already a list - params['file'][param_name] = param_value - elif param_location in {'form', 'query'}: - param_value_full = (base_name, param_value) - params[param_location].append(param_value_full) - if param_location not in {'form', 'query'}: - params[param_location][base_name] = param_value - collection_format = self.collection_format_map.get(param_name) - if collection_format: - params['collection_format'][base_name] = collection_format - - return params - - def __call__(self, *args, **kwargs): - """ This method is invoked when endpoints are called - Example: - pet_api = PetApi() - pet_api.add_pet # this is an instance of the class Endpoint - pet_api.add_pet() # this invokes pet_api.add_pet.__call__() - which then invokes the callable functions stored in that endpoint at - pet_api.add_pet.callable or self.callable in this class - """ - return self.callable(self, *args, **kwargs) - - def call_with_http_info(self, **kwargs): - - try: - _host = self.settings['servers'][kwargs['_host_index']] - except IndexError: - if self.settings['servers']: - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" % - len(self.settings['servers']) - ) - _host = None - - for key, value in six.iteritems(kwargs): - if key not in self.params_map['all']: - raise ApiTypeError( - "Got an unexpected parameter '%s'" - " to method `%s`" % - (key, self.settings['operation_id']) - ) - # only throw this nullable ApiValueError if _check_input_type - # is False, if _check_input_type==True we catch this case - # in self.__validate_inputs - if (key not in self.params_map['nullable'] and value is None - and kwargs['_check_input_type'] is False): - raise ApiValueError( - "Value may not be None for non-nullable parameter `%s`" - " when calling `%s`" % - (key, self.settings['operation_id']) - ) - - for key in self.params_map['required']: - if key not in kwargs.keys(): - raise ApiValueError( - "Missing the required parameter `%s` when calling " - "`%s`" % (key, self.settings['operation_id']) - ) - - self.__validate_inputs(kwargs) - - params = self.__gather_params(kwargs) - - accept_headers_list = self.headers_map['accept'] - if accept_headers_list: - params['header']['Accept'] = self.api_client.select_header_accept( - accept_headers_list) - - content_type_headers_list = self.headers_map['content_type'] - if content_type_headers_list: - header_list = self.api_client.select_header_content_type( - content_type_headers_list) - params['header']['Content-Type'] = header_list - - return self.api_client.call_api( - self.settings['endpoint_path'], self.settings['http_method'], - params['path'], - params['query'], - params['header'], - body=params['body'], - post_params=params['form'], - files=params['file'], - response_type=self.settings['response_type'], - auth_settings=self.settings['auth'], - async_req=kwargs['async_req'], - _check_type=kwargs['_check_return_type'], - _return_http_data_only=kwargs['_return_http_data_only'], - _preload_content=kwargs['_preload_content'], - _request_timeout=kwargs['_request_timeout'], - _host=_host, - collection_formats=params['collection_format']) diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index d17177a832..da5dbfb341 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -18,16 +18,20 @@ import tornado.gen from {{packageName}} import rest from {{packageName}}.configuration import Configuration -from {{packageName}}.exceptions import ApiValueError, ApiException +from {{packageName}}.exceptions import ApiTypeError, ApiValueError, ApiException from {{packageName}}.model_utils import ( ModelNormal, ModelSimple, ModelComposed, + check_allowed_values, + check_validations, date, datetime, deserialize_file, file_type, + int, model_to_dict, + none_type, str, validate_and_convert_types ) @@ -597,3 +601,223 @@ class ApiClient(object): raise ApiValueError( 'Authentication token must be in `query` or `header`' ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + settings (dict): see below key value pairs + 'response_type' (tuple/None): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called + """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only', + '_check_input_type', + '_check_return_type' + ]) + self.params_map['nullable'].extend(['_request_timeout']) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + extra_types = { + 'async_req': (bool,), + '_host_index': (int,), + '_preload_content': (bool,), + '_request_timeout': (none_type, int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) + } + self.openapi_types.update(extra_types) + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param] + ) + + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param], + configuration=self.api_client.configuration + ) + + if kwargs['_check_input_type'] is False: + return + + for key, value in six.iteritems(kwargs): + fixed_val = validate_and_convert_types( + value, + self.openapi_types[key], + [key], + False, + kwargs['_check_input_type'], + configuration=self.api_client.configuration + ) + kwargs[key] = fixed_val + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location is None: + continue + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): + # param_value is already a list + params['file'][param_name] = param_value + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + try: + _host = self.settings['servers'][kwargs['_host_index']] + except IndexError: + if self.settings['servers']: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + _host = None + + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: + raise ApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + # only throw this nullable ApiValueError if _check_input_type + # is False, if _check_input_type==True we catch this case + # in self.__validate_inputs + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) + + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) + + self.__validate_inputs(kwargs) + + params = self.__gather_params(kwargs) + + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) + + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list + + return self.api_client.call_api( + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], + _host=_host, + collection_formats=params['collection_format']) From 57f64fc96f55ffef1253ce065e8001eefeeff738 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 22 Jun 2020 20:07:18 +0200 Subject: [PATCH 127/185] [Python] enum serialization (#6746) * [Python] enum serialization * Fix serialization of nested enum --- python-experimental/model_utils.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index b1db9b329c..58859114bd 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -951,7 +951,7 @@ def is_type_nullable(input_type): if issubclass(input_type, OpenApiModel) and input_type._nullable: return True if issubclass(input_type, ModelComposed): - # If oneOf/anyOf, check if the 'null' type is one of the allowed types. + # If oneOf/anyOf, check if the 'null' type is one of the allowed types. for t in input_type._composed_schemas.get('oneOf', ()): if is_type_nullable(t): return True for t in input_type._composed_schemas.get('anyOf', ()): @@ -975,7 +975,7 @@ def is_valid_type(input_class_simple, valid_classes): input_class_simple is none_type): for valid_class in valid_classes: if input_class_simple is none_type and is_type_nullable(valid_class): - # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. + # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. return True if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): continue @@ -1138,6 +1138,8 @@ def model_to_dict(model_instance, serialize=True): if hasattr(item[1], '_data_store') else item, value.items() )) + elif isinstance(value, ModelSimple): + result[attr] = value.value elif hasattr(value, '_data_store'): result[attr] = model_to_dict(value, serialize=serialize) else: From 3d3d771ed53c28eb6370acaeafb1b9b239c02152 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Fri, 26 Jun 2020 06:28:54 +0200 Subject: [PATCH 128/185] [Python] Support for per-operation servers (#6557) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Dynamic server support * regenerated * Apply suggestions from code review Co-authored-by: Thomas Hervé * regenerated * Add ParameterizedServer feature to Python experimental * Fix lookup of server variables * Add tests and change default value for servers * Fix server variables * Return base path when index is None * Use HOST * Apply suggestions from code review * Apply suggestions from code review * regenerated * Add specific tests for dynamic servers * regenerated * add docstring * regenerated * Fix wrong merge resolution Co-authored-by: Thomas Hervé --- configuration.mustache | 44 ++++++++++++++++++++++--- python-experimental/api.mustache | 34 ++++++++++++++++--- python-experimental/api_client.mustache | 12 +++++-- 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index f74ae45f28..6afe91d027 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -67,6 +67,15 @@ class Configuration(object): :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration {{/hasHttpSignatureMethods}} + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. {{#hasAuthMethods}} :Example: @@ -155,7 +164,7 @@ conf = {{{packageName}}}.Configuration( _default = None - def __init__(self, host="{{{basePath}}}", + def __init__(self, host=None, api_key=None, api_key_prefix=None, username=None, password=None, discard_unknown_keys=False, @@ -163,12 +172,22 @@ conf = {{{packageName}}}.Configuration( {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, ): """Constructor """ - self.host = host + self._base_path = "{{{basePath}}}" if host is None else host """Default Base url """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ self.temp_folder_path = None """Temp file folder for downloading files """ @@ -565,14 +584,18 @@ conf = {{{packageName}}}.Configuration( {{/servers}} ] - def get_host_from_settings(self, index, variables=None): + def get_host_from_settings(self, index, variables=None, servers=None): """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None :return: URL based on host settings """ + if index is None: + return self._base_path + variables = {} if variables is None else variables - servers = self.get_host_settings() + servers = self.get_host_settings() if servers is None else servers try: server = servers[index] @@ -584,7 +607,7 @@ conf = {{{packageName}}}.Configuration( url = server['url'] # go through variables and replace placeholders - for variable_name, variable in server['variables'].items(): + for variable_name, variable in server.get('variables', {}).items(): used_value = variables.get( variable_name, variable['default_value']) @@ -599,3 +622,14 @@ conf = {{{packageName}}}.Configuration( url = url.replace("{" + variable_name + "}", used_value) return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 3d0b4a06af..ad5decabf0 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -99,9 +99,9 @@ class {{classname}}(object): _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. - _host_index (int): specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is 0. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -127,7 +127,7 @@ class {{classname}}(object): kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) - kwargs['_host_index'] = kwargs.get('_host_index', 0) + kwargs['_host_index'] = kwargs.get('_host_index') {{#requiredParams}} kwargs['{{paramName}}'] = \ {{paramName}} @@ -156,13 +156,37 @@ class {{classname}}(object): {{#-first}} 'servers': [ {{/-first}} - '{{{url}}}'{{^-last}},{{/-last}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }, {{#-last}} ] {{/-last}} {{/servers}} {{^servers}} - 'servers': [], + 'servers': None, {{/servers}} }, params_map={ diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index da5dbfb341..d3b0b6f60e 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -656,7 +656,7 @@ class Endpoint(object): self.openapi_types = root_map['openapi_types'] extra_types = { 'async_req': (bool,), - '_host_index': (int,), + '_host_index': (none_type, int), '_preload_content': (bool,), '_request_timeout': (none_type, int, (int,), [int]), '_return_http_data_only': (bool,), @@ -755,7 +755,15 @@ class Endpoint(object): def call_with_http_info(self, **kwargs): try: - _host = self.settings['servers'][kwargs['_host_index']] + index = self.api_client.configuration.server_operation_index.get( + self.settings['operation_id'], self.api_client.configuration.server_index + ) if kwargs['_host_index'] is None else kwargs['_host_index'] + server_variables = self.api_client.configuration.server_operation_variables.get( + self.settings['operation_id'], self.api_client.configuration.server_variables + ) + _host = self.api_client.configuration.get_host_from_settings( + index, variables=server_variables, servers=self.settings['servers'] + ) except IndexError: if self.settings['servers']: raise ApiValueError( From 9e15550767ab2ea52d44ecd45f7217fcb06e3e97 Mon Sep 17 00:00:00 2001 From: Matthew Davis <7035647+mdavis-xyz@users.noreply.github.com> Date: Fri, 3 Jul 2020 20:39:53 +1000 Subject: [PATCH 129/185] clarify direction of py client side validation flag (#6850) * clarify direction of py client side validation flag * change pet store py cli validation disable example Co-authored-by: Matthew Davis Co-authored-by: EC2 Default User --- configuration.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.mustache b/configuration.mustache index 6afe91d027..8025a1b655 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -299,7 +299,7 @@ conf = {{{packageName}}}.Configuration( self.retries = None """Adding retries to override urllib3 default value 3 """ - # Disable client side validation + # Enable client side validation self.client_side_validation = True def __deepcopy__(self, memo): From b669e224c83b6d08c70aff9217d1cde59cd9d58c Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sat, 18 Jul 2020 10:13:22 -0700 Subject: [PATCH 130/185] Python-exp remove codegemodel mutation, allow mixed OneOf types (#6797) * Stops converting primitive models into object models, adds ComposedSchemas with mixed type * Samples update for python-exp --- python-experimental/model.mustache | 15 +- python-experimental/model_doc.mustache | 9 + .../model_templates/classvars.mustache | 87 +++----- .../docstring_init_required_kwargs.mustache | 30 +++ .../method_init_normal.mustache | 3 + .../method_init_shared.mustache | 31 +-- .../method_init_simple.mustache | 66 ++++++ .../model_templates/model_simple.mustache | 2 +- .../model_templates/validations.mustache | 28 +++ python-experimental/model_utils.mustache | 206 ++++++++++++++---- 10 files changed, 343 insertions(+), 134 deletions(-) create mode 100644 python-experimental/model_templates/docstring_init_required_kwargs.mustache create mode 100644 python-experimental/model_templates/method_init_simple.mustache create mode 100644 python-experimental/model_templates/validations.mustache diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 490629c5a3..e89b3d5633 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -33,17 +33,22 @@ from {{packageName}}.model_utils import ( # noqa: F401 {{^interfaces}} -{{#isAlias}} -{{> python-experimental/model_templates/model_simple }} -{{/isAlias}} -{{^isAlias}} {{#isArrayModel}} {{> python-experimental/model_templates/model_simple }} {{/isArrayModel}} +{{#isEnum}} +{{> python-experimental/model_templates/model_simple }} +{{/isEnum}} +{{#isAlias}} +{{> python-experimental/model_templates/model_simple }} +{{/isAlias}} {{^isArrayModel}} +{{^isEnum}} +{{^isAlias}} {{> python-experimental/model_templates/model_normal }} -{{/isArrayModel}} {{/isAlias}} +{{/isEnum}} +{{/isArrayModel}} {{/interfaces}} {{#interfaces}} {{#-last}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index a1e57131bc..b5aa50c432 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -5,6 +5,15 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +{{#isEnum}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}}{{#allowableValues}}{{#defaultValue}}, {{/defaultValue}} must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} +{{/isEnum}} +{{#isAlias}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isAlias}} +{{#isArrayModel}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}}{{#arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isArrayModel}} {{#requiredVars}} {{^defaultValue}} **{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 9fc3f83433..5186e6621f 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -1,4 +1,16 @@ allowed_values = { +{{#isEnum}} + ('value',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} {{#requiredVars}} {{#isEnum}} ('{{name}}',): { @@ -30,70 +42,24 @@ } validations = { +{{#isAlias}} +{{^isEnum}} +{{^isArrayModel}} + ('value',): { +{{> python-experimental/model_templates/validations }} +{{/isArrayModel}} +{{/isEnum}} +{{/isAlias}} {{#requiredVars}} {{#hasValidation}} ('{{name}}',): { -{{#maxLength}} - 'max_length': {{maxLength}}, -{{/maxLength}} -{{#minLength}} - 'min_length': {{minLength}}, -{{/minLength}} -{{#maxItems}} - 'max_items': {{maxItems}}, -{{/maxItems}} -{{#minItems}} - 'min_items': {{minItems}}, -{{/minItems}} -{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, -{{/maximum}} -{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, -{{/minimum}} -{{#pattern}} - 'regex': { - 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} - {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - }, -{{/pattern}} -{{#multipleOf}} - 'multiple_of': {{multipleOf}}, -{{/multipleOf}} - }, +{{> python-experimental/model_templates/validations }} {{/hasValidation}} {{/requiredVars}} {{#optionalVars}} {{#hasValidation}} ('{{name}}',): { -{{#maxLength}} - 'max_length': {{maxLength}}, -{{/maxLength}} -{{#minLength}} - 'min_length': {{minLength}}, -{{/minLength}} -{{#maxItems}} - 'max_items': {{maxItems}}, -{{/maxItems}} -{{#minItems}} - 'min_items': {{minItems}}, -{{/minItems}} -{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, -{{/maximum}} -{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, -{{/minimum}} -{{#pattern}} - 'regex': { - 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} - {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - }, -{{/pattern}} -{{#multipleOf}} - 'multiple_of': {{multipleOf}}, -{{/multipleOf}} - }, +{{> python-experimental/model_templates/validations }} {{/hasValidation}} {{/optionalVars}} } @@ -113,6 +79,15 @@ and the value is attribute type. """ return { +{{#isAlias}} + 'value': ({{{dataType}}},), +{{/isAlias}} +{{#isEnum}} + 'value': ({{{dataType}}},), +{{/isEnum}} +{{#isArrayModel}} + 'value': ({{{dataType}}},), +{{/isArrayModel}} {{#requiredVars}} '{{name}}': ({{{dataType}}},), # noqa: E501 {{/requiredVars}} diff --git a/python-experimental/model_templates/docstring_init_required_kwargs.mustache b/python-experimental/model_templates/docstring_init_required_kwargs.mustache new file mode 100644 index 0000000000..b09f3950b9 --- /dev/null +++ b/python-experimental/model_templates/docstring_init_required_kwargs.mustache @@ -0,0 +1,30 @@ + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) \ No newline at end of file diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index 9a3aeaefea..7faf7a30ee 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -9,6 +9,9 @@ {{> python-experimental/model_templates/method_init_shared }} +{{#isEnum}} + self.value = value +{{/isEnum}} {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} diff --git a/python-experimental/model_templates/method_init_shared.mustache b/python-experimental/model_templates/method_init_shared.mustache index 78059150f2..e500b11e70 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/python-experimental/model_templates/method_init_shared.mustache @@ -19,36 +19,7 @@ {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{/defaultValue}} {{/requiredVars}} - _check_type (bool): if True, values for parameters in openapi_types - will be type checked and a TypeError will be - raised if the wrong type is input. - Defaults to True - _path_to_item (tuple/list): This is a list of keys or values to - drill down to the model in received_data - when deserializing a response - _spec_property_naming (bool): True if the variable names in the input data - are serialized names, as specified in the OpenAPI document. - False if the variable names in the input data - are pythonic names, e.g. snake case (default) - _configuration (Configuration): the instance to use when - deserializing a file_type parameter. - If passed, type conversion is attempted - If omitted no type conversion is done. - _visited_composed_classes (tuple): This stores a tuple of - classes that we have traveled through so that - if we see that class again we will not use its - discriminator again. - When traveling through a discriminator, the - composed schema that is - is traveled through is added to this set. - For example if Animal has a discriminator - petType and we pass in "Dog", and the class Dog - allOf includes Animal, we move through Animal - once using the discriminator, and pick Dog. - Then in Dog, we will make an instance of the - Animal class but this time we won't travel - through its discriminator because we passed in - _visited_composed_classes = (Animal,) +{{> python-experimental/model_templates/docstring_init_required_kwargs }} {{#optionalVars}} {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 {{/optionalVars}} diff --git a/python-experimental/model_templates/method_init_simple.mustache b/python-experimental/model_templates/method_init_simple.mustache new file mode 100644 index 0000000000..9d59b7ba09 --- /dev/null +++ b/python-experimental/model_templates/method_init_simple.mustache @@ -0,0 +1,66 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self{{#hasRequired}}, value{{/hasRequired}}, *args, **kwargs): + """{{classname}} - a model defined in OpenAPI + +{{#hasRequired}} + Args: + value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + +{{/hasRequired}} + Keyword Args: +{{^hasRequired}} + value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/hasRequired}} +{{> python-experimental/model_templates/docstring_init_required_kwargs }} + """ + +{{^hasRequired}} + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = {{{defaultValue}}} +{{/hasRequired}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) \ No newline at end of file diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index bc582ff796..1623ca5f6e 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -15,4 +15,4 @@ class {{unescapedDescription}}(ModelSimple): _composed_schemas = None -{{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file +{{> python-experimental/model_templates/method_init_simple}} \ No newline at end of file diff --git a/python-experimental/model_templates/validations.mustache b/python-experimental/model_templates/validations.mustache new file mode 100644 index 0000000000..6b91bffe22 --- /dev/null +++ b/python-experimental/model_templates/validations.mustache @@ -0,0 +1,28 @@ +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} +{{#multipleOf}} + 'multiple_of': {{multipleOf}}, +{{/multipleOf}} + }, \ No newline at end of file diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 58859114bd..1323b72499 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -54,6 +54,58 @@ class cached_property(object): return result +PRIMITIVE_TYPES = (list, float, int, bool, datetime, date, str, file_type) + +def allows_single_value_input(cls): + """ + This function returns True if the input composed schema model or any + descendant model allows a value only input + This is true for cases where oneOf contains items like: + oneOf: + - float + - NumberWithValidation + - StringEnum + - ArrayModel + - null + TODO: lru_cache this + """ + if ( + issubclass(cls, ModelSimple) or + cls in PRIMITIVE_TYPES + ): + return True + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return False + return any(allows_single_value_input(c) for c in cls._composed_schemas['oneOf']) + return False + +def composed_model_input_classes(cls): + """ + This function returns a list of the possible models that can be accepted as + inputs. + TODO: lru_cache this + """ + if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES: + return [cls] + elif issubclass(cls, ModelNormal): + if cls.discriminator is None: + return [cls] + else: + return get_discriminated_classes(cls) + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return [] + if cls.discriminator is None: + input_classes = [] + for c in cls._composed_schemas['oneOf']: + input_classes.extend(composed_model_input_classes(c)) + return input_classes + else: + return get_discriminated_classes(cls) + return [] + + class OpenApiModel(object): """The base class for all OpenAPIModels""" @@ -66,9 +118,17 @@ class OpenApiModel(object): # pick a new schema/class to instantiate because a discriminator # propertyName value was passed in - if len(args) == 1 and args[0] is None and is_type_nullable(cls): - # The input data is the 'null' value and the type is nullable. - return None + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) if ( @@ -241,6 +301,10 @@ UPCONVERSION_TYPE_PAIRS = ( (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. (list, ModelComposed), (dict, ModelComposed), + (str, ModelComposed), + (int, ModelComposed), + (float, ModelComposed), + (list, ModelComposed), (list, ModelNormal), (dict, ModelNormal), (str, ModelSimple), @@ -619,20 +683,53 @@ def remove_uncoercible(required_types_classes, current_item, spec_property_namin results_classes.append(required_type_class) return results_classes +def get_discriminated_classes(cls): + """ + Returns all the classes that a discriminator converts to + TODO: lru_cache this + """ + possible_classes = [] + key = list(cls.discriminator.keys())[0] + if is_type_nullable(cls): + possible_classes.append(cls) + for discr_cls in cls.discriminator[key].values(): + if hasattr(discr_cls, 'discriminator') and discr_cls.discriminator is not None: + possible_classes.extend(get_discriminated_classes(discr_cls)) + else: + possible_classes.append(discr_cls) + return possible_classes + + +def get_possible_classes(cls, from_server_context): + # TODO: lru_cache this + possible_classes = [cls] + if from_server_context: + return possible_classes + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + possible_classes = [] + possible_classes.extend(get_discriminated_classes(cls)) + elif issubclass(cls, ModelComposed): + possible_classes.extend(composed_model_input_classes(cls)) + return possible_classes -def get_required_type_classes(required_types_mixed): + +def get_required_type_classes(required_types_mixed, spec_property_naming): """Converts the tuple required_types into a tuple and a dict described below Args: required_types_mixed (tuple/list): will contain either classes or instance of list or dict + spec_property_naming (bool): if True these values came from the + server, and we use the data types in our endpoints. + If False, we are client side and we need to include + oneOf and discriminator classes inside the data types in our endpoints Returns: (valid_classes, dict_valid_class_to_child_types_mixed): valid_classes (tuple): the valid classes that the current item should be - dict_valid_class_to_child_types_mixed (doct): + dict_valid_class_to_child_types_mixed (dict): valid_class (class): this is the key child_types_mixed (list/dict/tuple): describes the valid child types @@ -650,7 +747,7 @@ def get_required_type_classes(required_types_mixed): valid_classes.append(dict) child_req_types_by_current_type[dict] = required_type[str] else: - valid_classes.append(required_type) + valid_classes.extend(get_possible_classes(required_type, spec_property_naming)) return tuple(valid_classes), child_req_types_by_current_type @@ -803,7 +900,7 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, """Deserializes model_data to model instance. Args: - model_data (list/dict): data to instantiate the model + model_data (int/str/float/bool/none_type/list/dict): data to instantiate the model model_class (OpenApiModel): the model class path_to_item (list): path to the model in the received data check_type (bool): whether to check the data tupe for the values in @@ -829,14 +926,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _spec_property_naming=spec_property_naming) if issubclass(model_class, ModelSimple): - instance = model_class(value=model_data, **kw_args) - return instance - if isinstance(model_data, list): - instance = model_class(*model_data, **kw_args) + return model_class(model_data, **kw_args) + elif isinstance(model_data, list): + return model_class(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) - instance = model_class(**kw_args) - return instance + return model_class(**kw_args) + elif isinstance(model_data, PRIMITIVE_TYPES): + return model_class(model_data, **kw_args) def deserialize_file(response_data, configuration, content_disposition=None): @@ -1019,7 +1116,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, Raises: ApiTypeError """ - results = get_required_type_classes(required_types_mixed) + results = get_required_type_classes(required_types_mixed, spec_property_naming) valid_classes, child_req_types_by_current_type = results input_class_simple = get_simple_class(input_value) @@ -1256,7 +1353,7 @@ def get_allof_instances(self, model_args, constant_args): return composed_instances -def get_oneof_instance(self, model_args, constant_args): +def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): """ Find the oneOf schema that matches the input data (e.g. payload). If exactly one schema matches the input data, an instance of that schema @@ -1264,25 +1361,33 @@ def get_oneof_instance(self, model_args, constant_args): If zero or more than one schema match the input data, an exception is raised. In OAS 3.x, the payload MUST, by validation, match exactly one of the schemas described by oneOf. + Args: - self: the class we are handling - model_args (dict): var_name to var_value + cls: the class we are handling + model_kwargs (dict): var_name to var_value The input data, e.g. the payload that must match a oneOf schema in the OpenAPI document. - constant_args (dict): var_name to var_value + constant_kwargs (dict): var_name to var_value args that every model requires, including configuration, server and path to item. + Kwargs: + model_arg: (int, float, bool, str, date, datetime, ModelSimple, None): + the value to assign to a primitive class or ModelSimple class + Notes: + - this is only passed in when oneOf includes types which are not object + - None is used to suppress handling of model_arg, nullable models are handled in __new__ + Returns oneof_instance (instance) """ - if len(self._composed_schemas['oneOf']) == 0: + if len(cls._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in self._composed_schemas['oneOf']: + for oneof_class in cls._composed_schemas['oneOf']: # The composed oneOf schema allows the 'null' type and the input data # is the null value. This is a OAS >= 3.1 feature. if oneof_class is none_type: @@ -1290,28 +1395,45 @@ def get_oneof_instance(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_args, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] + single_value_input = allows_single_value_input(oneof_class) + + if not single_value_input: + # transform js keys from input data to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_kwargs, oneof_class) + + # Extract a dict with the properties that are declared in the oneOf schema. + # Undeclared properties (e.g. properties that are allowed because of the + # additionalProperties attribute in the OAS document) are not added to + # the dict. + kwargs = {} + var_names = set(oneof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # do not try to make a model with no input args + if len(kwargs) == 0: + continue - # do not try to make a model with no input args - if len(kwargs) == 0: - continue + # and use it to make the instance + kwargs.update(constant_kwargs) - # and use it to make the instance - kwargs.update(constant_args) try: - oneof_instance = oneof_class(**kwargs) + if not single_value_input: + oneof_instance = oneof_class(**kwargs) + else: + if issubclass(oneof_class, ModelSimple): + oneof_instance = oneof_class(model_arg, **constant_kwargs) + elif oneof_class in PRIMITIVE_TYPES: + oneof_instance = validate_and_convert_types( + model_arg, + (oneof_class,), + constant_kwargs['_path_to_item'], + constant_kwargs['_spec_property_naming'], + constant_kwargs['_check_type'], + configuration=constant_kwargs['_configuration'] + ) oneof_instances.append(oneof_instance) except Exception: pass @@ -1319,13 +1441,13 @@ def get_oneof_instance(self, model_args, constant_args): raise ApiValueError( "Invalid inputs given to generate an instance of %s. None " "of the oneOf schemas matched the input data." % - self.__class__.__name__ + cls.__name__ ) elif len(oneof_instances) > 1: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Multiple " "oneOf schemas matched the inputs, but a max of one is allowed." % - self.__class__.__name__ + cls.__name__ ) return oneof_instances[0] @@ -1465,7 +1587,7 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances = [] allof_instances = get_allof_instances(self, model_args, constant_args) composed_instances.extend(allof_instances) - oneof_instance = get_oneof_instance(self, model_args, constant_args) + oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args) if oneof_instance is not None: composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) From 145902c7902a3f80a835317c4497599e5fb048b3 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 19 Jul 2020 09:45:56 -0700 Subject: [PATCH 131/185] [python-experimental] Removes python2 (#6991) * Removes future from python-exp v3 sample * Removes future from python-exp v2 sample * Deletes future from remaining python-exp files * Removes six from python-exp templates * Removes six from python-exp samples * Removes mock from python-exp * Python-exp switched to py3 * Removes python 2.7 for python-exp ci testing * Requires python>=3.3 for python-exp * Reverts unnecessary changes to two templates --- python-experimental/README.mustache | 2 +- python-experimental/README_common.mustache | 1 - .../README_onlypackage.mustache | 1 - python-experimental/__init__api.mustache | 2 +- python-experimental/__init__package.mustache | 2 - python-experimental/api.mustache | 7 - python-experimental/api_client.mustache | 27 +- python-experimental/api_doc_example.mustache | 1 - python-experimental/api_test.mustache | 2 - python-experimental/configuration.mustache | 632 ++++++++++++++++++ python-experimental/exceptions.mustache | 129 ++++ python-experimental/gitlab-ci.mustache | 35 + python-experimental/model.mustache | 4 - .../method_init_composed.mustache | 2 +- .../method_init_normal.mustache | 2 +- .../methods_todict_tostr_eq_shared.mustache | 7 +- .../methods_tostr_eq_simple.mustache | 8 +- python-experimental/model_test.mustache | 1 - python-experimental/model_utils.mustache | 54 +- python-experimental/requirements.mustache | 2 - python-experimental/rest.mustache | 279 ++++++++ python-experimental/setup.mustache | 4 +- python-experimental/signing.mustache | 3 +- .../test-requirements.mustache | 7 +- python-experimental/tox.mustache | 9 + python-experimental/travis.mustache | 21 + 26 files changed, 1138 insertions(+), 106 deletions(-) create mode 100644 python-experimental/configuration.mustache create mode 100644 python-experimental/exceptions.mustache create mode 100644 python-experimental/gitlab-ci.mustache create mode 100644 python-experimental/rest.mustache create mode 100644 python-experimental/tox.mustache create mode 100644 python-experimental/travis.mustache diff --git a/python-experimental/README.mustache b/python-experimental/README.mustache index 72c7f3de3f..3fb507c574 100644 --- a/python-experimental/README.mustache +++ b/python-experimental/README.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python 2.7 and 3.4+ +Python 3.4+ ## Installation & Usage ### pip install diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index 0f6dcb41d6..b996e676d1 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -1,5 +1,4 @@ ```python -from __future__ import print_function {{#apiInfo}}{{#apis}}{{^hasMore}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/hasMore}}{{/apis}}{{/apiInfo}} import time import {{{packageName}}} diff --git a/python-experimental/README_onlypackage.mustache b/python-experimental/README_onlypackage.mustache index 11c002c9aa..ee90ce7903 100644 --- a/python-experimental/README_onlypackage.mustache +++ b/python-experimental/README_onlypackage.mustache @@ -26,7 +26,6 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: * urllib3 >= 1.15 -* six >= 1.10 * certifi * python-dateutil {{#asyncio}} diff --git a/python-experimental/__init__api.mustache b/python-experimental/__init__api.mustache index d37ee6c78b..1d37d33951 100644 --- a/python-experimental/__init__api.mustache +++ b/python-experimental/__init__api.mustache @@ -1,3 +1,3 @@ # do not import all apis into this module because that uses a lot of memory and stack frames -# if you need the ability to import all models from one package, import them with +# if you need the ability to import all apis from one package, import them with # from {{packageName}.apis import DefaultApi, PetApi \ No newline at end of file diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache index a949d50850..d0746d3aa6 100644 --- a/python-experimental/__init__package.mustache +++ b/python-experimental/__init__package.mustache @@ -4,8 +4,6 @@ {{>partial_header}} -from __future__ import absolute_import - __version__ = "{{packageVersion}}" # import ApiClient diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index ad5decabf0..776acbf5ec 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -2,14 +2,9 @@ {{>partial_header}} -from __future__ import absolute_import - import re # noqa: F401 import sys # noqa: F401 -# python 2 and python 3 compatibility library -import six - from {{packageName}}.api_client import ApiClient, Endpoint from {{packageName}}.model_utils import ( # noqa: F401 check_allowed_values, @@ -17,9 +12,7 @@ from {{packageName}}.model_utils import ( # noqa: F401 date, datetime, file_type, - int, none_type, - str, validate_and_convert_types ) {{#imports}} diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index d3b0b6f60e..b7112d202b 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -1,6 +1,5 @@ # coding: utf-8 {{>partial_header}} -from __future__ import absolute_import import json import atexit @@ -8,10 +7,8 @@ import mimetypes from multiprocessing.pool import ThreadPool import os import re +from urllib.parse import quote -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import quote {{#tornado}} import tornado.gen {{/tornado}} @@ -29,10 +26,8 @@ from {{packageName}}.model_utils import ( datetime, deserialize_file, file_type, - int, model_to_dict, none_type, - str, validate_and_convert_types ) @@ -59,10 +54,8 @@ class ApiClient(object): to the API. More threads means more concurrent API requests. """ - # six.binary_type python2=str, python3=bytes - # six.text_type python2=unicode, python3=str PRIMITIVE_TYPES = ( - (float, bool, six.binary_type, six.text_type) + six.integer_types + float, bool, bytes, str, int ) _pool = None @@ -189,7 +182,7 @@ class ApiClient(object): _preload_content=_preload_content, _request_timeout=_request_timeout) except ApiException as e: - e.body = e.body.decode('utf-8') if six.PY3 else e.body + e.body = e.body.decode('utf-8') raise e content_type = response_data.getheader('content-type') @@ -207,7 +200,7 @@ class ApiClient(object): {{/tornado}} return return_data - if six.PY3 and response_type not in ["file", "bytes"]: + if response_type not in ["file", "bytes"]: match = None if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) @@ -277,7 +270,7 @@ class ApiClient(object): return self.sanitize_for_serialization(obj.value) return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} + for key, val in obj_dict.items()} def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. @@ -477,7 +470,7 @@ class ApiClient(object): new_params = [] if collection_formats is None: collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': @@ -508,7 +501,7 @@ class ApiClient(object): return [] params = [] - for param_name, file_instances in six.iteritems(files): + for param_name, file_instances in files.items(): if file_instances is None: # if the file field is nullable, skip None values continue @@ -692,7 +685,7 @@ class Endpoint(object): if kwargs['_check_input_type'] is False: return - for key, value in six.iteritems(kwargs): + for key, value in kwargs.items(): fixed_val = validate_and_convert_types( value, self.openapi_types[key], @@ -714,7 +707,7 @@ class Endpoint(object): 'query': [] } - for param_name, param_value in six.iteritems(kwargs): + for param_name, param_value in kwargs.items(): param_location = self.location_map.get(param_name) if param_location is None: continue @@ -772,7 +765,7 @@ class Endpoint(object): ) _host = None - for key, value in six.iteritems(kwargs): + for key, value in kwargs.items(): if key not in self.params_map['all']: raise ApiTypeError( "Got an unexpected parameter '%s'" diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index 23cf85e9df..b7bbc009f5 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -1,5 +1,4 @@ ```python -from __future__ import print_function import time import {{{packageName}}} from {{apiPackage}} import {{classVarName}} diff --git a/python-experimental/api_test.mustache b/python-experimental/api_test.mustache index e04b32f96e..f9276b443c 100644 --- a/python-experimental/api_test.mustache +++ b/python-experimental/api_test.mustache @@ -2,8 +2,6 @@ {{>partial_header}} -from __future__ import absolute_import - import unittest import {{packageName}} diff --git a/python-experimental/configuration.mustache b/python-experimental/configuration.mustache new file mode 100644 index 0000000000..8b911bdddd --- /dev/null +++ b/python-experimental/configuration.mustache @@ -0,0 +1,632 @@ +# coding: utf-8 + +{{>partial_header}} + +import copy +import logging +{{^asyncio}} +import multiprocessing +{{/asyncio}} +import sys +import urllib3 + +from http import client as http_client +from {{packageName}}.exceptions import ApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. +{{#hasHttpSignatureMethods}} + :param signing_info: Configuration parameters for the HTTP signature security scheme. + Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration +{{/hasHttpSignatureMethods}} + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + +{{#hasAuthMethods}} + :Example: +{{#hasApiKeyMethods}} + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = {{{packageName}}}.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 +{{/hasApiKeyMethods}} +{{#hasHttpBasicMethods}} + + HTTP Basic Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: basic + + Configure API client with HTTP basic authentication: + +conf = {{{packageName}}}.Configuration( + username='the-user', + password='the-password', +) + +{{/hasHttpBasicMethods}} +{{#hasHttpSignatureMethods}} + + HTTP Signature Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: signature + + Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, + sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time + of the signature to 5 minutes after the signature has been created. + Note you can use the constants defined in the {{{packageName}}}.signing module, and you can + also specify arbitrary HTTP headers to be included in the HTTP signature, except for the + 'Authorization' header, which is used to carry the signature. + + One may be tempted to sign all headers by default, but in practice it rarely works. + This is beccause explicit proxies, transparent proxies, TLS termination endpoints or + load balancers may add/modify/remove headers. Include the HTTP headers that you know + are not going to be modified in transit. + +conf = {{{packageName}}}.Configuration( + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS, + signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET, + {{{packageName}}}.signing.HEADER_CREATED, + {{{packageName}}}.signing.HEADER_EXPIRES, + {{{packageName}}}.signing.HEADER_HOST, + {{{packageName}}}.signing.HEADER_DATE, + {{{packageName}}}.signing.HEADER_DIGEST, + 'Content-Type', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) +{{/hasHttpSignatureMethods}} +{{/hasAuthMethods}} + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", +{{#hasHttpSignatureMethods}} + signing_info=None, +{{/hasHttpSignatureMethods}} + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ): + """Constructor + """ + self._base_path = "{{{basePath}}}" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations +{{#hasHttpSignatureMethods}} + if signing_info is not None: + signing_info.host = host + self.signing_info = signing_info + """The HTTP signing configuration + """ +{{/hasHttpSignatureMethods}} +{{#hasOAuthMethods}} + self.access_token = None + """access token for OAuth/Bearer + """ +{{/hasOAuthMethods}} +{{^hasOAuthMethods}} +{{#hasBearerMethods}} + self.access_token = None + """access token for OAuth/Bearer + """ +{{/hasBearerMethods}} +{{/hasOAuthMethods}} + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("{{packageName}}") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = None + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + {{#asyncio}} + self.connection_pool_maxsize = 100 + """This value is passed to the aiohttp to limit simultaneous connections. + Default values is 100, None means no-limit. + """ + {{/asyncio}} + {{^asyncio}} + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + {{/asyncio}} + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s +{{#hasHttpSignatureMethods}} + if name == "signing_info" and value is not None: + # Ensure the host paramater from signing info is the same as + # Configuration.host. + value.host = self.host +{{/hasHttpSignatureMethods}} + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} +{{#authMethods}} +{{#isApiKey}} + if '{{name}}' in self.api_key{{#vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/vendorExtensions.x-auth-id-alias}}: + auth['{{name}}'] = { + 'type': 'api_key', + 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix( + '{{name}}',{{#vendorExtensions.x-auth-id-alias}} + alias='{{.}}',{{/vendorExtensions.x-auth-id-alias}} + ), + } +{{/isApiKey}} +{{#isBasic}} + {{#isBasicBasic}} + if self.username is not None and self.password is not None: + auth['{{name}}'] = { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + } + {{/isBasicBasic}} + {{#isBasicBearer}} + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'bearer', + 'in': 'header', + {{#bearerFormat}} + 'format': '{{{.}}}', + {{/bearerFormat}} + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } + {{/isBasicBearer}} + {{#isHttpSignature}} + if self.signing_info is not None: + auth['{{name}}'] = { + 'type': 'http-signature', + 'in': 'header', + 'key': 'Authorization', + 'value': None # Signature headers are calculated for every HTTP request + } + {{/isHttpSignature}} +{{/isBasic}} +{{#isOAuth}} + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } +{{/isOAuth}} +{{/authMethods}} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: {{version}}\n"\ + "SDK Package Version: {{packageVersion}}".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + {{#servers}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }{{^-last}},{{/-last}} + {{/servers}} + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/python-experimental/exceptions.mustache b/python-experimental/exceptions.mustache new file mode 100644 index 0000000000..8d445c6e24 --- /dev/null +++ b/python-experimental/exceptions.mustache @@ -0,0 +1,129 @@ +# coding: utf-8 + +{{>partial_header}} + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/python-experimental/gitlab-ci.mustache b/python-experimental/gitlab-ci.mustache new file mode 100644 index 0000000000..a626e9c084 --- /dev/null +++ b/python-experimental/gitlab-ci.mustache @@ -0,0 +1,35 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.nosetest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + {{#useNose}} + - nosetests + {{/useNose}} + {{^useNose}} + - pytest --cov={{{packageName}}} + {{/useNose}} + +nosetest-3.3: + extends: .nosetest + image: python:3.3-alpine +nosetest-3.4: + extends: .nosetest + image: python:3.4-alpine +nosetest-3.5: + extends: .nosetest + image: python:3.5-alpine +nosetest-3.6: + extends: .nosetest + image: python:3.6-alpine +nosetest-3.7: + extends: .nosetest + image: python:3.7-alpine +nosetest-3.8: + extends: .nosetest + image: python:3.8-alpine diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index e89b3d5633..ad7d5ddb31 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -2,11 +2,9 @@ {{>partial_header}} -from __future__ import absolute_import import re # noqa: F401 import sys # noqa: F401 -import six # noqa: F401 import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 @@ -20,9 +18,7 @@ from {{packageName}}.model_utils import ( # noqa: F401 date, datetime, file_type, - int, none_type, - str, validate_get_composed_info, ) {{#models}} diff --git a/python-experimental/model_templates/method_init_composed.mustache b/python-experimental/model_templates/method_init_composed.mustache index 67750cb17a..7e64549acd 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/python-experimental/model_templates/method_init_composed.mustache @@ -41,7 +41,7 @@ for var_name, var_value in required_args.items(): setattr(self, var_name, var_value) - for var_name, var_value in six.iteritems(kwargs): + for var_name, var_value in kwargs.items(): if var_name in unused_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ diff --git a/python-experimental/model_templates/method_init_normal.mustache b/python-experimental/model_templates/method_init_normal.mustache index 7faf7a30ee..4fee1c8449 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/python-experimental/model_templates/method_init_normal.mustache @@ -15,7 +15,7 @@ {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} - for var_name, var_value in six.iteritems(kwargs): + for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ diff --git a/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache b/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache index d01d49ad77..17c441196a 100644 --- a/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache +++ b/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache @@ -13,17 +13,12 @@ if not set(self._data_store.keys()) == set(other._data_store.keys()): return False - for _var_name, this_val in six.iteritems(self._data_store): + for _var_name, this_val in self._data_store.items(): that_val = other._data_store[_var_name] types = set() types.add(this_val.__class__) types.add(that_val.__class__) vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) if not vals_equal: return False return True \ No newline at end of file diff --git a/python-experimental/model_templates/methods_tostr_eq_simple.mustache b/python-experimental/model_templates/methods_tostr_eq_simple.mustache index 0bba565d22..4a7ef6ae5c 100644 --- a/python-experimental/model_templates/methods_tostr_eq_simple.mustache +++ b/python-experimental/model_templates/methods_tostr_eq_simple.mustache @@ -13,10 +13,4 @@ types.add(this_val.__class__) types.add(that_val.__class__) vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True \ No newline at end of file + return vals_equal \ No newline at end of file diff --git a/python-experimental/model_test.mustache b/python-experimental/model_test.mustache index 5b9a91d2d0..c5ffe2c255 100644 --- a/python-experimental/model_test.mustache +++ b/python-experimental/model_test.mustache @@ -2,7 +2,6 @@ {{>partial_header}} -from __future__ import absolute_import import sys import unittest diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 1323b72499..ab30c2dcb0 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -4,13 +4,13 @@ from datetime import date, datetime # noqa: F401 import inspect +import io import os import pprint import re import tempfile from dateutil.parser import parse -import six from {{packageName}}.exceptions import ( ApiKeyError, @@ -20,20 +20,7 @@ from {{packageName}}.exceptions import ( ) none_type = type(None) -if six.PY3: - import io - file_type = io.IOBase - # these are needed for when other modules import str and int from here - str = str - int = int -else: - file_type = file # noqa: F821 - str_py2 = str - unicode_py2 = unicode # noqa: F821 - long_py2 = long # noqa: F821 - int_py2 = int - # this requires that the future library is installed - from builtins import int, str +file_type = io.IOBase class cached_property(object): @@ -380,8 +367,6 @@ def get_simple_class(input_value): # isinstance(True, int) == True return bool elif isinstance(input_value, int): - # for python2 input_value==long_instance -> return int - # where int is the python3 int backport return int elif isinstance(input_value, datetime): # this must be higher than the date check because @@ -389,8 +374,7 @@ def get_simple_class(input_value): return datetime elif isinstance(input_value, date): return date - elif (six.PY2 and isinstance(input_value, (str_py2, unicode_py2, str)) or - isinstance(input_value, str)): + elif isinstance(input_value, str): return str return type(input_value) @@ -835,12 +819,12 @@ def deserialize_primitive(data, klass, path_to_item): return converted_value except (OverflowError, ValueError) as ex: # parse can raise OverflowError - six.raise_from(ApiValueError( + raise ApiValueError( "{0}Failed to parse {1} as {2}".format( - additional_message, repr(data), get_py3_class_name(klass) + additional_message, repr(data), klass.__name__ ), path_to_item=path_to_item - ), ex) + ) from ex def get_discriminator_class(model_class, @@ -964,8 +948,8 @@ def deserialize_file(response_data, configuration, content_disposition=None): path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: - if six.PY3 and isinstance(response_data, str): - # in python3 change str to bytes so we can write it + if isinstance(response_data, str): + # change str to bytes so we can write it response_data = response_data.encode('utf-8') f.write(response_data) @@ -1184,7 +1168,7 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, if input_value == {}: # allow an empty dict return input_value - for inner_key, inner_val in six.iteritems(input_value): + for inner_key, inner_val in input_value.items(): inner_path = list(path_to_item) inner_path.append(inner_key) if get_simple_class(inner_key) != str: @@ -1218,7 +1202,7 @@ def model_to_dict(model_instance, serialize=True): if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: - for attr, value in six.iteritems(model_instance._data_store): + for attr, value in model_instance._data_store.items(): if serialize: # we use get here because additional property key names do not # exist in attribute_map @@ -1275,13 +1259,8 @@ def type_error_message(var_value=None, var_name=None, valid_classes=None, def get_valid_classes_phrase(input_classes): """Returns a string phrase describing what types are allowed - Note: Adds the extra valid classes in python2 """ all_classes = list(input_classes) - if six.PY2 and str in input_classes: - all_classes.extend([str_py2, unicode_py2]) - if six.PY2 and int in input_classes: - all_classes.extend([int_py2, long_py2]) all_classes = sorted(all_classes, key=lambda cls: cls.__name__) all_class_names = [cls.__name__ for cls in all_classes] if len(all_class_names) == 1: @@ -1289,15 +1268,6 @@ def get_valid_classes_phrase(input_classes): return "is one of [{0}]".format(", ".join(all_class_names)) -def get_py3_class_name(input_class): - if six.PY2: - if input_class == str: - return 'str' - elif input_class == int: - return 'int' - return input_class.__name__ - - def convert_js_args_to_python_args(fn): from functools import wraps @wraps(fn) @@ -1340,7 +1310,7 @@ def get_allof_instances(self, model_args, constant_args): allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: - six.raise_from(ApiValueError( + raise ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( @@ -1349,7 +1319,7 @@ def get_allof_instances(self, model_args, constant_args): self.__class__.__name__, str(ex) ) - ), ex) + ) from ex return composed_instances diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache index a56bedffbf..2c2f00fcb2 100644 --- a/python-experimental/requirements.mustache +++ b/python-experimental/requirements.mustache @@ -1,7 +1,5 @@ nulltype certifi >= 14.05.14 -future; python_version<="2.7" -six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.15.1 diff --git a/python-experimental/rest.mustache b/python-experimental/rest.mustache new file mode 100644 index 0000000000..d5edf9535d --- /dev/null +++ b/python-experimental/rest.mustache @@ -0,0 +1,279 @@ +# coding: utf-8 + +{{>partial_header}} + +import io +import json +import logging +import re +import ssl +from urllib.parse import urlencode + +import certifi +import urllib3 + +from {{packageName}}.exceptions import ApiException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.getheaders() + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.getheader(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, int): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if query_params: + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 796475c456..b3c89f621e 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -18,7 +18,6 @@ VERSION = "{{packageVersion}}" REQUIRES = [ "urllib3 >= 1.15", - "six >= 1.10", "certifi", "python-dateutil", "nulltype", @@ -33,7 +32,6 @@ REQUIRES = [ "pycryptodome>=3.9.0", {{/hasHttpSignatureMethods}} ] -EXTRAS = {':python_version <= "2.7"': ['future']} setup( name=NAME, @@ -43,8 +41,8 @@ setup( author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], + python_requires=">=3.3", install_requires=REQUIRES, - extras_require=EXTRAS, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, {{#licenseInfo}}license="{{licenseInfo}}", diff --git a/python-experimental/signing.mustache b/python-experimental/signing.mustache index 0be0e1c467..26d2b8cb37 100644 --- a/python-experimental/signing.mustache +++ b/python-experimental/signing.mustache @@ -1,6 +1,5 @@ # coding: utf-8 {{>partial_header}} -from __future__ import absolute_import from base64 import b64encode from Crypto.IO import PEM, PKCS8 @@ -11,8 +10,8 @@ from email.utils import formatdate import json import os import re -from six.moves.urllib.parse import urlencode, urlparse from time import time +from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the # HTTP signature scheme. Additional headers may be included in the signature. diff --git a/python-experimental/test-requirements.mustache b/python-experimental/test-requirements.mustache index ebdee3392e..cc68f6484f 100644 --- a/python-experimental/test-requirements.mustache +++ b/python-experimental/test-requirements.mustache @@ -6,11 +6,10 @@ py>=1.4.31 randomize>=0.13 {{/useNose}} {{^useNose}} -pytest~=4.6.7 # needed for python 2.7+3.4 +pytest~=4.6.7 # needed for python 3.4 pytest-cov>=2.8.1 -pytest-randomly==1.2.3 # needed for python 2.7+3.4 +pytest-randomly==1.2.3 # needed for python 3.4 {{/useNose}} {{#hasHttpSignatureMethods}} pycryptodome>=3.9.0 -{{/hasHttpSignatureMethods}} -mock; python_version<="2.7" \ No newline at end of file +{{/hasHttpSignatureMethods}} \ No newline at end of file diff --git a/python-experimental/tox.mustache b/python-experimental/tox.mustache new file mode 100644 index 0000000000..4c771c472b --- /dev/null +++ b/python-experimental/tox.mustache @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + {{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} diff --git a/python-experimental/travis.mustache b/python-experimental/travis.mustache new file mode 100644 index 0000000000..77f7289f97 --- /dev/null +++ b/python-experimental/travis.mustache @@ -0,0 +1,21 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.6" + - "3.7" + - "3.8" +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +{{#useNose}} +script: nosetests +{{/useNose}} +{{^useNose}} +script: pytest --cov={{{packageName}}} +{{/useNose}} From 8d442c92ae1cb651e009af90e97bdd60079b6200 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 27 Jul 2020 18:35:41 -0700 Subject: [PATCH 132/185] Python-exp clean up model classnames (#7054) * Adds lazy_import, removes python-exp java class renaming code, partial removal of getPythonClassName call sites Fixes PythonClientExperimentalTest.java Python-exp smaples regeneration Revers makefile Reverst pom.xml Fixes model imports in models.__init__ Updates docstring, omits lazy import in additional properties if we dont need it Improves additional_properties_type assignment if None Removes getPythonClassName Fixes python-exp tests * Removes unused makefiles --- python-experimental/README_common.mustache | 2 +- python-experimental/__init__models.mustache | 2 +- python-experimental/model.mustache | 6 ++- .../model_templates/classvars.mustache | 42 +++++++++++++++++-- .../model_templates/model_composed.mustache | 7 +++- .../model_templates/model_normal.mustache | 2 +- .../model_templates/model_simple.mustache | 2 +- python-experimental/model_utils.mustache | 4 +- 8 files changed, 55 insertions(+), 12 deletions(-) diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index b996e676d1..d3844fd15f 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -47,7 +47,7 @@ Class | Method | HTTP request | Description ## Documentation For Models -{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{unescapedDescription}}}.md) +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) {{/model}}{{/models}} ## Documentation For Authorization diff --git a/python-experimental/__init__models.mustache b/python-experimental/__init__models.mustache index abe69dc035..5a2f25f875 100644 --- a/python-experimental/__init__models.mustache +++ b/python-experimental/__init__models.mustache @@ -13,6 +13,6 @@ {{#models}} {{#model}} -from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} +from {{modelPackage}}.{{classFilename}} import {{classname}} {{/model}} {{/models}} diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index ad7d5ddb31..1a181b824d 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -24,7 +24,11 @@ from {{packageName}}.model_utils import ( # noqa: F401 {{#models}} {{#model}} {{#imports}} -{{{.}}} +{{#-first}} + +def lazy_import(): +{{/-first}} + {{{.}}} {{/imports}} diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 5186e6621f..ed121c5bfe 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -64,20 +64,41 @@ {{/optionalVars}} } - additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} +{{#additionalPropertiesType}} + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} + return ({{{additionalPropertiesType}}},) # noqa: E501 +{{/additionalPropertiesType}} +{{^additionalPropertiesType}} + additional_properties_type = None +{{/additionalPropertiesType}} _nullable = {{#isNullable}}True{{/isNullable}}{{^isNullable}}False{{/isNullable}} @cached_property def openapi_types(): """ - This must be a class method so a model may have properties that are - of type self, this ensures that we don't create a cyclic import + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type. """ +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} return { {{#isAlias}} 'value': ({{{dataType}}},), @@ -98,7 +119,20 @@ @cached_property def discriminator(): - {{^discriminator}}return None{{/discriminator}}{{#discriminator}}val = { +{{^discriminator}} + return None +{{/discriminator}} +{{#discriminator}} +{{#mappedModels}} +{{#-first}} +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} +{{/-first}} +{{/mappedModels}} + val = { {{#mappedModels}} '{{mappingName}}': {{{modelName}}}, {{/mappedModels}} diff --git a/python-experimental/model_templates/model_composed.mustache b/python-experimental/model_templates/model_composed.mustache index 7e9e86cbfc..dd61b23c79 100644 --- a/python-experimental/model_templates/model_composed.mustache +++ b/python-experimental/model_templates/model_composed.mustache @@ -1,4 +1,4 @@ -class {{unescapedDescription}}(ModelComposed): +class {{classname}}(ModelComposed): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -35,6 +35,11 @@ class {{unescapedDescription}}(ModelComposed): # code would be run when this module is imported, and these composed # classes don't exist yet because their module has not finished # loading +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} return { 'anyOf': [ {{#anyOf}} diff --git a/python-experimental/model_templates/model_normal.mustache b/python-experimental/model_templates/model_normal.mustache index 21254c55d1..af130c66a7 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/python-experimental/model_templates/model_normal.mustache @@ -1,4 +1,4 @@ -class {{unescapedDescription}}(ModelNormal): +class {{classname}}(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech diff --git a/python-experimental/model_templates/model_simple.mustache b/python-experimental/model_templates/model_simple.mustache index 1623ca5f6e..0b7d1860dd 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/python-experimental/model_templates/model_simple.mustache @@ -1,4 +1,4 @@ -class {{unescapedDescription}}(ModelSimple): +class {{classname}}(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index ab30c2dcb0..400cfe3509 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -33,9 +33,9 @@ class cached_property(object): self._fn = fn def __get__(self, instance, cls=None): - try: + if self.result_key in vars(self): return vars(self)[self.result_key] - except KeyError: + else: result = self._fn() setattr(self, self.result_key, result) return result From 9302ebe9e82aa06392aa3f56bbcebe1559db515d Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 28 Jul 2020 08:16:19 -0700 Subject: [PATCH 133/185] [python-experimental] simplifies json serialization (#7061) * Requires python >= 3.5, adds type hints to call_api method * Adds type hints to files_parameters and __call_api * Adds and uses a new json encoded to prepare data before it is sent * Removes nose name from gitlab testing invocations * Also updates travis to py>=3.5 * Collapses encoder back into sanitize_for_serialization --- python-experimental/README.mustache | 2 +- .../README_onlypackage.mustache | 2 +- python-experimental/api_client.mustache | 97 +++++++++++-------- python-experimental/gitlab-ci.mustache | 24 ++--- python-experimental/setup.mustache | 2 +- python-experimental/travis.mustache | 3 - 6 files changed, 67 insertions(+), 63 deletions(-) diff --git a/python-experimental/README.mustache b/python-experimental/README.mustache index 3fb507c574..7368913ef8 100644 --- a/python-experimental/README.mustache +++ b/python-experimental/README.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python 3.4+ +Python >= 3.5 ## Installation & Usage ### pip install diff --git a/python-experimental/README_onlypackage.mustache b/python-experimental/README_onlypackage.mustache index ee90ce7903..3ef048b67a 100644 --- a/python-experimental/README_onlypackage.mustache +++ b/python-experimental/README_onlypackage.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python 2.7 and 3.4+ +Python >= 3.5 ## Installation & Usage diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index b7112d202b..de4e2d478e 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -5,8 +5,10 @@ import json import atexit import mimetypes from multiprocessing.pool import ThreadPool +import io import os import re +import typing from urllib.parse import quote {{#tornado}} @@ -54,9 +56,6 @@ class ApiClient(object): to the API. More threads means more concurrent API requests. """ - PRIMITIVE_TYPES = ( - float, bool, bytes, str, int - ) _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, @@ -114,12 +113,24 @@ class ApiClient(object): @tornado.gen.coroutine {{/tornado}} {{#asyncio}}async {{/asyncio}}def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None, - _check_type=None): + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): config = self.configuration @@ -232,9 +243,9 @@ class ApiClient(object): response_data.getheaders())) {{/tornado}} - def sanitize_for_serialization(self, obj): + @classmethod + def sanitize_for_serialization(cls, obj): """Builds a JSON POST object. - If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date @@ -242,35 +253,24 @@ class ApiClient(object): If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. - :param obj: The data to serialize. :return: The serialized form of data. """ - if obj is None: - return None - elif isinstance(obj, self.PRIMITIVE_TYPES): + if isinstance(obj, (ModelNormal, ModelComposed)): + return { + key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() + } + elif isinstance(obj, (str, int, float, none_type, bool)): return obj - elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] - elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) elif isinstance(obj, (datetime, date)): return obj.isoformat() - - if isinstance(obj, dict): - obj_dict = obj - elif isinstance(obj, ModelNormal) or isinstance(obj, ModelComposed): - # Convert model obj to dict - # Convert attribute name to json key in - # model definition for request - obj_dict = model_to_dict(obj, serialize=True) elif isinstance(obj, ModelSimple): - return self.sanitize_for_serialization(obj.value) - - return {key: self.sanitize_for_serialization(val) - for key, val in obj_dict.items()} + return cls.sanitize_for_serialization(obj.value) + elif isinstance(obj, (list, tuple)): + return [cls.sanitize_for_serialization(item) for item in obj] + if isinstance(obj, dict): + return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. @@ -317,13 +317,26 @@ class ApiClient(object): ) return deserialized_data - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None, - _check_type=None): + def call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -490,7 +503,7 @@ class ApiClient(object): new_params.append((k, v)) return new_params - def files_parameters(self, files=None): + def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): """Builds form parameters. :param files: None or a dict with key=param_name and @@ -566,7 +579,7 @@ class ApiClient(object): :param resource_path: A string representation of the HTTP request resource path. :param method: A string representation of the HTTP request method. :param body: A object representing the body of the HTTP request. - The object type is the return value of sanitize_for_serialization(). + The object type is the return value of _encoder.default(). """ if not auth_settings: return diff --git a/python-experimental/gitlab-ci.mustache b/python-experimental/gitlab-ci.mustache index a626e9c084..60c4b37893 100644 --- a/python-experimental/gitlab-ci.mustache +++ b/python-experimental/gitlab-ci.mustache @@ -3,7 +3,7 @@ stages: - test -.nosetest: +.tests: stage: test script: - pip install -r requirements.txt @@ -15,21 +15,15 @@ stages: - pytest --cov={{{packageName}}} {{/useNose}} -nosetest-3.3: - extends: .nosetest - image: python:3.3-alpine -nosetest-3.4: - extends: .nosetest - image: python:3.4-alpine -nosetest-3.5: - extends: .nosetest +test-3.5: + extends: .tests image: python:3.5-alpine -nosetest-3.6: - extends: .nosetest +test-3.6: + extends: .tests image: python:3.6-alpine -nosetest-3.7: - extends: .nosetest +test-3.7: + extends: .tests image: python:3.7-alpine -nosetest-3.8: - extends: .nosetest +test-3.8: + extends: .tests image: python:3.8-alpine diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index b3c89f621e..4c3e32ef7d 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -41,7 +41,7 @@ setup( author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], - python_requires=">=3.3", + python_requires=">=3.5", install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, diff --git a/python-experimental/travis.mustache b/python-experimental/travis.mustache index 77f7289f97..3c255f64e9 100644 --- a/python-experimental/travis.mustache +++ b/python-experimental/travis.mustache @@ -1,9 +1,6 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "3.2" - - "3.3" - - "3.4" - "3.5" - "3.6" - "3.7" From bb80c9c79229b110305935a9d8d65cfced2d07a9 Mon Sep 17 00:00:00 2001 From: Christian Gibson Date: Mon, 10 Aug 2020 13:11:29 -0700 Subject: [PATCH 134/185] [python{,-experimental}] Obey floating point timeouts provided to RESTClientObject.request(...) (#7154) * [fix] support floating point timeout durations * [lint] generate samples, rebuild project --- python-experimental/rest.mustache | 2 +- rest.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python-experimental/rest.mustache b/python-experimental/rest.mustache index d5edf9535d..746f984434 100644 --- a/python-experimental/rest.mustache +++ b/python-experimental/rest.mustache @@ -129,7 +129,7 @@ class RESTClientObject(object): timeout = None if _request_timeout: - if isinstance(_request_timeout, int): # noqa: E501,F821 + if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): diff --git a/rest.mustache b/rest.mustache index fe7abfdfc0..51f72f6e1f 100644 --- a/rest.mustache +++ b/rest.mustache @@ -133,7 +133,7 @@ class RESTClientObject(object): timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): From a5e3e523ea6955e35681dd5e6265bdaec5c0ef40 Mon Sep 17 00:00:00 2001 From: TIm Clark Date: Tue, 11 Aug 2020 21:38:58 -0400 Subject: [PATCH 135/185] [python-experimental] Fix model tests (#7139) * [python-experimental] Fix model tests * Fixes model tests to template off the classname instead of the model's description. * Uses python-experimental templates when generating python-experimental samples * Fix sample file manifest * Restore remaining tests --- python-experimental/model_test.mustache | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python-experimental/model_test.mustache b/python-experimental/model_test.mustache index c5ffe2c255..669cc12185 100644 --- a/python-experimental/model_test.mustache +++ b/python-experimental/model_test.mustache @@ -11,11 +11,11 @@ import {{packageName}} {{#imports}} {{{.}}} {{/imports}} -from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} +from {{modelPackage}}.{{classFilename}} import {{classname}} -class Test{{unescapedDescription}}(unittest.TestCase): - """{{unescapedDescription}} unit test stubs""" +class Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" def setUp(self): pass @@ -23,10 +23,10 @@ class Test{{unescapedDescription}}(unittest.TestCase): def tearDown(self): pass - def test{{unescapedDescription}}(self): - """Test {{unescapedDescription}}""" + def test{{classname}}(self): + """Test {{classname}}""" # FIXME: construct object with mandatory attributes with example values - # model = {{unescapedDescription}}() # noqa: E501 + # model = {{classname}}() # noqa: E501 pass {{/model}} From 12266062043bf9b30392c31ae8f832e6042cb899 Mon Sep 17 00:00:00 2001 From: spacether Date: Wed, 19 Aug 2020 21:27:31 -0700 Subject: [PATCH 136/185] [python-exp] simplify examples (#7157) * Adds example setting code in python-experimental with one fn setting example values Fixes sample indentations Handles composed schema models, object model and arraymodels Adds brackets in arraymodel input Sets modelName with map schemas Removes included_schemas arguments, dicriminator examples do not include property examples Refactors modelName into toExampleValueRecursive argument Fixes bug where example models contained themselves Stops using model ExampleGenerator examples because they are inconsistent with the ones in python-experimental Uses example values if they exist Removes single quotes from enum examples Fixes password example Adds commented our regex handling, commented out because it breaks Handles AnyType schema examples Adds x_example values for simple string properties, uses toExampleValue for all example generation Adds examples for simple string parameters Updates comments in toExampleValueBase Fixes the double nested bug for AdditionalPropertiesWithArrayOfEnums Fixes bug where NumberWithValidations had double nesting Updates simple string examples in arrays Fixes array string examples Fixes example for string endpoint body example Adds exampleFromStringOrArraySchema Adds regex examples, pegs slf4j-version to v1.7.29 for rgxgen Adds comment about regex seed Updates pattern matcher to not handle ^ and $ Updates used sample values Adds ensureQuotes Adds ensureQuotes Fixes double quote bug Updates mustache file Adds ensureQuotes to key handling Adds modelNameToSchema map, reduces run time by using it Fixes java tests Regenerates python-experimental samples Fixes python test * Rebased on master * Adds getModelNameToSchemaCache * Updates toDefaultValue to not mutate schemas * Has all dates and datetimes default and example setting use the same helper function * Samples regenerated * indentation tweak, removes txt from sample file --- python-experimental/api_doc_example.mustache | 65 ++++++++++++-------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index b7bbc009f5..38d50dbd7c 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -16,44 +16,61 @@ with {{{packageName}}}.ApiClient() as api_client: {{/hasAuthMethods}} # Create an instance of the API class api_instance = {{classVarName}}.{{{classname}}}(api_client) - {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} - {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} - {{/optionalParams}} - {{#requiredParams}} - {{^hasMore}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/defaultValue}} +{{/requiredParams}} +{{#optionalParams}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} +{{/optionalParams}} +{{#requiredParams}} +{{^hasMore}} # example passing only required values which don't have defaults set try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/hasMore}} - {{/requiredParams}} - {{#optionalParams}} - {{^hasMore}} +{{/hasMore}} +{{/requiredParams}} +{{#optionalParams}} +{{^hasMore}} # example passing only required values which don't have defaults set # and optional values try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/hasMore}} - {{/optionalParams}} - {{^requiredParams}} - {{^optionalParams}} +{{/hasMore}} +{{/optionalParams}} +{{^requiredParams}} +{{^optionalParams}} # example, this endpoint has no required or optional parameters try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}() +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/optionalParams}} - {{/requiredParams}} +{{/optionalParams}} +{{/requiredParams}} ``` From 97671b53ae76a092a81196a7d602c254579ba465 Mon Sep 17 00:00:00 2001 From: Ryan Rishi Date: Sat, 5 Sep 2020 11:22:04 -0600 Subject: [PATCH 137/185] Subclass Python exceptions (#7321) * Subclass Python exceptions: - UnauthorizedException (401) - ForbiddenException (403) - NotFoundException (404) - ServiceException [500 - 599] Fixes #2151 * add generated sample code * use Python 2 flavor inheritance * regenerate samples --- exceptions.mustache | 24 ++++++++++++++++++++++++ rest.mustache | 14 +++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/exceptions.mustache b/exceptions.mustache index b187ee9d47..6c77269533 100644 --- a/exceptions.mustache +++ b/exceptions.mustache @@ -120,6 +120,30 @@ class ApiException(OpenApiException): return error_message +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ServiceException, self).__init__(status, reason, http_resp) + + def render_path(path_to_item): """Returns a string representation of a path""" result = "" diff --git a/rest.mustache b/rest.mustache index 51f72f6e1f..05b46dadc1 100644 --- a/rest.mustache +++ b/rest.mustache @@ -16,7 +16,7 @@ import six from six.moves.urllib.parse import urlencode import urllib3 -from {{packageName}}.exceptions import ApiException, ApiValueError +from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -213,6 +213,18 @@ class RESTClientObject(object): logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + raise ApiException(http_resp=r) return r From 24be170e9d5606ea595fc1351c733ce6fdf6c9c8 Mon Sep 17 00:00:00 2001 From: Nicholas Muesch Date: Tue, 15 Sep 2020 16:40:48 -0400 Subject: [PATCH 138/185] Support multiple api keys in python example documentation (#7417) * Support multiple api keys in config option * Regenerate samples * Update rest of examples --- python_doc_auth_partial.mustache | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python_doc_auth_partial.mustache b/python_doc_auth_partial.mustache index 460c2df938..5106632d21 100644 --- a/python_doc_auth_partial.mustache +++ b/python_doc_auth_partial.mustache @@ -92,12 +92,8 @@ configuration = {{{packageName}}}.Configuration( {{#isApiKey}} # Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration( - host = "{{{basePath}}}", - api_key = { - '{{name}}': 'YOUR_API_KEY' - } -) +configuration.api_key['{{{name}}}'] = 'YOUR_API_KEY' + # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{name}}'] = 'Bearer' {{/isApiKey}} From fcdfa84252f85b7d88f1b76a44228987ebff0d09 Mon Sep 17 00:00:00 2001 From: spacether Date: Sun, 20 Sep 2020 10:55:54 -0700 Subject: [PATCH 139/185] Adds free form model generation in python-experimental (#7373) * Adds free form model generation in python-experimental * Adds hasValidation property to codegenModel * Adds separate variable val * Samples regenerated * Updates test_some_object.py * Adds two more boolean conditions * Runs ensure up to date * Updates tests to check that models are or are not generated * Removes unused import * Updates model names in java test * Removes unneeded test * Cleans up tests --- python-experimental/model_templates/classvars.mustache | 8 ++------ python-experimental/model_templates/validations.mustache | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index ed121c5bfe..3a78919948 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -42,14 +42,10 @@ } validations = { -{{#isAlias}} -{{^isEnum}} -{{^isArrayModel}} +{{#hasValidation}} ('value',): { {{> python-experimental/model_templates/validations }} -{{/isArrayModel}} -{{/isEnum}} -{{/isAlias}} +{{/hasValidation}} {{#requiredVars}} {{#hasValidation}} ('{{name}}',): { diff --git a/python-experimental/model_templates/validations.mustache b/python-experimental/model_templates/validations.mustache index 6b91bffe22..9e26146d83 100644 --- a/python-experimental/model_templates/validations.mustache +++ b/python-experimental/model_templates/validations.mustache @@ -7,6 +7,12 @@ {{#maxItems}} 'max_items': {{maxItems}}, {{/maxItems}} +{{#minProperties}} + 'min_properties': {{minProperties}}, +{{/minProperties}} +{{#maxProperties}} + 'max_properties': {{maxProperties}}, +{{/maxProperties}} {{#minItems}} 'min_items': {{minItems}}, {{/minItems}} From 6f4f7383441ef3968af9319464f6331e8b30b3d1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 23 Sep 2020 02:45:29 +0800 Subject: [PATCH 140/185] remove hardcoded PetApi (#7483) --- python-experimental/__init__api.mustache | 8 +++++++- python-experimental/__init__apis.mustache | 8 +++++--- python-experimental/api_client.mustache | 10 ++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/python-experimental/__init__api.mustache b/python-experimental/__init__api.mustache index 1d37d33951..8a9e6b91b9 100644 --- a/python-experimental/__init__api.mustache +++ b/python-experimental/__init__api.mustache @@ -1,3 +1,9 @@ +{{#apiInfo}} +{{#apis}} +{{#-first}} # do not import all apis into this module because that uses a lot of memory and stack frames # if you need the ability to import all apis from one package, import them with -# from {{packageName}.apis import DefaultApi, PetApi \ No newline at end of file +# from {{packageName}}.apis import {{classname}} +{{/-first}} +{{/apis}} +{{/apiInfo}} diff --git a/python-experimental/__init__apis.mustache b/python-experimental/__init__apis.mustache index da3937f8c5..32d101a97d 100644 --- a/python-experimental/__init__apis.mustache +++ b/python-experimental/__init__apis.mustache @@ -1,3 +1,6 @@ +{{#apiInfo}} +{{#apis}} +{{#-first}} # coding: utf-8 # flake8: noqa @@ -7,7 +10,7 @@ # raise a `RecursionError`. # In order to avoid this, import only the API that you directly need like: # -# from {{packagename}}.api.pet_api import PetApi +# from {{packagename}}.api.{{classVarName}} import {{classname}} # # or import this package, but before doing it, use: # @@ -15,8 +18,7 @@ # sys.setrecursionlimit(n) # Import APIs into API package: -{{#apiInfo}} -{{#apis}} +{{/-first}} from {{apiPackage}}.{{classVarName}} import {{classname}} {{/apis}} {{/apiInfo}} diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache index de4e2d478e..fd3d0b8a20 100644 --- a/python-experimental/api_client.mustache +++ b/python-experimental/api_client.mustache @@ -750,11 +750,13 @@ class Endpoint(object): def __call__(self, *args, **kwargs): """ This method is invoked when endpoints are called Example: - pet_api = PetApi() - pet_api.add_pet # this is an instance of the class Endpoint - pet_api.add_pet() # this invokes pet_api.add_pet.__call__() +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} + api_instance = {{classname}}() + api_instance.{{operationId}} # this is an instance of the class Endpoint + api_instance.{{operationId}}() # this invokes api_instance.{{operationId}}.__call__() which then invokes the callable functions stored in that endpoint at - pet_api.add_pet.callable or self.callable in this class + api_instance.{{operationId}}.callable or self.callable in this class +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} """ return self.callable(self, *args, **kwargs) From 6f0478fedcb637e22c028e9da5f2cee37a94f4db Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 25 Sep 2020 02:47:22 +0800 Subject: [PATCH 141/185] Add option to set recursion limit (#7491) * add option to set recursion limit * fix test failure * update doc * add tests * add missing import * rename option to recursionLimit --- __init__package.mustache | 4 ++++ python-experimental/__init__package.mustache | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/__init__package.mustache b/__init__package.mustache index aee16448ad..f81dd5735f 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -23,3 +23,7 @@ from {{packageName}}.exceptions import ApiException # import models into sdk package {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} {{/model}}{{/models}} +{{#recursionLimit}} + +__import__('sys').setrecursionlimit({{{.}}}) +{{/recursionLimit}} diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache index d0746d3aa6..d7ff5b8260 100644 --- a/python-experimental/__init__package.mustache +++ b/python-experimental/__init__package.mustache @@ -21,4 +21,8 @@ from {{packageName}}.exceptions import ApiAttributeError from {{packageName}}.exceptions import ApiTypeError from {{packageName}}.exceptions import ApiValueError from {{packageName}}.exceptions import ApiKeyError -from {{packageName}}.exceptions import ApiException \ No newline at end of file +from {{packageName}}.exceptions import ApiException +{{#recursionLimit}} + +__import__('sys').setrecursionlimit({{{.}}}) +{{/recursionLimit}} From 20972a83eb0cc9bf0e99adb17d5063084deca711 Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Tue, 29 Sep 2020 19:56:52 +0200 Subject: [PATCH 142/185] [Python-experimental] Don't mandate passing in required value as argument (#7424) * [Python-experimental] Don't mandate passing in required value as argument * Remove usage of have_value * Address additional review comments * Fix tests according to the code change * Does not set None as value initial value, removes hasRequired tag usage, updates docstring Co-authored-by: Justin Black --- .../method_init_simple.mustache | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/python-experimental/model_templates/method_init_simple.mustache b/python-experimental/model_templates/method_init_simple.mustache index 9d59b7ba09..b71b80667c 100644 --- a/python-experimental/model_templates/method_init_simple.mustache +++ b/python-experimental/model_templates/method_init_simple.mustache @@ -8,30 +8,37 @@ ]) @convert_js_args_to_python_args - def __init__(self{{#hasRequired}}, value{{/hasRequired}}, *args, **kwargs): + def __init__(self, *args, **kwargs): """{{classname}} - a model defined in OpenAPI -{{#hasRequired}} + Note that value can be passed either in args or in kwargs, but not in both. + Args: - value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + args[0] ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 -{{/hasRequired}} Keyword Args: -{{^hasRequired}} - value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 -{{/hasRequired}} + value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{> python-experimental/model_templates/docstring_init_required_kwargs }} """ -{{^hasRequired}} if 'value' in kwargs: value = kwargs.pop('value') elif args: args = list(args) value = args.pop(0) +{{#defaultValue}} else: value = {{{defaultValue}}} -{{/hasRequired}} +{{/defaultValue}} +{{^defaultValue}} + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) +{{/defaultValue}} + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) From 92d76f470d94e7a014b766c6e051b27485f394d0 Mon Sep 17 00:00:00 2001 From: Kuzma <57258237+ksvirkou-hubspot@users.noreply.github.com> Date: Sat, 3 Oct 2020 18:37:08 +0300 Subject: [PATCH 143/185] [Python] correct return types if multiple responses are defined (#7427) * update python mustache templates * bug fix * rm response_type * generated samples * resolve conflict * samples * set None if a type is empty * regenerated samples --- api.mustache | 19 ++++++++++++++++++- api_client.mustache | 17 ++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/api.mustache b/api.mustache index 1dcbb86078..7cbea8a8bd 100644 --- a/api.mustache +++ b/api.mustache @@ -253,6 +253,23 @@ class {{classname}}(object): {{/hasConsumes}} # Authentication setting auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + + {{#returnType}} + {{#responses}} + {{#-first}} + response_types_map = { + {{/-first}} + {{^isWildcard}} + {{code}}: {{#dataType}}"{{dataType}}"{{/dataType}}{{^dataType}}None{{/dataType}}, + {{/isWildcard}} + {{#-last}} + } + {{/-last}} + {{/responses}} + {{/returnType}} + {{^returnType}} + response_types_map = {} + {{/returnType}} return self.api_client.call_api( '{{{path}}}', '{{httpMethod}}', @@ -262,7 +279,7 @@ class {{classname}}(object): body=body_params, post_params=form_params, files=local_var_files, - response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 + response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 diff --git a/api_client.mustache b/api_client.mustache index 7eb04b6943..a3e6eba30d 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -130,7 +130,7 @@ class ApiClient(object): {{#asyncio}}async {{/asyncio}}def __call_api( self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, + files=None, response_types_map=None, auth_settings=None, _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None, _host=None, _request_auth=None): @@ -213,6 +213,8 @@ class ApiClient(object): {{#tornado}} raise tornado.gen.Return(return_data) {{/tornado}} + + response_type = response_types_map.get(response_data.status, None) if six.PY3 and response_type not in ["file", "bytes"]: match = None @@ -222,6 +224,7 @@ class ApiClient(object): response_data.data = response_data.data.decode(encoding) # deserialize response data + if response_type: return_data = self.deserialize(response_data, response_type) else: @@ -348,10 +351,10 @@ class ApiClient(object): def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None, - _request_auth=None): + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None,_preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -396,7 +399,7 @@ class ApiClient(object): return self.__call_api(resource_path, method, path_params, query_params, header_params, body, post_params, files, - response_type, auth_settings, + response_types_map, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _request_auth) @@ -406,7 +409,7 @@ class ApiClient(object): query_params, header_params, body, post_params, files, - response_type, + response_types_map, auth_settings, _return_http_data_only, collection_formats, From 65ca911bcc9ebbefa5f298a1153d6241ea0e3df3 Mon Sep 17 00:00:00 2001 From: Maksym Melnychok Date: Fri, 9 Oct 2020 19:38:15 +0200 Subject: [PATCH 144/185] [python-experimental] implement `in` operator for model classes (#7637) * implement operator for model classes * refresh samples --- .../methods_setattr_getattr_composed.mustache | 18 +++++++++++++++++- .../methods_setattr_getattr_normal.mustache | 9 ++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index dd118d30f9..1a01fc472c 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -68,4 +68,20 @@ "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item - ) \ No newline at end of file + ) + + def __contains__(self, name): + """this allows us to use `in` operator: `'attr' in instance`""" + + if name in self.required_properties: + return name in self.__dict__ + + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + + if model_instances: + for model_instance in model_instances: + if name in model_instance._data_store: + return True + + return False diff --git a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache index 9fc6344908..32566dc684 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache @@ -22,4 +22,11 @@ "{0} has no attribute '{1}'".format( type(self).__name__, name), [name] - ) \ No newline at end of file + ) + + def __contains__(self, name): + """this allows us to use `in` operator: `'attr' in instance`""" + if name in self.required_properties: + return name in self.__dict__ + + return name in self.__dict__['_data_store'] From 68ee3ae9e5d9534cf968aff57f84ce1b7ab7d853 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 12 Oct 2020 09:12:37 -0700 Subject: [PATCH 145/185] Unifies naming for isMap in Schema class properties (#7640) * Updates isMapModel + isMapContainer -> isMap * Removes git conflict characters --- model.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.mustache b/model.mustache index 2b3299a6f2..1696dc55ba 100644 --- a/model.mustache +++ b/model.mustache @@ -127,7 +127,7 @@ class {{classname}}(object): ", ".join(map(str, allowed_values))) ) {{/isListContainer}} -{{#isMapContainer}} +{{#isMap}} if (self.local_vars_configuration.client_side_validation and not set({{{name}}}.keys()).issubset(set(allowed_values))): # noqa: E501 raise ValueError( @@ -135,7 +135,7 @@ class {{classname}}(object): .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 ", ".join(map(str, allowed_values))) ) -{{/isMapContainer}} +{{/isMap}} {{/isContainer}} {{^isContainer}} allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 From 4f22c218c107afb4c80315b185f5b43ccdda2d95 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 18 Oct 2020 21:58:59 -0700 Subject: [PATCH 146/185] Unifies naming for isArray in Schema class properties (#7691) * Updates key java files * Adds all lingering isArray fixes * Adds two files * Reverts two cs files * Fixes lingering isListContainer + isArrayModel references * Some ensure up to date updates --- api.mustache | 16 ++++++++-------- model.mustache | 4 ++-- python-experimental/model.mustache | 8 ++++---- python-experimental/model_doc.mustache | 4 ++-- .../model_templates/classvars.mustache | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api.mustache b/api.mustache index 7cbea8a8bd..513738359c 100644 --- a/api.mustache +++ b/api.mustache @@ -208,30 +208,30 @@ class {{classname}}(object): path_params = {} {{#pathParams}} if '{{paramName}}' in local_var_params: - path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 + path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isArray}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 {{/pathParams}} query_params = [] {{#queryParams}} if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] is not None: # noqa: E501 - query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 + query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isArray}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 {{/queryParams}} header_params = {} {{#headerParams}} if '{{paramName}}' in local_var_params: - header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 + header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isArray}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 {{/headerParams}} form_params = [] local_var_files = {} {{#formParams}} if '{{paramName}}' in local_var_params: - {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 + {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isArray}} # noqa: E501 + collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 {{/formParams}} body_params = None diff --git a/model.mustache b/model.mustache index 1696dc55ba..9760e7d5e8 100644 --- a/model.mustache +++ b/model.mustache @@ -118,7 +118,7 @@ class {{classname}}(object): {{#isEnum}} {{#isContainer}} allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 -{{#isListContainer}} +{{#isArray}} if (self.local_vars_configuration.client_side_validation and not set({{{name}}}).issubset(set(allowed_values))): # noqa: E501 raise ValueError( @@ -126,7 +126,7 @@ class {{classname}}(object): .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 ", ".join(map(str, allowed_values))) ) -{{/isListContainer}} +{{/isArray}} {{#isMap}} if (self.local_vars_configuration.client_side_validation and not set({{{name}}}.keys()).issubset(set(allowed_values))): # noqa: E501 diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache index 1a181b824d..1fc47d9056 100644 --- a/python-experimental/model.mustache +++ b/python-experimental/model.mustache @@ -33,22 +33,22 @@ def lazy_import(): {{^interfaces}} -{{#isArrayModel}} +{{#isArray}} {{> python-experimental/model_templates/model_simple }} -{{/isArrayModel}} +{{/isArray}} {{#isEnum}} {{> python-experimental/model_templates/model_simple }} {{/isEnum}} {{#isAlias}} {{> python-experimental/model_templates/model_simple }} {{/isAlias}} -{{^isArrayModel}} +{{^isArray}} {{^isEnum}} {{^isAlias}} {{> python-experimental/model_templates/model_normal }} {{/isAlias}} {{/isEnum}} -{{/isArrayModel}} +{{/isArray}} {{/interfaces}} {{#interfaces}} {{#-last}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache index b5aa50c432..7971d6c85f 100644 --- a/python-experimental/model_doc.mustache +++ b/python-experimental/model_doc.mustache @@ -11,9 +11,9 @@ Name | Type | Description | Notes {{#isAlias}} **value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} {{/isAlias}} -{{#isArrayModel}} +{{#isArray}} **value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}}{{#arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} -{{/isArrayModel}} +{{/isArray}} {{#requiredVars}} {{^defaultValue}} **{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} diff --git a/python-experimental/model_templates/classvars.mustache b/python-experimental/model_templates/classvars.mustache index 3a78919948..f2ea42679a 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/python-experimental/model_templates/classvars.mustache @@ -102,9 +102,9 @@ {{#isEnum}} 'value': ({{{dataType}}},), {{/isEnum}} -{{#isArrayModel}} +{{#isArray}} 'value': ({{{dataType}}},), -{{/isArrayModel}} +{{/isArray}} {{#requiredVars}} '{{name}}': ({{{dataType}}},), # noqa: E501 {{/requiredVars}} From e0c8b11fdf8cdfb9c5c119b9c728f8e4b9884ae8 Mon Sep 17 00:00:00 2001 From: Maksym Melnychok Date: Sun, 25 Oct 2020 17:13:22 +0100 Subject: [PATCH 147/185] [python] Add option to return None instead of raising exception when accessing unset attribute (#7784) * add option to return None instead of raising exception when accessing unset attribute * update python samples * reimplement getattr using getitem or get depending on attrNoneIfUnset * move getattr and setattr to respective templates * update docstrings, def get/setattr methods to have docstrings in them, use __dict__ to avoid recursion issues * revert required_properties change * add manual tests for .get method --- .../methods_setattr_getattr_composed.mustache | 43 ++++++++++--------- .../methods_setattr_getattr_normal.mustache | 26 +++++------ .../model_templates/methods_shared.mustache | 18 ++++---- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index 1a01fc472c..6b1013ca99 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -1,5 +1,5 @@ - def __setattr__(self, name, value): - """this allows us to set a value with instance.field_name = val""" + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" if name in self.required_properties: self.__dict__[name] = value return @@ -20,28 +20,22 @@ ) return None - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) raise ApiAttributeError( "{0} has no attribute '{1}'".format( type(self).__name__, name), - path_to_item + [e for e in [self._path_to_item, name] if e] ) - def __getattr__(self, name): - """this allows us to get a value with val = instance.field_name""" + __unset_attribute_value__ = object() + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" if name in self.required_properties: return self.__dict__[name] # get the attribute from the correct instance model_instances = self._var_name_to_model_instances.get( name, self._additional_properties_model_instances) - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) values = [] # A composed model stores child (oneof/anyOf/allOf) models under # self._var_name_to_model_instances. A named property can exist in @@ -55,11 +49,7 @@ values.append(v) len_values = len(values) if len_values == 0: - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - path_to_item - ) + return default elif len_values == 1: return values[0] elif len_values > 1: @@ -67,11 +57,22 @@ "Values stored for property {0} in {1} differ when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), - path_to_item + [e for e in [self._path_to_item, name] if e] + ) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + value = self.get(name, self.__unset_attribute_value__) + if value is self.__unset_attribute_value__: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] ) + return value def __contains__(self, name): - """this allows us to use `in` operator: `'attr' in instance`""" + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" if name in self.required_properties: return name in self.__dict__ @@ -84,4 +85,4 @@ if name in model_instance._data_store: return True - return False + return False \ No newline at end of file diff --git a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache index 32566dc684..e700dad953 100644 --- a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache +++ b/python-experimental/model_templates/methods_setattr_getattr_normal.mustache @@ -1,32 +1,32 @@ - def __setattr__(self, name, value): - """this allows us to set a value with instance.field_name = val""" + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" if name in self.required_properties: self.__dict__[name] = value return self.set_attribute(name, value) - def __getattr__(self, name): - """this allows us to get a value with val = instance.field_name""" + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" if name in self.required_properties: return self.__dict__[name] - if name in self.__dict__['_data_store']: - return self.__dict__['_data_store'][name] + return self.__dict__['_data_store'].get(name, default) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + if name in self: + return self.get(name) - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) raise ApiAttributeError( "{0} has no attribute '{1}'".format( type(self).__name__, name), - [name] + [e for e in [self._path_to_item, name] if e] ) def __contains__(self, name): - """this allows us to use `in` operator: `'attr' in instance`""" + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" if name in self.required_properties: return name in self.__dict__ - return name in self.__dict__['_data_store'] + return name in self.__dict__['_data_store'] \ No newline at end of file diff --git a/python-experimental/model_templates/methods_shared.mustache b/python-experimental/model_templates/methods_shared.mustache index d3cf66e41b..43bcf6fd0d 100644 --- a/python-experimental/model_templates/methods_shared.mustache +++ b/python-experimental/model_templates/methods_shared.mustache @@ -1,15 +1,15 @@ - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__setattr__(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__getattr__(name) - def __repr__(self): """For `print` and `pprint`""" return self.to_str() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other \ No newline at end of file + return not self == other + + def __setattr__(self, attr, value): + """set the value of an attribute using dot notation: `instance.attr = val`""" + self[attr] = value + + def __getattr__(self, attr): + """get the value of an attribute using dot notation: `instance.attr`""" + return self.{{#attrNoneIfUnset}}get{{/attrNoneIfUnset}}{{^attrNoneIfUnset}}__getitem__{{/attrNoneIfUnset}}(attr) \ No newline at end of file From 9fcef2bf13775b012be35479fc0797380156d947 Mon Sep 17 00:00:00 2001 From: Steve B Date: Wed, 28 Oct 2020 02:22:28 +0100 Subject: [PATCH 148/185] [python] add socket_options to configuration for the rest client (#7795) * [python] add socket_options to configuration for the rest client * (python-experimental) add socket_options to configuration for the rest client This mirrors work done on the python generator * (python-experimental) add test to cover socket_options is passed on from configuration Co-authored-by: steve brazier --- configuration.mustache | 4 ++++ python-experimental/configuration.mustache | 3 +++ python-experimental/rest.mustache | 3 +++ rest.mustache | 3 +++ 4 files changed, 13 insertions(+) diff --git a/configuration.mustache b/configuration.mustache index 8025a1b655..9f2542f5a9 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -302,6 +302,10 @@ conf = {{{packageName}}}.Configuration( # Enable client side validation self.client_side_validation = True + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + def __deepcopy__(self, memo): cls = self.__class__ result = cls.__new__(cls) diff --git a/python-experimental/configuration.mustache b/python-experimental/configuration.mustache index 8b911bdddd..ca6fc37747 100644 --- a/python-experimental/configuration.mustache +++ b/python-experimental/configuration.mustache @@ -299,6 +299,9 @@ conf = {{{packageName}}}.Configuration( # Enable client side validation self.client_side_validation = True + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + def __deepcopy__(self, memo): cls = self.__class__ result = cls.__new__(cls) diff --git a/python-experimental/rest.mustache b/python-experimental/rest.mustache index 746f984434..5fb2da0af2 100644 --- a/python-experimental/rest.mustache +++ b/python-experimental/rest.mustache @@ -64,6 +64,9 @@ class RESTClientObject(object): if configuration.retries is not None: addition_pool_args['retries'] = configuration.retries + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + if maxsize is None: if configuration.connection_pool_maxsize is not None: maxsize = configuration.connection_pool_maxsize diff --git a/rest.mustache b/rest.mustache index 05b46dadc1..3916878624 100644 --- a/rest.mustache +++ b/rest.mustache @@ -68,6 +68,9 @@ class RESTClientObject(object): if configuration.retries is not None: addition_pool_args['retries'] = configuration.retries + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + if maxsize is None: if configuration.connection_pool_maxsize is not None: maxsize = configuration.connection_pool_maxsize From aabb60701610eadb9d61eb68db77861c5acdafab Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Wed, 4 Nov 2020 17:41:00 +0100 Subject: [PATCH 149/185] [python] check output content-type only if preload_content is set (#7847) --- api_client.mustache | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index a3e6eba30d..4f230dff62 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -200,8 +200,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -218,6 +216,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" From 997f98c0ae0c70a4cd22ca73473da2ccd4db8d1f Mon Sep 17 00:00:00 2001 From: debugman Date: Fri, 6 Nov 2020 01:42:35 +0800 Subject: [PATCH 150/185] added serialize option in to_dict function in python generated model (#7555) * added to_json_dict in python generated model * update to_dict * updated to_dict Co-authored-by: sunkaicheng --- model.mustache | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/model.mustache b/model.mustache index 9760e7d5e8..99820290f2 100644 --- a/model.mustache +++ b/model.mustache @@ -2,9 +2,9 @@ {{>partial_header}} +import inspect import pprint import re # noqa: F401 - import six from {{packageName}}.configuration import Configuration @@ -197,27 +197,35 @@ class {{classname}}(object): return self.discriminator_value_class_map.get(discriminator_value) {{/discriminator}} - def to_dict(self): + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} + def convert(x): + if hasattr(x, "to_dict"): + args = inspect.getargspec(x.to_dict).args + if len(args) == 1: + return x.to_dict() + else: + return x.to_dict(serialize) + else: + return x + for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) + attr = self.attribute_map.get(attr, attr) if serialize else attr if isinstance(value, list): result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + lambda x: convert(x), value )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, + lambda item: (item[0], convert(item[1])), value.items() )) else: - result[attr] = value + result[attr] = convert(value) return result From 29f961aa103b901039d5fbe045d26c815e8d5657 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 6 Nov 2020 19:04:12 -0800 Subject: [PATCH 151/185] Removes secondaryParam and hasMore (#7882) * Removes secondaryParam and hasMore * Fixes tests * Only uses bodyParam in groovy template --- api.mustache | 8 ++++---- api_doc.mustache | 6 +++--- api_doc_example.mustache | 2 +- common_README.mustache | 8 ++++---- model.mustache | 4 ++-- model_test.mustache | 2 +- python-experimental/README_common.mustache | 8 ++++---- python-experimental/api.mustache | 10 +++++----- python-experimental/api_doc.mustache | 6 +++--- python-experimental/api_doc_example.mustache | 12 ++++++------ python-experimental/setup.mustache | 4 ++-- setup.mustache | 4 ++-- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/api.mustache b/api.mustache index 513738359c..38d137c3c4 100644 --- a/api.mustache +++ b/api.mustache @@ -133,7 +133,7 @@ class {{classname}}(object): all_params = [ {{#allParams}} - '{{paramName}}'{{#hasMore}},{{/hasMore}} + '{{paramName}}'{{^-last}},{{/-last}} {{/allParams}} ] all_params.extend( @@ -242,17 +242,17 @@ class {{classname}}(object): {{#hasProduces}} # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}]) # noqa: E501 {{/hasProduces}} {{#hasConsumes}} # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 {{/hasConsumes}} # Authentication setting - auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + auth_settings = [{{#authMethods}}'{{name}}'{{^-last}}, {{/-last}}{{/authMethods}}] # noqa: E501 {{#returnType}} {{#responses}} diff --git a/api_doc.mustache b/api_doc.mustache index fb537ad30b..dddec91719 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -11,7 +11,7 @@ Method | HTTP request | Description {{#operations}} {{#operation}} # **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) {{{summary}}}{{#notes}} @@ -58,8 +58,8 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} - - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} {{#responses.0}} ### HTTP response details diff --git a/api_doc_example.mustache b/api_doc_example.mustache index dadb8f6a96..526c5950a0 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -19,7 +19,7 @@ with {{{packageName}}}.ApiClient() as api_client: try: {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} pprint(api_response){{/returnType}} except ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) diff --git a/common_README.mustache b/common_README.mustache index 37060d6d1f..12fa1322a7 100644 --- a/common_README.mustache +++ b/common_README.mustache @@ -1,6 +1,6 @@ ```python from __future__ import print_function -{{#apiInfo}}{{#apis}}{{^hasMore}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/hasMore}}{{/apis}}{{/apiInfo}} +{{#apiInfo}}{{#apis}}{{#-last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/-last}}{{/apis}}{{/apiInfo}} import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException @@ -17,7 +17,7 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: try: {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} pprint(api_response){{/returnType}} except ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) @@ -73,5 +73,5 @@ Class | Method | HTTP request | Description ## Author -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/model.mustache b/model.mustache index 99820290f2..857a3e48fb 100644 --- a/model.mustache +++ b/model.mustache @@ -40,13 +40,13 @@ class {{classname}}(object): """ openapi_types = { {{#vars}} - '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} + '{{name}}': '{{{dataType}}}'{{^-last}},{{/-last}} {{/vars}} } attribute_map = { {{#vars}} - '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} + '{{name}}': '{{baseName}}'{{^-last}},{{/-last}} {{/vars}} } {{#discriminator}} diff --git a/model_test.mustache b/model_test.mustache index b69f13f744..cd55662e10 100644 --- a/model_test.mustache +++ b/model_test.mustache @@ -31,7 +31,7 @@ class Test{{classname}}(unittest.TestCase): if include_optional : return {{classname}}( {{#vars}} - {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}{{#hasMore}}, {{/hasMore}} + {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}{{^-last}}, {{/-last}} {{/vars}} ) else : diff --git a/python-experimental/README_common.mustache b/python-experimental/README_common.mustache index d3844fd15f..ec525d175b 100644 --- a/python-experimental/README_common.mustache +++ b/python-experimental/README_common.mustache @@ -1,5 +1,5 @@ ```python -{{#apiInfo}}{{#apis}}{{^hasMore}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/hasMore}}{{/apis}}{{/apiInfo}} +{{#apiInfo}}{{#apis}}{{#-last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/-last}}{{/apis}}{{/apiInfo}} import time import {{{packageName}}} from pprint import pprint @@ -24,7 +24,7 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: try: {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} pprint(api_response){{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) @@ -88,8 +88,8 @@ Class | Method | HTTP request | Description ## Author -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} ## Notes for Large OpenAPI documents If the OpenAPI document is large, imports in {{{packageName}}}.apis and {{{packageName}}}.models may fail with a diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache index 776acbf5ec..0e76b3f29f 100644 --- a/python-experimental/api.mustache +++ b/python-experimental/api.mustache @@ -60,9 +60,9 @@ class {{classname}}(object): >>> result = thread.get() {{#requiredParams}} -{{^hasMore}} +{{#-last}} Args: -{{/hasMore}} +{{/-last}} {{/requiredParams}} {{#requiredParams}} {{^defaultValue}} @@ -134,7 +134,7 @@ class {{classname}}(object): {{#-first}} 'auth': [ {{/-first}} - '{{name}}'{{#hasMore}},{{/hasMore}} + '{{name}}'{{^-last}},{{/-last}} {{#-last}} ], {{/-last}} @@ -283,7 +283,7 @@ class {{classname}}(object): {{#hasProduces}} 'accept': [ {{#produces}} - '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} + '{{{mediaType}}}'{{^-last}},{{/-last}} {{/produces}} ], {{/hasProduces}} @@ -293,7 +293,7 @@ class {{classname}}(object): {{#hasConsumes}} 'content_type': [ {{#consumes}} - '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} + '{{{mediaType}}}'{{^-last}},{{/-last}} {{/consumes}} ] {{/hasConsumes}} diff --git a/python-experimental/api_doc.mustache b/python-experimental/api_doc.mustache index 10317b4b48..f9dac707f7 100644 --- a/python-experimental/api_doc.mustache +++ b/python-experimental/api_doc.mustache @@ -11,7 +11,7 @@ Method | HTTP request | Description {{#operations}} {{#operation}} # **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}) +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) {{{summary}}}{{#notes}} @@ -57,8 +57,8 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} - - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} {{#responses.0}} ### HTTP response details diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache index 38d50dbd7c..bf989ae430 100644 --- a/python-experimental/api_doc_example.mustache +++ b/python-experimental/api_doc_example.mustache @@ -25,23 +25,23 @@ with {{{packageName}}}.ApiClient() as api_client: {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} {{/optionalParams}} {{#requiredParams}} -{{^hasMore}} +{{#-last}} # example passing only required values which don't have defaults set try: {{#summary}} # {{{.}}} {{/summary}} - {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}) + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) {{#returnType}} pprint(api_response) {{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/hasMore}} +{{/-last}} {{/requiredParams}} {{#optionalParams}} -{{^hasMore}} +{{#-last}} # example passing only required values which don't have defaults set # and optional values @@ -49,13 +49,13 @@ with {{{packageName}}}.ApiClient() as api_client: {{#summary}} # {{{.}}} {{/summary}} - {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}) + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{^-last}}, {{/-last}}{{/optionalParams}}) {{#returnType}} pprint(api_response) {{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/hasMore}} +{{/-last}} {{/optionalParams}} {{^requiredParams}} {{^optionalParams}} diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache index 4c3e32ef7d..632584a592 100644 --- a/python-experimental/setup.mustache +++ b/python-experimental/setup.mustache @@ -8,7 +8,7 @@ NAME = "{{{projectName}}}" VERSION = "{{packageVersion}}" {{#apiInfo}} {{#apis}} -{{^hasMore}} +{{#-last}} # To install the library, run the following # # python setup.py install @@ -50,6 +50,6 @@ setup( {{appDescription}} # noqa: E501 """ ) -{{/hasMore}} +{{/-last}} {{/apis}} {{/apiInfo}} diff --git a/setup.mustache b/setup.mustache index a41fee1467..a14de4016f 100644 --- a/setup.mustache +++ b/setup.mustache @@ -8,7 +8,7 @@ NAME = "{{{projectName}}}" VERSION = "{{packageVersion}}" {{#apiInfo}} {{#apis}} -{{^hasMore}} +{{#-last}} # To install the library, run the following # # python setup.py install @@ -40,6 +40,6 @@ setup( {{appDescription}} # noqa: E501 """ ) -{{/hasMore}} +{{/-last}} {{/apis}} {{/apiInfo}} From 29501553532dbd0cce57ed37b58bde4795f4371c Mon Sep 17 00:00:00 2001 From: Nicholas Muesch Date: Sun, 8 Nov 2020 15:27:58 -0500 Subject: [PATCH 152/185] Skip validation if input_value is None (#7845) --- python-experimental/model_utils.mustache | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-experimental/model_utils.mustache b/python-experimental/model_utils.mustache index 400cfe3509..72a5cbe429 100644 --- a/python-experimental/model_utils.mustache +++ b/python-experimental/model_utils.mustache @@ -455,6 +455,9 @@ def check_validations( configuration (Configuration): the configuration class. """ + if input_values is None: + return + current_validations = validations[input_variable_path] if (is_json_validation_enabled('multipleOf', configuration) and 'multiple_of' in current_validations and From 1699424e0ffb793814dffae64e7d6fb30c57ff6e Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 18 Nov 2020 14:34:00 +0800 Subject: [PATCH 153/185] [python] Renames python generators (#7965) * python->python-legacy, python-experimental->python * test with openjdk8 * test with openjdk11 * comment out rm * move kotlin tests to circleci * move kotlin tests * move tests to circleci * fix circleci * rearrange test * move tests * use wrapper Co-authored-by: Justin Black --- README.mustache | 4 +- ..._common.mustache => README_common.mustache | 0 README_onlypackage.mustache | 5 +- __init__api.mustache | 16 +- ...it__apis.mustache => __init__apis.mustache | 0 __init__model.mustache | 15 +- ...models.mustache => __init__models.mustache | 0 __init__package.mustache | 17 +- api.mustache | 514 +++++------ api_client.mustache | 714 +++++++++------ api_doc.mustache | 11 +- api_doc_example.mustache | 68 +- api_test.mustache | 5 +- common_README.mustache | 77 -- configuration.mustache | 22 +- exceptions.mustache | 28 +- gitlab-ci.mustache | 27 +- model.mustache | 279 +----- model_doc.mustache | 27 +- .../classvars.mustache | 6 +- .../docstring_allowed.mustache | 0 .../docstring_init_required_kwargs.mustache | 0 .../docstring_openapi_validations.mustache | 0 .../method_init_composed.mustache | 2 +- .../method_init_normal.mustache | 2 +- .../method_init_shared.mustache | 2 +- .../method_init_simple.mustache | 2 +- .../method_set_attribute.mustache | 0 .../methods_setattr_getattr_composed.mustache | 0 .../methods_setattr_getattr_normal.mustache | 0 .../methods_shared.mustache | 0 .../methods_todict_tostr_eq_shared.mustache | 0 .../methods_tostr_eq_simple.mustache | 0 .../model_composed.mustache | 8 +- .../model_normal.mustache | 8 +- .../model_simple.mustache | 8 +- .../validations.mustache | 0 model_test.mustache | 39 +- ...del_utils.mustache => model_utils.mustache | 16 +- python-experimental/README.mustache | 55 -- .../README_onlypackage.mustache | 43 - python-experimental/__init__api.mustache | 9 - python-experimental/__init__model.mustache | 5 - python-experimental/__init__package.mustache | 28 - python-experimental/api.mustache | 308 ------- python-experimental/api_client.mustache | 839 ------------------ python-experimental/api_doc.mustache | 75 -- python-experimental/api_doc_example.mustache | 76 -- python-experimental/api_test.mustache | 34 - python-experimental/configuration.mustache | 635 ------------- python-experimental/exceptions.mustache | 129 --- python-experimental/gitlab-ci.mustache | 29 - python-experimental/model.mustache | 59 -- python-experimental/model_doc.mustache | 36 - python-experimental/model_test.mustache | 36 - python-experimental/requirements.mustache | 5 - python-experimental/rest.mustache | 282 ------ python-experimental/setup.mustache | 55 -- .../test-requirements.mustache | 15 - python-experimental/tox.mustache | 9 - python-experimental/travis.mustache | 18 - requirements.mustache | 3 +- rest.mustache | 22 +- setup.mustache | 16 +- .../signing.mustache => signing.mustache | 0 test-requirements.mustache | 9 +- tox.mustache | 5 - travis.mustache | 4 - 68 files changed, 919 insertions(+), 3842 deletions(-) rename python-experimental/README_common.mustache => README_common.mustache (100%) rename python-experimental/__init__apis.mustache => __init__apis.mustache (100%) rename python-experimental/__init__models.mustache => __init__models.mustache (100%) delete mode 100644 common_README.mustache rename {python-experimental/model_templates => model_templates}/classvars.mustache (94%) rename {python-experimental/model_templates => model_templates}/docstring_allowed.mustache (100%) rename {python-experimental/model_templates => model_templates}/docstring_init_required_kwargs.mustache (100%) rename {python-experimental/model_templates => model_templates}/docstring_openapi_validations.mustache (100%) rename {python-experimental/model_templates => model_templates}/method_init_composed.mustache (96%) rename {python-experimental/model_templates => model_templates}/method_init_normal.mustache (92%) rename {python-experimental/model_templates => model_templates}/method_init_shared.mustache (96%) rename {python-experimental/model_templates => model_templates}/method_init_simple.mustache (97%) rename {python-experimental/model_templates => model_templates}/method_set_attribute.mustache (100%) rename {python-experimental/model_templates => model_templates}/methods_setattr_getattr_composed.mustache (100%) rename {python-experimental/model_templates => model_templates}/methods_setattr_getattr_normal.mustache (100%) rename {python-experimental/model_templates => model_templates}/methods_shared.mustache (100%) rename {python-experimental/model_templates => model_templates}/methods_todict_tostr_eq_shared.mustache (100%) rename {python-experimental/model_templates => model_templates}/methods_tostr_eq_simple.mustache (100%) rename {python-experimental/model_templates => model_templates}/model_composed.mustache (85%) rename {python-experimental/model_templates => model_templates}/model_normal.mustache (73%) rename {python-experimental/model_templates => model_templates}/model_simple.mustache (50%) rename {python-experimental/model_templates => model_templates}/validations.mustache (100%) rename python-experimental/model_utils.mustache => model_utils.mustache (99%) delete mode 100644 python-experimental/README.mustache delete mode 100644 python-experimental/README_onlypackage.mustache delete mode 100644 python-experimental/__init__api.mustache delete mode 100644 python-experimental/__init__model.mustache delete mode 100644 python-experimental/__init__package.mustache delete mode 100644 python-experimental/api.mustache delete mode 100644 python-experimental/api_client.mustache delete mode 100644 python-experimental/api_doc.mustache delete mode 100644 python-experimental/api_doc_example.mustache delete mode 100644 python-experimental/api_test.mustache delete mode 100644 python-experimental/configuration.mustache delete mode 100644 python-experimental/exceptions.mustache delete mode 100644 python-experimental/gitlab-ci.mustache delete mode 100644 python-experimental/model.mustache delete mode 100644 python-experimental/model_doc.mustache delete mode 100644 python-experimental/model_test.mustache delete mode 100644 python-experimental/requirements.mustache delete mode 100644 python-experimental/rest.mustache delete mode 100644 python-experimental/setup.mustache delete mode 100644 python-experimental/test-requirements.mustache delete mode 100644 python-experimental/tox.mustache delete mode 100644 python-experimental/travis.mustache rename python-experimental/signing.mustache => signing.mustache (100%) diff --git a/README.mustache b/README.mustache index 9d854a4f1b..463e4e0d56 100644 --- a/README.mustache +++ b/README.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python 2.7 and 3.4+ +Python >= 3.5 ## Installation & Usage ### pip install @@ -52,4 +52,4 @@ import {{{packageName}}} Please follow the [installation procedure](#installation--usage) and then run the following: -{{> common_README }} +{{> README_common }} diff --git a/python-experimental/README_common.mustache b/README_common.mustache similarity index 100% rename from python-experimental/README_common.mustache rename to README_common.mustache diff --git a/README_onlypackage.mustache b/README_onlypackage.mustache index 826454b1ea..40dc242b7b 100644 --- a/README_onlypackage.mustache +++ b/README_onlypackage.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python 2.7 and 3.4+ +Python >= 3.5 ## Installation & Usage @@ -26,7 +26,6 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: * urllib3 >= 1.15 -* six >= 1.10 * certifi * python-dateutil {{#asyncio}} @@ -41,4 +40,4 @@ To be able to use it, you will need these dependencies in your own package that In your own code, to use this library to connect and interact with {{{projectName}}}, you can run the following: -{{> common_README }} +{{> README_common }} diff --git a/__init__api.mustache b/__init__api.mustache index db658a10fa..8a9e6b91b9 100644 --- a/__init__api.mustache +++ b/__init__api.mustache @@ -1,7 +1,9 @@ -from __future__ import absolute_import - -# flake8: noqa - -# import apis into api package -{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} -{{/apis}}{{/apiInfo}} \ No newline at end of file +{{#apiInfo}} +{{#apis}} +{{#-first}} +# do not import all apis into this module because that uses a lot of memory and stack frames +# if you need the ability to import all apis from one package, import them with +# from {{packageName}}.apis import {{classname}} +{{/-first}} +{{/apis}} +{{/apiInfo}} diff --git a/python-experimental/__init__apis.mustache b/__init__apis.mustache similarity index 100% rename from python-experimental/__init__apis.mustache rename to __init__apis.mustache diff --git a/__init__model.mustache b/__init__model.mustache index 2266b3d17f..cfe32b7849 100644 --- a/__init__model.mustache +++ b/__init__model.mustache @@ -1,10 +1,5 @@ -# coding: utf-8 - -# flake8: noqa -{{>partial_header}} - -from __future__ import absolute_import - -# import models into model package -{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} -{{/models}} +# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from {{packageName}.models import ModelA, ModelB diff --git a/python-experimental/__init__models.mustache b/__init__models.mustache similarity index 100% rename from python-experimental/__init__models.mustache rename to __init__models.mustache diff --git a/__init__package.mustache b/__init__package.mustache index f81dd5735f..d7ff5b8260 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -4,25 +4,24 @@ {{>partial_header}} -from __future__ import absolute_import - __version__ = "{{packageVersion}}" -# import apis into sdk package -{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} -{{/apis}}{{/apiInfo}} # import ApiClient from {{packageName}}.api_client import ApiClient + +# import Configuration from {{packageName}}.configuration import Configuration +{{#hasHttpSignatureMethods}} +from {{packageName}}.signing import HttpSigningConfiguration +{{/hasHttpSignatureMethods}} + +# import exceptions from {{packageName}}.exceptions import OpenApiException +from {{packageName}}.exceptions import ApiAttributeError from {{packageName}}.exceptions import ApiTypeError from {{packageName}}.exceptions import ApiValueError from {{packageName}}.exceptions import ApiKeyError -from {{packageName}}.exceptions import ApiAttributeError from {{packageName}}.exceptions import ApiException -# import models into sdk package -{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} -{{/model}}{{/models}} {{#recursionLimit}} __import__('sys').setrecursionlimit({{{.}}}) diff --git a/api.mustache b/api.mustache index 38d137c3c4..0e76b3f29f 100644 --- a/api.mustache +++ b/api.mustache @@ -2,18 +2,22 @@ {{>partial_header}} -from __future__ import absolute_import - import re # noqa: F401 +import sys # noqa: F401 -# python 2 and python 3 compatibility library -import six - -from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError +from {{packageName}}.api_client import ApiClient, Endpoint +from {{packageName}}.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types ) +{{#imports}} +{{{import}}} +{{/imports}} {{#operations}} @@ -30,265 +34,275 @@ class {{classname}}(object): self.api_client = api_client {{#operation}} - def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + def __{{operationId}}( + self, +{{#requiredParams}} +{{^defaultValue}} + {{paramName}}, +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}}={{{defaultValue}}}, +{{/defaultValue}} +{{/requiredParams}} + **kwargs + ): + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} - {{{notes}}} # noqa: E501 + {{{notes}}} # noqa: E501 {{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True -{{#sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} -{{^sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} - >>> result = thread.get() + >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) + >>> result = thread.get() -{{#allParams}} - :param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} - :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} -{{/allParams}} - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :type _preload_content: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} - """ - kwargs['_return_http_data_only'] = True - return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501 - - def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 - -{{#notes}} - {{{notes}}} # noqa: E501 -{{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True +{{#requiredParams}} +{{#-last}} + Args: +{{/-last}} +{{/requiredParams}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}} +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] +{{/defaultValue}} +{{/requiredParams}} -{{#sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} -{{^sortParamsByRequiredFlag}} - >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) -{{/sortParamsByRequiredFlag}} - >>> result = thread.get() + Keyword Args:{{#optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously -{{#allParams}} - :param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} - :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} -{{/allParams}} - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _return_http_data_only: response data without head status code - and headers - :type _return_http_data_only: bool, optional - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :type _preload_content: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}} - """ + Returns: + {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') +{{#requiredParams}} + kwargs['{{paramName}}'] = \ + {{paramName}} +{{/requiredParams}} + return self.call_with_http_info(**kwargs) - {{#servers.0}} - local_var_hosts = [ + self.{{operationId}} = Endpoint( + settings={ + 'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}}, +{{#authMethods}} +{{#-first}} + 'auth': [ +{{/-first}} + '{{name}}'{{^-last}},{{/-last}} +{{#-last}} + ], +{{/-last}} +{{/authMethods}} +{{^authMethods}} + 'auth': [], +{{/authMethods}} + 'endpoint_path': '{{{path}}}', + 'operation_id': '{{operationId}}', + 'http_method': '{{httpMethod}}', {{#servers}} - '{{{url}}}'{{^-last}},{{/-last}} +{{#-first}} + 'servers': [ +{{/-first}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }, +{{#-last}} + ] +{{/-last}} {{/servers}} - ] - local_var_host = local_var_hosts[0] - if kwargs.get('_host_index'): - _host_index = int(kwargs.get('_host_index')) - if _host_index < 0 or _host_index >= len(local_var_hosts): - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" - % len(local_var_host) - ) - local_var_host = local_var_hosts[_host_index] - {{/servers.0}} - local_var_params = locals() - - all_params = [ +{{^servers}} + 'servers': None, +{{/servers}} + }, + params_map={ + 'all': [ {{#allParams}} - '{{paramName}}'{{^-last}},{{/-last}} + '{{paramName}}', {{/allParams}} - ] - all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth' - ] - ) - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method {{operationId}}" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] + ], +{{#requiredParams}} +{{#-first}} + 'required': [ +{{/-first}} + '{{paramName}}', +{{#-last}} + ], +{{/-last}} +{{/requiredParams}} +{{^requiredParams}} + 'required': [], +{{/requiredParams}} + 'nullable': [ {{#allParams}} -{{^isNullable}} -{{#required}} - # verify the required parameter '{{paramName}}' is set - if self.api_client.client_side_validation and ('{{paramName}}' not in local_var_params or # noqa: E501 - local_var_params['{{paramName}}'] is None): # noqa: E501 - raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 -{{/required}} +{{#isNullable}} + '{{paramName}}', {{/isNullable}} {{/allParams}} - + ], + 'enum': [ +{{#allParams}} +{{#isEnum}} + '{{paramName}}', +{{/isEnum}} +{{/allParams}} + ], + 'validation': [ {{#allParams}} {{#hasValidation}} - {{#maxLength}} - if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 - len(local_var_params['{{paramName}}']) > {{maxLength}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 - {{/maxLength}} - {{#minLength}} - if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 - len(local_var_params['{{paramName}}']) < {{minLength}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 - {{/minLength}} - {{#maximum}} - if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 - {{/maximum}} - {{#minimum}} - if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 - {{/minimum}} - {{#pattern}} - if self.api_client.client_side_validation and '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 - {{/pattern}} - {{#maxItems}} - if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 - len(local_var_params['{{paramName}}']) > {{maxItems}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 - {{/maxItems}} - {{#minItems}} - if self.api_client.client_side_validation and ('{{paramName}}' in local_var_params and # noqa: E501 - len(local_var_params['{{paramName}}']) < {{minItems}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 - {{/minItems}} + '{{paramName}}', {{/hasValidation}} -{{#-last}} -{{/-last}} {{/allParams}} - collection_formats = {} - - path_params = {} -{{#pathParams}} - if '{{paramName}}' in local_var_params: - path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isArray}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 -{{/pathParams}} - - query_params = [] -{{#queryParams}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] is not None: # noqa: E501 - query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isArray}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 -{{/queryParams}} - - header_params = {} -{{#headerParams}} - if '{{paramName}}' in local_var_params: - header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isArray}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 -{{/headerParams}} - - form_params = [] - local_var_files = {} -{{#formParams}} - if '{{paramName}}' in local_var_params: - {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isArray}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isArray}} # noqa: E501 -{{/formParams}} - - body_params = None -{{#bodyParam}} - if '{{paramName}}' in local_var_params: - body_params = local_var_params['{{paramName}}'] -{{/bodyParam}} - {{#hasProduces}} - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}]) # noqa: E501 - - {{/hasProduces}} - {{#hasConsumes}} - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 - - {{/hasConsumes}} - # Authentication setting - auth_settings = [{{#authMethods}}'{{name}}'{{^-last}}, {{/-last}}{{/authMethods}}] # noqa: E501 - - {{#returnType}} - {{#responses}} - {{#-first}} - response_types_map = { - {{/-first}} - {{^isWildcard}} - {{code}}: {{#dataType}}"{{dataType}}"{{/dataType}}{{^dataType}}None{{/dataType}}, - {{/isWildcard}} - {{#-last}} - } - {{/-last}} - {{/responses}} - {{/returnType}} - {{^returnType}} - response_types_map = {} - {{/returnType}} - - return self.api_client.call_api( - '{{{path}}}', '{{httpMethod}}', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_types_map=response_types_map, - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - {{#servers.0}} - _host=local_var_host, - {{/servers.0}} - collection_formats=collection_formats, - _request_auth=local_var_params.get('_request_auth')) + ] + }, + root_map={ + 'validations': { +{{#allParams}} +{{#hasValidation}} + ('{{paramName}}',): { +{{#maxLength}} + 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} + 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} + 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} + 'min_items': {{minItems}},{{/minItems}}{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + },{{/pattern}} + }, +{{/hasValidation}} +{{/allParams}} + }, + 'allowed_values': { +{{#allParams}} +{{#isEnum}} + ('{{paramName}}',): { +{{#isNullable}} + 'None': None,{{/isNullable}}{{#allowableValues}}{{#enumVars}} + "{{name}}": {{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + }, +{{/isEnum}} +{{/allParams}} + }, + 'openapi_types': { +{{#allParams}} + '{{paramName}}': + ({{{dataType}}},), +{{/allParams}} + }, + 'attribute_map': { +{{#allParams}} +{{^isBodyParam}} + '{{paramName}}': '{{baseName}}', +{{/isBodyParam}} +{{/allParams}} + }, + 'location_map': { +{{#allParams}} + '{{paramName}}': '{{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isCookieParam}}cookie{{/isCookieParam}}{{#isBodyParam}}body{{/isBodyParam}}', +{{/allParams}} + }, + 'collection_format_map': { +{{#allParams}} +{{#collectionFormat}} + '{{paramName}}': '{{collectionFormat}}', +{{/collectionFormat}} +{{/allParams}} + } + }, + headers_map={ +{{#hasProduces}} + 'accept': [ +{{#produces}} + '{{{mediaType}}}'{{^-last}},{{/-last}} +{{/produces}} + ], +{{/hasProduces}} +{{^hasProduces}} + 'accept': [], +{{/hasProduces}} +{{#hasConsumes}} + 'content_type': [ +{{#consumes}} + '{{{mediaType}}}'{{^-last}},{{/-last}} +{{/consumes}} + ] +{{/hasConsumes}} +{{^hasConsumes}} + 'content_type': [], +{{/hasConsumes}} + }, + api_client=api_client, + callable=__{{operationId}} + ) {{/operation}} {{/operations}} diff --git a/api_client.mustache b/api_client.mustache index 4f230dff62..fd3d0b8a20 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -1,28 +1,37 @@ # coding: utf-8 {{>partial_header}} -from __future__ import absolute_import -import atexit -import datetime -from dateutil.parser import parse import json +import atexit import mimetypes from multiprocessing.pool import ThreadPool +import io import os import re -import tempfile +import typing +from urllib.parse import quote -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import quote {{#tornado}} import tornado.gen {{/tornado}} -from {{packageName}}.configuration import Configuration -import {{modelPackage}} from {{packageName}} import rest -from {{packageName}}.exceptions import ApiValueError, ApiException +from {{packageName}}.configuration import Configuration +from {{packageName}}.exceptions import ApiTypeError, ApiValueError, ApiException +from {{packageName}}.model_utils import ( + ModelNormal, + ModelSimple, + ModelComposed, + check_allowed_values, + check_validations, + date, + datetime, + deserialize_file, + file_type, + model_to_dict, + none_type, + validate_and_convert_types +) class ApiClient(object): @@ -47,23 +56,12 @@ class ApiClient(object): to the API. More threads means more concurrent API requests. """ - PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, - } _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration.get_default_copy() + configuration = Configuration() self.configuration = configuration self.pool_threads = pool_threads @@ -74,27 +72,14 @@ class ApiClient(object): self.cookie = cookie # Set default User-Agent. self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' - self.client_side_validation = configuration.client_side_validation - {{#asyncio}} - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc_value, traceback): - await self.close() - {{/asyncio}} - {{^asyncio}} def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() - {{/asyncio}} - {{#asyncio}}async {{/asyncio}}def close(self): - {{#asyncio}} - await self.rest_client.close() - {{/asyncio}} + def close(self): if self._pool: self._pool.close() self._pool.join() @@ -128,12 +113,24 @@ class ApiClient(object): @tornado.gen.coroutine {{/tornado}} {{#asyncio}}async {{/asyncio}}def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_types_map=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None, - _request_auth=None): + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): config = self.configuration @@ -173,15 +170,14 @@ class ApiClient(object): collection_formats) post_params.extend(self.files_parameters(files)) - # auth setting - self.update_params_for_auth( - header_params, query_params, auth_settings, - request_auth=_request_auth) - # body if body: body = self.sanitize_for_serialization(body) + # auth setting + self.update_params_for_auth(header_params, query_params, + auth_settings, resource_path, method, body) + # request url if _host is None: url = self.configuration.host + resource_path @@ -197,35 +193,38 @@ class ApiClient(object): _preload_content=_preload_content, _request_timeout=_request_timeout) except ApiException as e: - e.body = e.body.decode('utf-8') if six.PY3 else e.body + e.body = e.body.decode('utf-8') raise e + content_type = response_data.getheader('content-type') + self.last_response = response_data return_data = response_data if not _preload_content: {{^tornado}} - return return_data + return (return_data) {{/tornado}} {{#tornado}} raise tornado.gen.Return(return_data) {{/tornado}} - - response_type = response_types_map.get(response_data.status, None) + return return_data - if six.PY3 and response_type not in ["file", "bytes"]: + if response_type not in ["file", "bytes"]: match = None - content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" response_data.data = response_data.data.decode(encoding) # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) else: return_data = None @@ -244,9 +243,9 @@ class ApiClient(object): response_data.getheaders())) {{/tornado}} - def sanitize_for_serialization(self, obj): + @classmethod + def sanitize_for_serialization(cls, obj): """Builds a JSON POST object. - If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date @@ -254,106 +253,90 @@ class ApiClient(object): If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. - :param obj: The data to serialize. :return: The serialized form of data. """ - if obj is None: - return None - elif isinstance(obj, self.PRIMITIVE_TYPES): + if isinstance(obj, (ModelNormal, ModelComposed)): + return { + key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() + } + elif isinstance(obj, (str, int, float, none_type, bool)): return obj - elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] - elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) - elif isinstance(obj, (datetime.datetime, datetime.date)): + elif isinstance(obj, (datetime, date)): return obj.isoformat() - + elif isinstance(obj, ModelSimple): + return cls.sanitize_for_serialization(obj.value) + elif isinstance(obj, (list, tuple)): + return [cls.sanitize_for_serialization(item) for item in obj] if isinstance(obj, dict): - obj_dict = obj - else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None} - - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} - - def deserialize(self, response, response_type): + return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. :param response: RESTResponse object to be deserialized. - :param response_type: class literal for - deserialized object, or string of class name. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param _check_type: boolean, whether to check the types of the data + received from the server + :type _check_type: bool :return: deserialized object. """ # handle file downloading # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) + if response_type == (file_type,): + content_disposition = response.getheader("Content-Disposition") + return deserialize_file(response.data, self.configuration, + content_disposition=content_disposition) # fetch data from response object try: - data = json.loads(response.data) + received_data = json.loads(response.data) except ValueError: - data = response.data - - return self.__deserialize(data, response_type) - - def __deserialize(self, data, klass): - """Deserializes dict, list, str into an object. - - :param data: dict, list or str. - :param klass: class literal, or string of class name. - - :return: object. - """ - if data is None: - return None - - if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] - - if klass.startswith('dict('): - sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr({{modelPackage}}, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == datetime.date: - return self.__deserialize_date(data) - elif klass == datetime.datetime: - return self.__deserialize_datetime(data) - else: - return self.__deserialize_model(data, klass) - - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_types_map=None, auth_settings=None, - async_req=None, _return_http_data_only=None, - collection_formats=None,_preload_content=True, - _request_timeout=None, _host=None, _request_auth=None): + received_data = response.data + + # store our data under the key of 'received_data' so users have some + # context if they are deserializing a string and the data type is wrong + deserialized_data = validate_and_convert_types( + received_data, + response_type, + ['received_data'], + True, + _check_type, + configuration=self.configuration + ) + return deserialized_data + + def call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -368,25 +351,38 @@ class ApiClient(object): :param post_params dict: Request post form parameters, for `application/x-www-form-urlencoded`, `multipart/form-data`. :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param files: key -> field name, value -> a list of open file + objects for `multipart/form-data`. + :type files: dict :param async_req bool: execute request asynchronously + :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers + :type _return_http_data_only: bool, optional :param collection_formats: dict of collection formats for path, query, header, and post parameters. + :type collection_formats: dict, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. + :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_token: dict, optional + :param _check_type: boolean describing if the data back from the server + should have its type checked. + :type _check_type: bool, optional :return: If async_req parameter is True, the request will be called asynchronously. @@ -398,23 +394,23 @@ class ApiClient(object): return self.__call_api(resource_path, method, path_params, query_params, header_params, body, post_params, files, - response_types_map, auth_settings, + response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, - _request_auth) + _check_type) return self.pool.apply_async(self.__call_api, (resource_path, method, path_params, query_params, header_params, body, post_params, files, - response_types_map, + response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, - _host, _request_auth)) + _host, _check_type)) def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, @@ -436,8 +432,10 @@ class ApiClient(object): return self.rest_client.OPTIONS(url, query_params=query_params, headers=headers, + post_params=post_params, _preload_content=_preload_content, - _request_timeout=_request_timeout) + _request_timeout=_request_timeout, + body=body) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, @@ -485,7 +483,7 @@ class ApiClient(object): new_params = [] if collection_formats is None: collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': @@ -505,27 +503,37 @@ class ApiClient(object): new_params.append((k, v)) return new_params - def files_parameters(self, files=None): + def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): """Builds form parameters. - :param files: File parameters. - :return: Form parameters with files. + :param files: None or a dict with key=param_name and + value is a list of open file objects + :return: List of tuples of form parameters with file data """ - params = [] + if files is None: + return [] - if files: - for k, v in six.iteritems(files): - if not v: + params = [] + for param_name, file_instances in files.items(): + if file_instances is None: + # if the file field is nullable, skip None values + continue + for file_instance in file_instances: + if file_instance is None: + # if the file field is nullable, skip None values continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) + if file_instance.closed is True: + raise ApiValueError( + "Cannot read a closed file. The passed in file_type " + "for %s must be open." % param_name + ) + filename = os.path.basename(file_instance.name) + filedata = file_instance.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([param_name, tuple([filename, filedata, mimetype])])) + file_instance.close() return params @@ -562,156 +570,270 @@ class ApiClient(object): return content_types[0] def update_params_for_auth(self, headers, querys, auth_settings, - request_auth=None): + resource_path, method, body): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. - :param request_auth: if set, the provided settings will - override the token in the configuration. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. + The object type is the return value of _encoder.default(). """ if not auth_settings: return - if request_auth: - self._apply_auth_params(headers, querys, request_auth) - return - for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - self._apply_auth_params(headers, querys, auth_setting) - - def _apply_auth_params(self, headers, querys, auth_setting): - """Updates the request parameters based on a single auth_setting - - :param headers: Header parameters dict to be updated. - :param querys: Query parameters tuple list to be updated. - :param auth_setting: auth settings for the endpoint - """ - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) - - def __deserialize_file(self, response): - """Deserializes body to file - - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - :param response: RESTResponse. - :return: file path. + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] +{{#hasHttpSignatureMethods}} + else: + # The HTTP signature scheme requires multiple HTTP headers + # that are calculated dynamically. + signing_info = self.configuration.signing_info + auth_headers = signing_info.get_http_signature_headers( + resource_path, method, headers, body, querys) + headers.update(auth_headers) +{{/hasHttpSignatureMethods}} + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + settings (dict): see below key value pairs + 'response_type' (tuple/None): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ - fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) - os.close(fd) - os.remove(path) - - content_disposition = response.getheader("Content-Disposition") - if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "wb") as f: - f.write(response.data) - - return path + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only', + '_check_input_type', + '_check_return_type' + ]) + self.params_map['nullable'].extend(['_request_timeout']) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + extra_types = { + 'async_req': (bool,), + '_host_index': (none_type, int), + '_preload_content': (bool,), + '_request_timeout': (none_type, int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) + } + self.openapi_types.update(extra_types) + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param] + ) - def __deserialize_primitive(self, data, klass): - """Deserializes string to primitive type. + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param], + configuration=self.api_client.configuration + ) - :param data: str. - :param klass: class literal. + if kwargs['_check_input_type'] is False: + return - :return: int, long, float, str, bool. - """ - try: - return klass(data) - except UnicodeEncodeError: - return six.text_type(data) - except TypeError: - return data + for key, value in kwargs.items(): + fixed_val = validate_and_convert_types( + value, + self.openapi_types[key], + [key], + False, + kwargs['_check_input_type'], + configuration=self.api_client.configuration + ) + kwargs[key] = fixed_val + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in kwargs.items(): + param_location = self.location_map.get(param_name) + if param_location is None: + continue + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): + # param_value is already a list + params['file'][param_name] = param_value + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format - def __deserialize_object(self, value): - """Return an original value. + return params - :return: object. + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} + api_instance = {{classname}}() + api_instance.{{operationId}} # this is an instance of the class Endpoint + api_instance.{{operationId}}() # this invokes api_instance.{{operationId}}.__call__() + which then invokes the callable functions stored in that endpoint at + api_instance.{{operationId}}.callable or self.callable in this class +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} """ - return value + return self.callable(self, *args, **kwargs) - def __deserialize_date(self, string): - """Deserializes string to date. + def call_with_http_info(self, **kwargs): - :param string: str. - :return: date. - """ try: - return parse(string).date() - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) + index = self.api_client.configuration.server_operation_index.get( + self.settings['operation_id'], self.api_client.configuration.server_index + ) if kwargs['_host_index'] is None else kwargs['_host_index'] + server_variables = self.api_client.configuration.server_operation_variables.get( + self.settings['operation_id'], self.api_client.configuration.server_variables ) - - def __deserialize_datetime(self, string): - """Deserializes string to datetime. - - The string should be in iso8601 datetime format. - - :param string: str. - :return: datetime. - """ - try: - return parse(string) - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) + _host = self.api_client.configuration.get_host_from_settings( + index, variables=server_variables, servers=self.settings['servers'] ) + except IndexError: + if self.settings['servers']: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + _host = None + + for key, value in kwargs.items(): + if key not in self.params_map['all']: + raise ApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + # only throw this nullable ApiValueError if _check_input_type + # is False, if _check_input_type==True we catch this case + # in self.__validate_inputs + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) - def __deserialize_model(self, data, klass): - """Deserializes list or dict to model. + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - :param data: dict, list. - :param klass: class literal. - :return: model object. - """ - has_discriminator = False - if (hasattr(klass, 'get_real_child_model') - and klass.discriminator_value_class_map): - has_discriminator = True - - if not klass.openapi_types and has_discriminator is False: - return data - - kwargs = {} - if (data is not None and - klass.openapi_types is not None and - isinstance(data, (list, dict))): - for attr, attr_type in six.iteritems(klass.openapi_types): - if klass.attribute_map[attr] in data: - value = data[klass.attribute_map[attr]] - kwargs[attr] = self.__deserialize(value, attr_type) - - instance = klass(**kwargs) - - if has_discriminator: - klass_name = instance.get_real_child_model(data) - if klass_name: - instance = self.__deserialize(data, klass_name) - return instance + self.__validate_inputs(kwargs) + + params = self.__gather_params(kwargs) + + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) + + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list + + return self.api_client.call_api( + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], + _host=_host, + collection_formats=params['collection_format']) diff --git a/api_doc.mustache b/api_doc.mustache index dddec91719..36eac3ca91 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -11,7 +11,7 @@ Method | HTTP request | Description {{#operations}} {{#operation}} # **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) {{{summary}}}{{#notes}} @@ -35,18 +35,17 @@ Method | HTTP request | Description {{#isOAuth}} * OAuth Authentication ({{name}}): {{/isOAuth }} -{{> api_doc_example }} {{/authMethods}} {{/hasAuthMethods}} -{{^hasAuthMethods}} {{> api_doc_example }} -{{/hasAuthMethods}} ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} -{{/allParams}} +{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | +{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalParams}} ### Return type diff --git a/api_doc_example.mustache b/api_doc_example.mustache index 526c5950a0..bf989ae430 100644 --- a/api_doc_example.mustache +++ b/api_doc_example.mustache @@ -1,8 +1,10 @@ ```python -from __future__ import print_function import time import {{{packageName}}} -from {{{packageName}}}.rest import ApiException +from {{apiPackage}} import {{classVarName}} +{{#imports}} +{{{.}}} +{{/imports}} from pprint import pprint {{> python_doc_auth_partial}} # Enter a context with an instance of the API client @@ -13,14 +15,62 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: with {{{packageName}}}.ApiClient() as api_client: {{/hasAuthMethods}} # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) - {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} - {{/allParams}} + api_instance = {{classVarName}}.{{{classname}}}(api_client) +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/defaultValue}} +{{/requiredParams}} +{{#optionalParams}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} +{{/optionalParams}} +{{#requiredParams}} +{{#-last}} + # example passing only required values which don't have defaults set try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} - except ApiException as e: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-last}} +{{/requiredParams}} +{{#optionalParams}} +{{#-last}} + + # example passing only required values which don't have defaults set + # and optional values + try: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{^-last}}, {{/-last}}{{/optionalParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-last}} +{{/optionalParams}} +{{^requiredParams}} +{{^optionalParams}} + + # example, this endpoint has no required or optional parameters + try: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}() +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/optionalParams}} +{{/requiredParams}} ``` diff --git a/api_test.mustache b/api_test.mustache index 90fafc15f3..f9276b443c 100644 --- a/api_test.mustache +++ b/api_test.mustache @@ -2,20 +2,17 @@ {{>partial_header}} -from __future__ import absolute_import - import unittest import {{packageName}} from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 -from {{packageName}}.rest import ApiException class {{#operations}}Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" def setUp(self): - self.api = {{apiPackage}}.{{classVarName}}.{{classname}}() # noqa: E501 + self.api = {{classname}}() # noqa: E501 def tearDown(self): pass diff --git a/common_README.mustache b/common_README.mustache deleted file mode 100644 index 12fa1322a7..0000000000 --- a/common_README.mustache +++ /dev/null @@ -1,77 +0,0 @@ -```python -from __future__ import print_function -{{#apiInfo}}{{#apis}}{{#-last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/-last}}{{/apis}}{{/apiInfo}} -import time -import {{{packageName}}} -from {{{packageName}}}.rest import ApiException -from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} -{{> python_doc_auth_partial}} - -# Enter a context with an instance of the API client -with {{{packageName}}}.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = {{{packageName}}}.{{{classname}}}(api_client) - {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} - {{/allParams}} - - try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} - except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} -``` - -## Documentation for API Endpoints - -All URIs are relative to *{{basePath}}* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - -## Documentation For Models - -{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) -{{/model}}{{/models}} - -## Documentation For Authorization - -{{^authMethods}} - All endpoints do not require authorization. -{{/authMethods}} -{{#authMethods}} -{{#last}} Authentication schemes defined for the API:{{/last}} -## {{{name}}} - -{{#isApiKey}} -- **Type**: API key -- **API key parameter name**: {{{keyParamName}}} -- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} -{{/isApiKey}} -{{#isBasic}} -{{#isBasicBasic}} -- **Type**: HTTP basic authentication -{{/isBasicBasic}} -{{#isBasicBearer}} -- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} -{{/isBasicBearer}} -{{/isBasic}} -{{#isOAuth}} -- **Type**: OAuth -- **Flow**: {{{flow}}} -- **Authorization URL**: {{{authorizationUrl}}} -- **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - **{{{scope}}}**: {{{description}}} -{{/scopes}} -{{/isOAuth}} - -{{/authMethods}} - -## Author - -{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} -{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/configuration.mustache b/configuration.mustache index 9f2542f5a9..ca6fc37747 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -2,8 +2,6 @@ {{>partial_header}} -from __future__ import absolute_import - import copy import logging {{^asyncio}} @@ -12,8 +10,7 @@ import multiprocessing import sys import urllib3 -import six -from six.moves import http_client as httplib +from http import client as http_client from {{packageName}}.exceptions import ApiValueError @@ -302,9 +299,8 @@ conf = {{{packageName}}}.Configuration( # Enable client side validation self.client_side_validation = True + # Options to pass down to the underlying urllib3 socket self.socket_options = None - """Options to pass down to the underlying urllib3 socket - """ def __deepcopy__(self, memo): cls = self.__class__ @@ -389,7 +385,7 @@ conf = {{{packageName}}}.Configuration( # then add file handler and remove stream handler. self.logger_file_handler = logging.FileHandler(self.__logger_file) self.logger_file_handler.setFormatter(self.logger_formatter) - for _, logger in six.iteritems(self.logger): + for _, logger in self.logger.items(): logger.addHandler(self.logger_file_handler) @property @@ -411,17 +407,17 @@ conf = {{{packageName}}}.Configuration( self.__debug = value if self.__debug: # if debug status is True, turn on debug logging - for _, logger in six.iteritems(self.logger): + for _, logger in self.logger.items(): logger.setLevel(logging.DEBUG) - # turn on httplib debug - httplib.HTTPConnection.debuglevel = 1 + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 else: # if debug status is False, turn off debug logging, # setting log level to default `logging.WARNING` - for _, logger in six.iteritems(self.logger): + for _, logger in self.logger.items(): logger.setLevel(logging.WARNING) - # turn off httplib debug - httplib.HTTPConnection.debuglevel = 0 + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 @property def logger_format(self): diff --git a/exceptions.mustache b/exceptions.mustache index 6c77269533..8d445c6e24 100644 --- a/exceptions.mustache +++ b/exceptions.mustache @@ -2,8 +2,6 @@ {{>partial_header}} -import six - class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -120,35 +118,11 @@ class ApiException(OpenApiException): return error_message -class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(NotFoundException, self).__init__(status, reason, http_resp) - - -class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(UnauthorizedException, self).__init__(status, reason, http_resp) - - -class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(ForbiddenException, self).__init__(status, reason, http_resp) - - -class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - super(ServiceException, self).__init__(status, reason, http_resp) - - def render_path(path_to_item): """Returns a string representation of a path""" result = "" for pth in path_to_item: - if isinstance(pth, six.integer_types): + if isinstance(pth, int): result += "[{0}]".format(pth) else: result += "['{0}']".format(pth) diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache index 2cabff63c7..60c4b37893 100644 --- a/gitlab-ci.mustache +++ b/gitlab-ci.mustache @@ -3,7 +3,7 @@ stages: - test -.nosetest: +.tests: stage: test script: - pip install -r requirements.txt @@ -15,24 +15,15 @@ stages: - pytest --cov={{{packageName}}} {{/useNose}} -nosetest-2.7: - extends: .nosetest - image: python:2.7-alpine -nosetest-3.3: - extends: .nosetest - image: python:3.3-alpine -nosetest-3.4: - extends: .nosetest - image: python:3.4-alpine -nosetest-3.5: - extends: .nosetest +test-3.5: + extends: .tests image: python:3.5-alpine -nosetest-3.6: - extends: .nosetest +test-3.6: + extends: .tests image: python:3.6-alpine -nosetest-3.7: - extends: .nosetest +test-3.7: + extends: .tests image: python:3.7-alpine -nosetest-3.8: - extends: .nosetest +test-3.8: + extends: .tests image: python:3.8-alpine diff --git a/model.mustache b/model.mustache index 857a3e48fb..f2cb2368ca 100644 --- a/model.mustache +++ b/model.mustache @@ -1,254 +1,59 @@ # coding: utf-8 -{{>partial_header}} +{{> partial_header }} -import inspect -import pprint import re # noqa: F401 -import six - -from {{packageName}}.configuration import Configuration - - +import sys # noqa: F401 + +import nulltype # noqa: F401 + +from {{packageName}}.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) {{#models}} {{#model}} -class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """{{#allowableValues}} - - """ - allowed enum values - """ -{{#enumVars}} - {{name}} = {{{value}}}{{^-last}} -{{/-last}} -{{/enumVars}}{{/allowableValues}} - -{{#allowableValues}} - allowable_values = [{{#enumVars}}{{name}}{{^-last}}, {{/-last}}{{/enumVars}}] # noqa: E501 - -{{/allowableValues}} - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { -{{#vars}} - '{{name}}': '{{{dataType}}}'{{^-last}},{{/-last}} -{{/vars}} - } +{{#imports}} +{{#-first}} - attribute_map = { -{{#vars}} - '{{name}}': '{{baseName}}'{{^-last}},{{/-last}} -{{/vars}} - } -{{#discriminator}} - - discriminator_value_class_map = { -{{#children}} - '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} -{{/children}} - } -{{/discriminator}} - - def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}, local_vars_configuration=None): # noqa: E501 - """{{classname}} - a model defined in OpenAPI""" # noqa: E501 - if local_vars_configuration is None: - local_vars_configuration = Configuration() - self.local_vars_configuration = local_vars_configuration -{{#vars}}{{#-first}} +def lazy_import(): {{/-first}} - self._{{name}} = None -{{/vars}} - self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} -{{#vars}}{{#-first}} -{{/-first}} -{{#required}} - self.{{name}} = {{name}} -{{/required}} -{{^required}} -{{#isNullable}} - self.{{name}} = {{name}} -{{/isNullable}} -{{^isNullable}} - if {{name}} is not None: - self.{{name}} = {{name}} -{{/isNullable}} -{{/required}} -{{/vars}} - -{{#vars}} - @property - def {{name}}(self): - """Gets the {{name}} of this {{classname}}. # noqa: E501 + {{{.}}} +{{/imports}} -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - :return: The {{name}} of this {{classname}}. # noqa: E501 - :rtype: {{dataType}} - """ - return self._{{name}} - - @{{name}}.setter - def {{name}}(self, {{name}}): - """Sets the {{name}} of this {{classname}}. - -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type {{name}}: {{dataType}} - """ -{{^isNullable}} -{{#required}} - if self.local_vars_configuration.client_side_validation and {{name}} is None: # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 -{{/required}} -{{/isNullable}} -{{#isEnum}} -{{#isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 +{{^interfaces}} {{#isArray}} - if (self.local_vars_configuration.client_side_validation and - not set({{{name}}}).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) +{{> model_templates/model_simple }} {{/isArray}} -{{#isMap}} - if (self.local_vars_configuration.client_side_validation and - not set({{{name}}}.keys()).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isMap}} -{{/isContainer}} -{{^isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if self.local_vars_configuration.client_side_validation and {{{name}}} not in allowed_values: # noqa: E501 - raise ValueError( - "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 - .format({{{name}}}, allowed_values) - ) -{{/isContainer}} +{{#isEnum}} +{{> model_templates/model_simple }} {{/isEnum}} +{{#isAlias}} +{{> model_templates/model_simple }} +{{/isAlias}} +{{^isArray}} {{^isEnum}} -{{#hasValidation}} -{{#maxLength}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and len({{name}}) > {{maxLength}}): - raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 -{{/maxLength}} -{{#minLength}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and len({{name}}) < {{minLength}}): - raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 -{{/minLength}} -{{#maximum}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}): # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 -{{/maximum}} -{{#minimum}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}): # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 -{{/minimum}} -{{#pattern}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}})): # noqa: E501 - raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 -{{/pattern}} -{{#maxItems}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and len({{name}}) > {{maxItems}}): - raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 -{{/maxItems}} -{{#minItems}} - if (self.local_vars_configuration.client_side_validation and - {{name}} is not None and len({{name}}) < {{minItems}}): - raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 -{{/minItems}} -{{/hasValidation}} +{{^isAlias}} +{{> model_templates/model_normal }} +{{/isAlias}} {{/isEnum}} - - self._{{name}} = {{name}} - -{{/vars}} -{{#discriminator}} - def get_real_child_model(self, data): - """Returns the real base class specified by the discriminator""" - discriminator_key = self.attribute_map[self.discriminator] - discriminator_value = data[discriminator_key] - return self.discriminator_value_class_map.get(discriminator_value) - -{{/discriminator}} - def to_dict(self, serialize=False): - """Returns the model properties as a dict""" - result = {} - - def convert(x): - if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args - if len(args) == 1: - return x.to_dict() - else: - return x.to_dict(serialize) - else: - return x - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - attr = self.attribute_map.get(attr, attr) if serialize else attr - if isinstance(value, list): - result[attr] = list(map( - lambda x: convert(x), - value - )) - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], convert(item[1])), - value.items() - )) - else: - result[attr] = convert(value) - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False - - return self.to_dict() == other.to_dict() - - def __ne__(self, other): - """Returns true if both objects are not equal""" - if not isinstance(other, {{classname}}): - return True - - return self.to_dict() != other.to_dict() +{{/isArray}} +{{/interfaces}} +{{#interfaces}} +{{#-last}} +{{> model_templates/model_composed }} +{{/-last}} +{{/interfaces}} {{/model}} {{/models}} diff --git a/model_doc.mustache b/model_doc.mustache index fc90a2e0fc..7971d6c85f 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -5,8 +5,31 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} -{{/vars}} +{{#isEnum}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}}{{#allowableValues}}{{#defaultValue}}, {{/defaultValue}} must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} +{{/isEnum}} +{{#isAlias}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isAlias}} +{{#isArray}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}}{{#arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isArray}} +{{#requiredVars}} +{{^defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +{{/defaultValue}} +{{/requiredVars}} +{{#requiredVars}} +{{#defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +{{/defaultValue}} +{{/requiredVars}} +{{#optionalVars}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalVars}} +{{#additionalPropertiesType}} +**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] +{{/additionalPropertiesType}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/python-experimental/model_templates/classvars.mustache b/model_templates/classvars.mustache similarity index 94% rename from python-experimental/model_templates/classvars.mustache rename to model_templates/classvars.mustache index f2ea42679a..88ae5df9f1 100644 --- a/python-experimental/model_templates/classvars.mustache +++ b/model_templates/classvars.mustache @@ -44,18 +44,18 @@ validations = { {{#hasValidation}} ('value',): { -{{> python-experimental/model_templates/validations }} +{{> model_templates/validations }} {{/hasValidation}} {{#requiredVars}} {{#hasValidation}} ('{{name}}',): { -{{> python-experimental/model_templates/validations }} +{{> model_templates/validations }} {{/hasValidation}} {{/requiredVars}} {{#optionalVars}} {{#hasValidation}} ('{{name}}',): { -{{> python-experimental/model_templates/validations }} +{{> model_templates/validations }} {{/hasValidation}} {{/optionalVars}} } diff --git a/python-experimental/model_templates/docstring_allowed.mustache b/model_templates/docstring_allowed.mustache similarity index 100% rename from python-experimental/model_templates/docstring_allowed.mustache rename to model_templates/docstring_allowed.mustache diff --git a/python-experimental/model_templates/docstring_init_required_kwargs.mustache b/model_templates/docstring_init_required_kwargs.mustache similarity index 100% rename from python-experimental/model_templates/docstring_init_required_kwargs.mustache rename to model_templates/docstring_init_required_kwargs.mustache diff --git a/python-experimental/model_templates/docstring_openapi_validations.mustache b/model_templates/docstring_openapi_validations.mustache similarity index 100% rename from python-experimental/model_templates/docstring_openapi_validations.mustache rename to model_templates/docstring_openapi_validations.mustache diff --git a/python-experimental/model_templates/method_init_composed.mustache b/model_templates/method_init_composed.mustache similarity index 96% rename from python-experimental/model_templates/method_init_composed.mustache rename to model_templates/method_init_composed.mustache index 7e64549acd..8b3650b33a 100644 --- a/python-experimental/model_templates/method_init_composed.mustache +++ b/model_templates/method_init_composed.mustache @@ -10,7 +10,7 @@ '_additional_properties_model_instances', ]) -{{> python-experimental/model_templates/method_init_shared }} +{{> model_templates/method_init_shared }} constant_args = { '_check_type': _check_type, diff --git a/python-experimental/model_templates/method_init_normal.mustache b/model_templates/method_init_normal.mustache similarity index 92% rename from python-experimental/model_templates/method_init_normal.mustache rename to model_templates/method_init_normal.mustache index 4fee1c8449..e670b4ffb4 100644 --- a/python-experimental/model_templates/method_init_normal.mustache +++ b/model_templates/method_init_normal.mustache @@ -7,7 +7,7 @@ '_visited_composed_classes', ]) -{{> python-experimental/model_templates/method_init_shared }} +{{> model_templates/method_init_shared }} {{#isEnum}} self.value = value diff --git a/python-experimental/model_templates/method_init_shared.mustache b/model_templates/method_init_shared.mustache similarity index 96% rename from python-experimental/model_templates/method_init_shared.mustache rename to model_templates/method_init_shared.mustache index e500b11e70..f3497ef53b 100644 --- a/python-experimental/model_templates/method_init_shared.mustache +++ b/model_templates/method_init_shared.mustache @@ -19,7 +19,7 @@ {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{/defaultValue}} {{/requiredVars}} -{{> python-experimental/model_templates/docstring_init_required_kwargs }} +{{> model_templates/docstring_init_required_kwargs }} {{#optionalVars}} {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 {{/optionalVars}} diff --git a/python-experimental/model_templates/method_init_simple.mustache b/model_templates/method_init_simple.mustache similarity index 97% rename from python-experimental/model_templates/method_init_simple.mustache rename to model_templates/method_init_simple.mustache index b71b80667c..2340cf74ef 100644 --- a/python-experimental/model_templates/method_init_simple.mustache +++ b/model_templates/method_init_simple.mustache @@ -18,7 +18,7 @@ Keyword Args: value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 -{{> python-experimental/model_templates/docstring_init_required_kwargs }} +{{> model_templates/docstring_init_required_kwargs }} """ if 'value' in kwargs: diff --git a/python-experimental/model_templates/method_set_attribute.mustache b/model_templates/method_set_attribute.mustache similarity index 100% rename from python-experimental/model_templates/method_set_attribute.mustache rename to model_templates/method_set_attribute.mustache diff --git a/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/model_templates/methods_setattr_getattr_composed.mustache similarity index 100% rename from python-experimental/model_templates/methods_setattr_getattr_composed.mustache rename to model_templates/methods_setattr_getattr_composed.mustache diff --git a/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/model_templates/methods_setattr_getattr_normal.mustache similarity index 100% rename from python-experimental/model_templates/methods_setattr_getattr_normal.mustache rename to model_templates/methods_setattr_getattr_normal.mustache diff --git a/python-experimental/model_templates/methods_shared.mustache b/model_templates/methods_shared.mustache similarity index 100% rename from python-experimental/model_templates/methods_shared.mustache rename to model_templates/methods_shared.mustache diff --git a/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache b/model_templates/methods_todict_tostr_eq_shared.mustache similarity index 100% rename from python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache rename to model_templates/methods_todict_tostr_eq_shared.mustache diff --git a/python-experimental/model_templates/methods_tostr_eq_simple.mustache b/model_templates/methods_tostr_eq_simple.mustache similarity index 100% rename from python-experimental/model_templates/methods_tostr_eq_simple.mustache rename to model_templates/methods_tostr_eq_simple.mustache diff --git a/python-experimental/model_templates/model_composed.mustache b/model_templates/model_composed.mustache similarity index 85% rename from python-experimental/model_templates/model_composed.mustache rename to model_templates/model_composed.mustache index dd61b23c79..76fe3a8f50 100644 --- a/python-experimental/model_templates/model_composed.mustache +++ b/model_templates/model_composed.mustache @@ -5,15 +5,15 @@ class {{classname}}(ModelComposed): Do not edit the class manually. Attributes: -{{> python-experimental/model_templates/docstring_allowed }} +{{> model_templates/docstring_allowed }} attribute_map (dict): The key is attribute name and the value is json key in definition. discriminator_value_class_map (dict): A dict to go from the discriminator variable value to the discriminator class name. -{{> python-experimental/model_templates/docstring_openapi_validations }} +{{> model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvars }} +{{> model_templates/classvars }} attribute_map = { {{#requiredVars}} @@ -24,7 +24,7 @@ class {{classname}}(ModelComposed): {{/optionalVars}} } -{{> python-experimental/model_templates/method_init_composed }} +{{> model_templates/method_init_composed }} @cached_property def _composed_schemas(): diff --git a/python-experimental/model_templates/model_normal.mustache b/model_templates/model_normal.mustache similarity index 73% rename from python-experimental/model_templates/model_normal.mustache rename to model_templates/model_normal.mustache index af130c66a7..9aada8f5a0 100644 --- a/python-experimental/model_templates/model_normal.mustache +++ b/model_templates/model_normal.mustache @@ -5,15 +5,15 @@ class {{classname}}(ModelNormal): Do not edit the class manually. Attributes: -{{> python-experimental/model_templates/docstring_allowed }} +{{> model_templates/docstring_allowed }} attribute_map (dict): The key is attribute name and the value is json key in definition. discriminator_value_class_map (dict): A dict to go from the discriminator variable value to the discriminator class name. -{{> python-experimental/model_templates/docstring_openapi_validations }} +{{> model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvars }} +{{> model_templates/classvars }} attribute_map = { {{#requiredVars}} @@ -26,4 +26,4 @@ class {{classname}}(ModelNormal): _composed_schemas = {} -{{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file +{{> model_templates/method_init_normal}} \ No newline at end of file diff --git a/python-experimental/model_templates/model_simple.mustache b/model_templates/model_simple.mustache similarity index 50% rename from python-experimental/model_templates/model_simple.mustache rename to model_templates/model_simple.mustache index 0b7d1860dd..a4055af756 100644 --- a/python-experimental/model_templates/model_simple.mustache +++ b/model_templates/model_simple.mustache @@ -5,14 +5,14 @@ class {{classname}}(ModelSimple): Do not edit the class manually. Attributes: -{{> python-experimental/model_templates/docstring_allowed }} -{{> python-experimental/model_templates/docstring_openapi_validations }} +{{> model_templates/docstring_allowed }} +{{> model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvars }} +{{> model_templates/classvars }} attribute_map = {} _composed_schemas = None -{{> python-experimental/model_templates/method_init_simple}} \ No newline at end of file +{{> model_templates/method_init_simple}} \ No newline at end of file diff --git a/python-experimental/model_templates/validations.mustache b/model_templates/validations.mustache similarity index 100% rename from python-experimental/model_templates/validations.mustache rename to model_templates/validations.mustache diff --git a/model_test.mustache b/model_test.mustache index cd55662e10..669cc12185 100644 --- a/model_test.mustache +++ b/model_test.mustache @@ -2,16 +2,17 @@ {{>partial_header}} -from __future__ import absolute_import - +import sys import unittest -import datetime +import {{packageName}} {{#models}} {{#model}} -import {{packageName}} -from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 -from {{packageName}}.rest import ApiException +{{#imports}} +{{{.}}} +{{/imports}} +from {{modelPackage}}.{{classFilename}} import {{classname}} + class Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" @@ -22,31 +23,11 @@ class Test{{classname}}(unittest.TestCase): def tearDown(self): pass - def make_instance(self, include_optional): - """Test {{classname}} - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 - if include_optional : - return {{classname}}( -{{#vars}} - {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}{{^-last}}, {{/-last}} -{{/vars}} - ) - else : - return {{classname}}( -{{#vars}} -{{#required}} - {{name}} = {{#example}}{{{.}}}{{/example}}{{^example}}None{{/example}}, -{{/required}} -{{/vars}} - ) - def test{{classname}}(self): """Test {{classname}}""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) + # FIXME: construct object with mandatory attributes with example values + # model = {{classname}}() # noqa: E501 + pass {{/model}} {{/models}} diff --git a/python-experimental/model_utils.mustache b/model_utils.mustache similarity index 99% rename from python-experimental/model_utils.mustache rename to model_utils.mustache index 72a5cbe429..1523dbc2d7 100644 --- a/python-experimental/model_utils.mustache +++ b/model_utils.mustache @@ -96,9 +96,9 @@ def composed_model_input_classes(cls): class OpenApiModel(object): """The base class for all OpenAPIModels""" -{{> python-experimental/model_templates/method_set_attribute }} +{{> model_templates/method_set_attribute }} -{{> python-experimental/model_templates/methods_shared }} +{{> model_templates/methods_shared }} def __new__(cls, *args, **kwargs): # this function uses the discriminator to @@ -218,18 +218,18 @@ class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their swagger/openapi""" -{{> python-experimental/model_templates/methods_setattr_getattr_normal }} +{{> model_templates/methods_setattr_getattr_normal }} -{{> python-experimental/model_templates/methods_tostr_eq_simple }} +{{> model_templates/methods_tostr_eq_simple }} class ModelNormal(OpenApiModel): """the parent class of models whose type == object in their swagger/openapi""" -{{> python-experimental/model_templates/methods_setattr_getattr_normal }} +{{> model_templates/methods_setattr_getattr_normal }} -{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} +{{> model_templates/methods_todict_tostr_eq_shared}} class ModelComposed(OpenApiModel): @@ -258,9 +258,9 @@ class ModelComposed(OpenApiModel): which contain the value that the key is referring to. """ -{{> python-experimental/model_templates/methods_setattr_getattr_composed }} +{{> model_templates/methods_setattr_getattr_composed }} -{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} +{{> model_templates/methods_todict_tostr_eq_shared}} COERCION_INDEX_BY_TYPE = { diff --git a/python-experimental/README.mustache b/python-experimental/README.mustache deleted file mode 100644 index 7368913ef8..0000000000 --- a/python-experimental/README.mustache +++ /dev/null @@ -1,55 +0,0 @@ -# {{{projectName}}} -{{#appDescriptionWithNewLines}} -{{{appDescriptionWithNewLines}}} -{{/appDescriptionWithNewLines}} - -This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: {{appVersion}} -- Package version: {{packageVersion}} -{{^hideGenerationTimestamp}} -- Build date: {{generatedDate}} -{{/hideGenerationTimestamp}} -- Build package: {{generatorClass}} -{{#infoUrl}} -For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) -{{/infoUrl}} - -## Requirements. - -Python >= 3.5 - -## Installation & Usage -### pip install - -If the python package is hosted on a repository, you can install directly using: - -```sh -pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git -``` -(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) - -Then import the package: -```python -import {{{packageName}}} -``` - -### Setuptools - -Install via [Setuptools](http://pypi.python.org/pypi/setuptools). - -```sh -python setup.py install --user -``` -(or `sudo python setup.py install` to install the package for all users) - -Then import the package: -```python -import {{{packageName}}} -``` - -## Getting Started - -Please follow the [installation procedure](#installation--usage) and then run the following: - -{{> python-experimental/README_common }} diff --git a/python-experimental/README_onlypackage.mustache b/python-experimental/README_onlypackage.mustache deleted file mode 100644 index 3ef048b67a..0000000000 --- a/python-experimental/README_onlypackage.mustache +++ /dev/null @@ -1,43 +0,0 @@ -# {{{projectName}}} -{{#appDescription}} -{{{appDescription}}} -{{/appDescription}} - -The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: {{appVersion}} -- Package version: {{packageVersion}} -{{^hideGenerationTimestamp}} -- Build date: {{generatedDate}} -{{/hideGenerationTimestamp}} -- Build package: {{generatorClass}} -{{#infoUrl}} -For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) -{{/infoUrl}} - -## Requirements. - -Python >= 3.5 - -## Installation & Usage - -This python library package is generated without supporting files like setup.py or requirements files - -To be able to use it, you will need these dependencies in your own package that uses this library: - -* urllib3 >= 1.15 -* certifi -* python-dateutil -{{#asyncio}} -* aiohttp -{{/asyncio}} -{{#tornado}} -* tornado>=4.2,<5 -{{/tornado}} - -## Getting Started - -In your own code, to use this library to connect and interact with {{{projectName}}}, -you can run the following: - -{{> python-experimental/README_common }} diff --git a/python-experimental/__init__api.mustache b/python-experimental/__init__api.mustache deleted file mode 100644 index 8a9e6b91b9..0000000000 --- a/python-experimental/__init__api.mustache +++ /dev/null @@ -1,9 +0,0 @@ -{{#apiInfo}} -{{#apis}} -{{#-first}} -# do not import all apis into this module because that uses a lot of memory and stack frames -# if you need the ability to import all apis from one package, import them with -# from {{packageName}}.apis import {{classname}} -{{/-first}} -{{/apis}} -{{/apiInfo}} diff --git a/python-experimental/__init__model.mustache b/python-experimental/__init__model.mustache deleted file mode 100644 index cfe32b7849..0000000000 --- a/python-experimental/__init__model.mustache +++ /dev/null @@ -1,5 +0,0 @@ -# we can not import model classes here because that would create a circular -# reference which would not work in python2 -# do not import all models into this module because that uses a lot of memory and stack frames -# if you need the ability to import all models from one package, import them with -# from {{packageName}.models import ModelA, ModelB diff --git a/python-experimental/__init__package.mustache b/python-experimental/__init__package.mustache deleted file mode 100644 index d7ff5b8260..0000000000 --- a/python-experimental/__init__package.mustache +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -{{>partial_header}} - -__version__ = "{{packageVersion}}" - -# import ApiClient -from {{packageName}}.api_client import ApiClient - -# import Configuration -from {{packageName}}.configuration import Configuration -{{#hasHttpSignatureMethods}} -from {{packageName}}.signing import HttpSigningConfiguration -{{/hasHttpSignatureMethods}} - -# import exceptions -from {{packageName}}.exceptions import OpenApiException -from {{packageName}}.exceptions import ApiAttributeError -from {{packageName}}.exceptions import ApiTypeError -from {{packageName}}.exceptions import ApiValueError -from {{packageName}}.exceptions import ApiKeyError -from {{packageName}}.exceptions import ApiException -{{#recursionLimit}} - -__import__('sys').setrecursionlimit({{{.}}}) -{{/recursionLimit}} diff --git a/python-experimental/api.mustache b/python-experimental/api.mustache deleted file mode 100644 index 0e76b3f29f..0000000000 --- a/python-experimental/api.mustache +++ /dev/null @@ -1,308 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import re # noqa: F401 -import sys # noqa: F401 - -from {{packageName}}.api_client import ApiClient, Endpoint -from {{packageName}}.model_utils import ( # noqa: F401 - check_allowed_values, - check_validations, - date, - datetime, - file_type, - none_type, - validate_and_convert_types -) -{{#imports}} -{{{import}}} -{{/imports}} - - -{{#operations}} -class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None): - if api_client is None: - api_client = ApiClient() - self.api_client = api_client -{{#operation}} - - def __{{operationId}}( - self, -{{#requiredParams}} -{{^defaultValue}} - {{paramName}}, -{{/defaultValue}} -{{/requiredParams}} -{{#requiredParams}} -{{#defaultValue}} - {{paramName}}={{{defaultValue}}}, -{{/defaultValue}} -{{/requiredParams}} - **kwargs - ): - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 - -{{#notes}} - {{{notes}}} # noqa: E501 -{{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) - >>> result = thread.get() - -{{#requiredParams}} -{{#-last}} - Args: -{{/-last}} -{{/requiredParams}} -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}} -{{/defaultValue}} -{{/requiredParams}} -{{#requiredParams}} -{{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] -{{/defaultValue}} -{{/requiredParams}} - - Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} - _return_http_data_only (bool): response data without head status - code and headers. Default is True. - _preload_content (bool): if False, the urllib3.HTTPResponse object - will be returned without reading/decoding response data. - Default is True. - _request_timeout (float/tuple): timeout setting for this request. If one - number provided, it will be total request timeout. It can also - be a pair (tuple) of (connection, read) timeouts. - Default is None. - _check_input_type (bool): specifies if type checking - should be done one the data sent to the server. - Default is True. - _check_return_type (bool): specifies if type checking - should be done one the data received from the server. - Default is True. - _host_index (int/None): specifies the index of the server - that we want to use. - Default is read from the configuration. - async_req (bool): execute request asynchronously - - Returns: - {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} - If the method is called asynchronously, returns the request - thread. - """ - kwargs['async_req'] = kwargs.get( - 'async_req', False - ) - kwargs['_return_http_data_only'] = kwargs.get( - '_return_http_data_only', True - ) - kwargs['_preload_content'] = kwargs.get( - '_preload_content', True - ) - kwargs['_request_timeout'] = kwargs.get( - '_request_timeout', None - ) - kwargs['_check_input_type'] = kwargs.get( - '_check_input_type', True - ) - kwargs['_check_return_type'] = kwargs.get( - '_check_return_type', True - ) - kwargs['_host_index'] = kwargs.get('_host_index') -{{#requiredParams}} - kwargs['{{paramName}}'] = \ - {{paramName}} -{{/requiredParams}} - return self.call_with_http_info(**kwargs) - - self.{{operationId}} = Endpoint( - settings={ - 'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}}, -{{#authMethods}} -{{#-first}} - 'auth': [ -{{/-first}} - '{{name}}'{{^-last}},{{/-last}} -{{#-last}} - ], -{{/-last}} -{{/authMethods}} -{{^authMethods}} - 'auth': [], -{{/authMethods}} - 'endpoint_path': '{{{path}}}', - 'operation_id': '{{operationId}}', - 'http_method': '{{httpMethod}}', -{{#servers}} -{{#-first}} - 'servers': [ -{{/-first}} - { - 'url': "{{{url}}}", - 'description': "{{{description}}}{{^description}}No description provided{{/description}}", - {{#variables}} - {{#-first}} - 'variables': { - {{/-first}} - '{{{name}}}': { - 'description': "{{{description}}}{{^description}}No description provided{{/description}}", - 'default_value': "{{{defaultValue}}}", - {{#enumValues}} - {{#-first}} - 'enum_values': [ - {{/-first}} - "{{{.}}}"{{^-last}},{{/-last}} - {{#-last}} - ] - {{/-last}} - {{/enumValues}} - }{{^-last}},{{/-last}} - {{#-last}} - } - {{/-last}} - {{/variables}} - }, -{{#-last}} - ] -{{/-last}} -{{/servers}} -{{^servers}} - 'servers': None, -{{/servers}} - }, - params_map={ - 'all': [ -{{#allParams}} - '{{paramName}}', -{{/allParams}} - ], -{{#requiredParams}} -{{#-first}} - 'required': [ -{{/-first}} - '{{paramName}}', -{{#-last}} - ], -{{/-last}} -{{/requiredParams}} -{{^requiredParams}} - 'required': [], -{{/requiredParams}} - 'nullable': [ -{{#allParams}} -{{#isNullable}} - '{{paramName}}', -{{/isNullable}} -{{/allParams}} - ], - 'enum': [ -{{#allParams}} -{{#isEnum}} - '{{paramName}}', -{{/isEnum}} -{{/allParams}} - ], - 'validation': [ -{{#allParams}} -{{#hasValidation}} - '{{paramName}}', -{{/hasValidation}} -{{/allParams}} - ] - }, - root_map={ - 'validations': { -{{#allParams}} -{{#hasValidation}} - ('{{paramName}}',): { -{{#maxLength}} - 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} - 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} - 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} - 'min_items': {{minItems}},{{/minItems}}{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} - 'regex': { - 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} - {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - },{{/pattern}} - }, -{{/hasValidation}} -{{/allParams}} - }, - 'allowed_values': { -{{#allParams}} -{{#isEnum}} - ('{{paramName}}',): { -{{#isNullable}} - 'None': None,{{/isNullable}}{{#allowableValues}}{{#enumVars}} - "{{name}}": {{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} - }, -{{/isEnum}} -{{/allParams}} - }, - 'openapi_types': { -{{#allParams}} - '{{paramName}}': - ({{{dataType}}},), -{{/allParams}} - }, - 'attribute_map': { -{{#allParams}} -{{^isBodyParam}} - '{{paramName}}': '{{baseName}}', -{{/isBodyParam}} -{{/allParams}} - }, - 'location_map': { -{{#allParams}} - '{{paramName}}': '{{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isCookieParam}}cookie{{/isCookieParam}}{{#isBodyParam}}body{{/isBodyParam}}', -{{/allParams}} - }, - 'collection_format_map': { -{{#allParams}} -{{#collectionFormat}} - '{{paramName}}': '{{collectionFormat}}', -{{/collectionFormat}} -{{/allParams}} - } - }, - headers_map={ -{{#hasProduces}} - 'accept': [ -{{#produces}} - '{{{mediaType}}}'{{^-last}},{{/-last}} -{{/produces}} - ], -{{/hasProduces}} -{{^hasProduces}} - 'accept': [], -{{/hasProduces}} -{{#hasConsumes}} - 'content_type': [ -{{#consumes}} - '{{{mediaType}}}'{{^-last}},{{/-last}} -{{/consumes}} - ] -{{/hasConsumes}} -{{^hasConsumes}} - 'content_type': [], -{{/hasConsumes}} - }, - api_client=api_client, - callable=__{{operationId}} - ) -{{/operation}} -{{/operations}} diff --git a/python-experimental/api_client.mustache b/python-experimental/api_client.mustache deleted file mode 100644 index fd3d0b8a20..0000000000 --- a/python-experimental/api_client.mustache +++ /dev/null @@ -1,839 +0,0 @@ -# coding: utf-8 -{{>partial_header}} - -import json -import atexit -import mimetypes -from multiprocessing.pool import ThreadPool -import io -import os -import re -import typing -from urllib.parse import quote - -{{#tornado}} -import tornado.gen -{{/tornado}} - -from {{packageName}} import rest -from {{packageName}}.configuration import Configuration -from {{packageName}}.exceptions import ApiTypeError, ApiValueError, ApiException -from {{packageName}}.model_utils import ( - ModelNormal, - ModelSimple, - ModelComposed, - check_allowed_values, - check_validations, - date, - datetime, - deserialize_file, - file_type, - model_to_dict, - none_type, - validate_and_convert_types -) - - -class ApiClient(object): - """Generic API client for OpenAPI client library builds. - - OpenAPI generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the OpenAPI - templates. - - NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param configuration: .Configuration object for this client - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to - the API. - :param cookie: a cookie to include in the header when making calls - to the API - :param pool_threads: The number of threads to use for async requests - to the API. More threads means more concurrent API requests. - """ - - _pool = None - - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=1): - if configuration is None: - configuration = Configuration() - self.configuration = configuration - self.pool_threads = pool_threads - - self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - self.cookie = cookie - # Set default User-Agent. - self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def close(self): - if self._pool: - self._pool.close() - self._pool.join() - self._pool = None - if hasattr(atexit, 'unregister'): - atexit.unregister(self.close) - - @property - def pool(self): - """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. - """ - if self._pool is None: - atexit.register(self.close) - self._pool = ThreadPool(self.pool_threads) - return self._pool - - @property - def user_agent(self): - """User agent for this API client""" - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - self.default_headers['User-Agent'] = value - - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - - {{#tornado}} - @tornado.gen.coroutine - {{/tornado}} - {{#asyncio}}async {{/asyncio}}def __call_api( - self, - resource_path: str, - method: str, - path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, - query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, - header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, - body: typing.Optional[typing.Any] = None, - post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, - files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, - response_type: typing.Optional[typing.Tuple[typing.Any]] = None, - auth_settings: typing.Optional[typing.List[str]] = None, - _return_http_data_only: typing.Optional[bool] = None, - collection_formats: typing.Optional[typing.Dict[str, str]] = None, - _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - _host: typing.Optional[str] = None, - _check_type: typing.Optional[bool] = None - ): - - config = self.configuration - - # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) - if self.cookie: - header_params['Cookie'] = self.cookie - if header_params: - header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) - - # path parameters - if path_params: - path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) - for k, v in path_params: - # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) - ) - - # query parameters - if query_params: - query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) - - # post parameters - if post_params or files: - post_params = post_params if post_params else [] - post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) - post_params.extend(self.files_parameters(files)) - - # body - if body: - body = self.sanitize_for_serialization(body) - - # auth setting - self.update_params_for_auth(header_params, query_params, - auth_settings, resource_path, method, body) - - # request url - if _host is None: - url = self.configuration.host + resource_path - else: - # use server/host defined in path or operation instead - url = _host + resource_path - - try: - # perform request and return response - response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) - except ApiException as e: - e.body = e.body.decode('utf-8') - raise e - - content_type = response_data.getheader('content-type') - - self.last_response = response_data - - return_data = response_data - - if not _preload_content: - {{^tornado}} - return (return_data) - {{/tornado}} - {{#tornado}} - raise tornado.gen.Return(return_data) - {{/tornado}} - return return_data - - if response_type not in ["file", "bytes"]: - match = None - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_data.data = response_data.data.decode(encoding) - - # deserialize response data - if response_type: - return_data = self.deserialize( - response_data, - response_type, - _check_type - ) - else: - return_data = None - -{{^tornado}} - if _return_http_data_only: - return (return_data) - else: - return (return_data, response_data.status, - response_data.getheaders()) -{{/tornado}} -{{#tornado}} - if _return_http_data_only: - raise tornado.gen.Return(return_data) - else: - raise tornado.gen.Return((return_data, response_data.status, - response_data.getheaders())) -{{/tornado}} - - @classmethod - def sanitize_for_serialization(cls, obj): - """Builds a JSON POST object. - If obj is None, return None. - If obj is str, int, long, float, bool, return directly. - If obj is datetime.datetime, datetime.date - convert to string in iso8601 format. - If obj is list, sanitize each element in the list. - If obj is dict, return the dict. - If obj is OpenAPI model, return the properties dict. - :param obj: The data to serialize. - :return: The serialized form of data. - """ - if isinstance(obj, (ModelNormal, ModelComposed)): - return { - key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() - } - elif isinstance(obj, (str, int, float, none_type, bool)): - return obj - elif isinstance(obj, (datetime, date)): - return obj.isoformat() - elif isinstance(obj, ModelSimple): - return cls.sanitize_for_serialization(obj.value) - elif isinstance(obj, (list, tuple)): - return [cls.sanitize_for_serialization(item) for item in obj] - if isinstance(obj, dict): - return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} - raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) - - def deserialize(self, response, response_type, _check_type): - """Deserializes response into an object. - - :param response: RESTResponse object to be deserialized. - :param response_type: For the response, a tuple containing: - valid classes - a list containing valid classes (for list schemas) - a dict containing a tuple of valid classes as the value - Example values: - (str,) - (Pet,) - (float, none_type) - ([int, none_type],) - ({str: (bool, str, int, float, date, datetime, str, none_type)},) - :param _check_type: boolean, whether to check the types of the data - received from the server - :type _check_type: bool - - :return: deserialized object. - """ - # handle file downloading - # save response body into a tmp file and return the instance - if response_type == (file_type,): - content_disposition = response.getheader("Content-Disposition") - return deserialize_file(response.data, self.configuration, - content_disposition=content_disposition) - - # fetch data from response object - try: - received_data = json.loads(response.data) - except ValueError: - received_data = response.data - - # store our data under the key of 'received_data' so users have some - # context if they are deserializing a string and the data type is wrong - deserialized_data = validate_and_convert_types( - received_data, - response_type, - ['received_data'], - True, - _check_type, - configuration=self.configuration - ) - return deserialized_data - - def call_api( - self, - resource_path: str, - method: str, - path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, - query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, - header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, - body: typing.Optional[typing.Any] = None, - post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, - files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, - response_type: typing.Optional[typing.Tuple[typing.Any]] = None, - auth_settings: typing.Optional[typing.List[str]] = None, - async_req: typing.Optional[bool] = None, - _return_http_data_only: typing.Optional[bool] = None, - collection_formats: typing.Optional[typing.Dict[str, str]] = None, - _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - _host: typing.Optional[str] = None, - _check_type: typing.Optional[bool] = None - ): - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async_req request, set the async_req parameter. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param path_params: Path parameters in the url. - :param query_params: Query parameters in the url. - :param header_params: Header parameters to be - placed in the request header. - :param body: Request body. - :param post_params dict: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings list: Auth Settings names for the request. - :param response_type: For the response, a tuple containing: - valid classes - a list containing valid classes (for list schemas) - a dict containing a tuple of valid classes as the value - Example values: - (str,) - (Pet,) - (float, none_type) - ([int, none_type],) - ({str: (bool, str, int, float, date, datetime, str, none_type)},) - :param files: key -> field name, value -> a list of open file - objects for `multipart/form-data`. - :type files: dict - :param async_req bool: execute request asynchronously - :type async_req: bool, optional - :param _return_http_data_only: response data without head status code - and headers - :type _return_http_data_only: bool, optional - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :type collection_formats: dict, optional - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :type _preload_content: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _check_type: boolean describing if the data back from the server - should have its type checked. - :type _check_type: bool, optional - :return: - If async_req parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async_req is False or missing, - then the method will return the response directly. - """ - if not async_req: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout, _host, - _check_type) - - return self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, - query_params, - header_params, body, - post_params, files, - response_type, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, _check_type)) - - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None): - """Makes the HTTP request using RESTClient.""" - if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - else: - raise ApiValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - - def parameters_to_tuples(self, params, collection_formats): - """Get parameters as list of tuples, formatting collections. - - :param params: Parameters as dict or list of two-tuples - :param dict collection_formats: Parameter collection formats - :return: Parameters as list of tuples, collections formatted - """ - new_params = [] - if collection_formats is None: - collection_formats = {} - for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, value) for value in v) - else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' - else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) - else: - new_params.append((k, v)) - return new_params - - def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): - """Builds form parameters. - - :param files: None or a dict with key=param_name and - value is a list of open file objects - :return: List of tuples of form parameters with file data - """ - if files is None: - return [] - - params = [] - for param_name, file_instances in files.items(): - if file_instances is None: - # if the file field is nullable, skip None values - continue - for file_instance in file_instances: - if file_instance is None: - # if the file field is nullable, skip None values - continue - if file_instance.closed is True: - raise ApiValueError( - "Cannot read a closed file. The passed in file_type " - "for %s must be open." % param_name - ) - filename = os.path.basename(file_instance.name) - filedata = file_instance.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([param_name, tuple([filename, filedata, mimetype])])) - file_instance.close() - - return params - - def select_header_accept(self, accepts): - """Returns `Accept` based on an array of accepts provided. - - :param accepts: List of headers. - :return: Accept (e.g. application/json). - """ - if not accepts: - return - - accepts = [x.lower() for x in accepts] - - if 'application/json' in accepts: - return 'application/json' - else: - return ', '.join(accepts) - - def select_header_content_type(self, content_types): - """Returns `Content-Type` based on an array of content_types provided. - - :param content_types: List of content-types. - :return: Content-Type (e.g. application/json). - """ - if not content_types: - return 'application/json' - - content_types = [x.lower() for x in content_types] - - if 'application/json' in content_types or '*/*' in content_types: - return 'application/json' - else: - return content_types[0] - - def update_params_for_auth(self, headers, querys, auth_settings, - resource_path, method, body): - """Updates header and query params based on authentication setting. - - :param headers: Header parameters dict to be updated. - :param querys: Query parameters tuple list to be updated. - :param auth_settings: Authentication setting identifiers list. - :param resource_path: A string representation of the HTTP request resource path. - :param method: A string representation of the HTTP request method. - :param body: A object representing the body of the HTTP request. - The object type is the return value of _encoder.default(). - """ - if not auth_settings: - return - - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] -{{#hasHttpSignatureMethods}} - else: - # The HTTP signature scheme requires multiple HTTP headers - # that are calculated dynamically. - signing_info = self.configuration.signing_info - auth_headers = signing_info.get_http_signature_headers( - resource_path, method, headers, body, querys) - headers.update(auth_headers) -{{/hasHttpSignatureMethods}} - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) - - -class Endpoint(object): - def __init__(self, settings=None, params_map=None, root_map=None, - headers_map=None, api_client=None, callable=None): - """Creates an endpoint - - Args: - settings (dict): see below key value pairs - 'response_type' (tuple/None): response type - 'auth' (list): a list of auth type keys - 'endpoint_path' (str): the endpoint path - 'operation_id' (str): endpoint string identifier - 'http_method' (str): POST/PUT/PATCH/GET etc - 'servers' (list): list of str servers that this endpoint is at - params_map (dict): see below key value pairs - 'all' (list): list of str endpoint parameter names - 'required' (list): list of required parameter names - 'nullable' (list): list of nullable parameter names - 'enum' (list): list of parameters with enum values - 'validation' (list): list of parameters with validations - root_map - 'validations' (dict): the dict mapping endpoint parameter tuple - paths to their validation dictionaries - 'allowed_values' (dict): the dict mapping endpoint parameter - tuple paths to their allowed_values (enum) dictionaries - 'openapi_types' (dict): param_name to openapi type - 'attribute_map' (dict): param_name to camelCase name - 'location_map' (dict): param_name to 'body', 'file', 'form', - 'header', 'path', 'query' - collection_format_map (dict): param_name to `csv` etc. - headers_map (dict): see below key value pairs - 'accept' (list): list of Accept header strings - 'content_type' (list): list of Content-Type header strings - api_client (ApiClient) api client instance - callable (function): the function which is invoked when the - Endpoint is called - """ - self.settings = settings - self.params_map = params_map - self.params_map['all'].extend([ - 'async_req', - '_host_index', - '_preload_content', - '_request_timeout', - '_return_http_data_only', - '_check_input_type', - '_check_return_type' - ]) - self.params_map['nullable'].extend(['_request_timeout']) - self.validations = root_map['validations'] - self.allowed_values = root_map['allowed_values'] - self.openapi_types = root_map['openapi_types'] - extra_types = { - 'async_req': (bool,), - '_host_index': (none_type, int), - '_preload_content': (bool,), - '_request_timeout': (none_type, int, (int,), [int]), - '_return_http_data_only': (bool,), - '_check_input_type': (bool,), - '_check_return_type': (bool,) - } - self.openapi_types.update(extra_types) - self.attribute_map = root_map['attribute_map'] - self.location_map = root_map['location_map'] - self.collection_format_map = root_map['collection_format_map'] - self.headers_map = headers_map - self.api_client = api_client - self.callable = callable - - def __validate_inputs(self, kwargs): - for param in self.params_map['enum']: - if param in kwargs: - check_allowed_values( - self.allowed_values, - (param,), - kwargs[param] - ) - - for param in self.params_map['validation']: - if param in kwargs: - check_validations( - self.validations, - (param,), - kwargs[param], - configuration=self.api_client.configuration - ) - - if kwargs['_check_input_type'] is False: - return - - for key, value in kwargs.items(): - fixed_val = validate_and_convert_types( - value, - self.openapi_types[key], - [key], - False, - kwargs['_check_input_type'], - configuration=self.api_client.configuration - ) - kwargs[key] = fixed_val - - def __gather_params(self, kwargs): - params = { - 'body': None, - 'collection_format': {}, - 'file': {}, - 'form': [], - 'header': {}, - 'path': {}, - 'query': [] - } - - for param_name, param_value in kwargs.items(): - param_location = self.location_map.get(param_name) - if param_location is None: - continue - if param_location: - if param_location == 'body': - params['body'] = param_value - continue - base_name = self.attribute_map[param_name] - if (param_location == 'form' and - self.openapi_types[param_name] == (file_type,)): - params['file'][param_name] = [param_value] - elif (param_location == 'form' and - self.openapi_types[param_name] == ([file_type],)): - # param_value is already a list - params['file'][param_name] = param_value - elif param_location in {'form', 'query'}: - param_value_full = (base_name, param_value) - params[param_location].append(param_value_full) - if param_location not in {'form', 'query'}: - params[param_location][base_name] = param_value - collection_format = self.collection_format_map.get(param_name) - if collection_format: - params['collection_format'][base_name] = collection_format - - return params - - def __call__(self, *args, **kwargs): - """ This method is invoked when endpoints are called - Example: -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} - api_instance = {{classname}}() - api_instance.{{operationId}} # this is an instance of the class Endpoint - api_instance.{{operationId}}() # this invokes api_instance.{{operationId}}.__call__() - which then invokes the callable functions stored in that endpoint at - api_instance.{{operationId}}.callable or self.callable in this class -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} - """ - return self.callable(self, *args, **kwargs) - - def call_with_http_info(self, **kwargs): - - try: - index = self.api_client.configuration.server_operation_index.get( - self.settings['operation_id'], self.api_client.configuration.server_index - ) if kwargs['_host_index'] is None else kwargs['_host_index'] - server_variables = self.api_client.configuration.server_operation_variables.get( - self.settings['operation_id'], self.api_client.configuration.server_variables - ) - _host = self.api_client.configuration.get_host_from_settings( - index, variables=server_variables, servers=self.settings['servers'] - ) - except IndexError: - if self.settings['servers']: - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" % - len(self.settings['servers']) - ) - _host = None - - for key, value in kwargs.items(): - if key not in self.params_map['all']: - raise ApiTypeError( - "Got an unexpected parameter '%s'" - " to method `%s`" % - (key, self.settings['operation_id']) - ) - # only throw this nullable ApiValueError if _check_input_type - # is False, if _check_input_type==True we catch this case - # in self.__validate_inputs - if (key not in self.params_map['nullable'] and value is None - and kwargs['_check_input_type'] is False): - raise ApiValueError( - "Value may not be None for non-nullable parameter `%s`" - " when calling `%s`" % - (key, self.settings['operation_id']) - ) - - for key in self.params_map['required']: - if key not in kwargs.keys(): - raise ApiValueError( - "Missing the required parameter `%s` when calling " - "`%s`" % (key, self.settings['operation_id']) - ) - - self.__validate_inputs(kwargs) - - params = self.__gather_params(kwargs) - - accept_headers_list = self.headers_map['accept'] - if accept_headers_list: - params['header']['Accept'] = self.api_client.select_header_accept( - accept_headers_list) - - content_type_headers_list = self.headers_map['content_type'] - if content_type_headers_list: - header_list = self.api_client.select_header_content_type( - content_type_headers_list) - params['header']['Content-Type'] = header_list - - return self.api_client.call_api( - self.settings['endpoint_path'], self.settings['http_method'], - params['path'], - params['query'], - params['header'], - body=params['body'], - post_params=params['form'], - files=params['file'], - response_type=self.settings['response_type'], - auth_settings=self.settings['auth'], - async_req=kwargs['async_req'], - _check_type=kwargs['_check_return_type'], - _return_http_data_only=kwargs['_return_http_data_only'], - _preload_content=kwargs['_preload_content'], - _request_timeout=kwargs['_request_timeout'], - _host=_host, - collection_formats=params['collection_format']) diff --git a/python-experimental/api_doc.mustache b/python-experimental/api_doc.mustache deleted file mode 100644 index f9dac707f7..0000000000 --- a/python-experimental/api_doc.mustache +++ /dev/null @@ -1,75 +0,0 @@ -# {{packageName}}.{{classname}}{{#description}} -{{description}}{{/description}} - -All URIs are relative to *{{basePath}}* - -Method | HTTP request | Description -------------- | ------------- | ------------- -{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} -{{/operation}}{{/operations}} - -{{#operations}} -{{#operation}} -# **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) - -{{{summary}}}{{#notes}} - -{{{notes}}}{{/notes}} - -### Example - -{{#hasAuthMethods}} -{{#authMethods}} -{{#isBasic}} -{{#isBasicBasic}} -* Basic Authentication ({{name}}): -{{/isBasicBasic}} -{{#isBasicBearer}} -* Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): -{{/isBasicBearer}} -{{/isBasic}} -{{#isApiKey}} -* Api Key Authentication ({{name}}): -{{/isApiKey }} -{{#isOAuth}} -* OAuth Authentication ({{name}}): -{{/isOAuth }} -{{/authMethods}} -{{/hasAuthMethods}} -{{> python-experimental/api_doc_example }} -### Parameters -{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} -Name | Type | Description | Notes -------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | -{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}} -{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} -{{/optionalParams}} - -### Return type - -{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} - -### Authorization - -{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} - -### HTTP request headers - - - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} - - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} - -{{#responses.0}} -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -{{#responses}} -**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}}
{{/headers}}{{^headers.0}} - {{/headers.0}} | -{{/responses}} -{{/responses.0}} - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -{{/operation}} -{{/operations}} diff --git a/python-experimental/api_doc_example.mustache b/python-experimental/api_doc_example.mustache deleted file mode 100644 index bf989ae430..0000000000 --- a/python-experimental/api_doc_example.mustache +++ /dev/null @@ -1,76 +0,0 @@ -```python -import time -import {{{packageName}}} -from {{apiPackage}} import {{classVarName}} -{{#imports}} -{{{.}}} -{{/imports}} -from pprint import pprint -{{> python_doc_auth_partial}} -# Enter a context with an instance of the API client -{{#hasAuthMethods}} -with {{{packageName}}}.ApiClient(configuration) as api_client: -{{/hasAuthMethods}} -{{^hasAuthMethods}} -with {{{packageName}}}.ApiClient() as api_client: -{{/hasAuthMethods}} - # Create an instance of the API class - api_instance = {{classVarName}}.{{{classname}}}(api_client) -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} -{{/defaultValue}} -{{/requiredParams}} -{{#optionalParams}} - {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} -{{/optionalParams}} -{{#requiredParams}} -{{#-last}} - - # example passing only required values which don't have defaults set - try: -{{#summary}} - # {{{.}}} -{{/summary}} - {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) -{{#returnType}} - pprint(api_response) -{{/returnType}} - except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/-last}} -{{/requiredParams}} -{{#optionalParams}} -{{#-last}} - - # example passing only required values which don't have defaults set - # and optional values - try: -{{#summary}} - # {{{.}}} -{{/summary}} - {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{^-last}}, {{/-last}}{{/optionalParams}}) -{{#returnType}} - pprint(api_response) -{{/returnType}} - except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/-last}} -{{/optionalParams}} -{{^requiredParams}} -{{^optionalParams}} - - # example, this endpoint has no required or optional parameters - try: -{{#summary}} - # {{{.}}} -{{/summary}} - {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}() -{{#returnType}} - pprint(api_response) -{{/returnType}} - except {{{packageName}}}.ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -{{/optionalParams}} -{{/requiredParams}} -``` diff --git a/python-experimental/api_test.mustache b/python-experimental/api_test.mustache deleted file mode 100644 index f9276b443c..0000000000 --- a/python-experimental/api_test.mustache +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import unittest - -import {{packageName}} -from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 - - -class {{#operations}}Test{{classname}}(unittest.TestCase): - """{{classname}} unit test stubs""" - - def setUp(self): - self.api = {{classname}}() # noqa: E501 - - def tearDown(self): - pass - - {{#operation}} - def test_{{operationId}}(self): - """Test case for {{{operationId}}} - -{{#summary}} - {{{summary}}} # noqa: E501 -{{/summary}} - """ - pass - - {{/operation}} -{{/operations}} - -if __name__ == '__main__': - unittest.main() diff --git a/python-experimental/configuration.mustache b/python-experimental/configuration.mustache deleted file mode 100644 index ca6fc37747..0000000000 --- a/python-experimental/configuration.mustache +++ /dev/null @@ -1,635 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import copy -import logging -{{^asyncio}} -import multiprocessing -{{/asyncio}} -import sys -import urllib3 - -from http import client as http_client -from {{packageName}}.exceptions import ApiValueError - - -JSON_SCHEMA_VALIDATION_KEYWORDS = { - 'multipleOf', 'maximum', 'exclusiveMaximum', - 'minimum', 'exclusiveMinimum', 'maxLength', - 'minLength', 'pattern', 'maxItems', 'minItems' -} - -class Configuration(object): - """NOTE: This class is auto generated by OpenAPI Generator - - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param host: Base url - :param api_key: Dict to store API key(s). - Each entry in the dict specifies an API key. - The dict key is the name of the security scheme in the OAS specification. - The dict value is the API key secret. - :param api_key_prefix: Dict to store API prefix (e.g. Bearer) - The dict key is the name of the security scheme in the OAS specification. - The dict value is an API key prefix when generating the auth data. - :param username: Username for HTTP basic authentication - :param password: Password for HTTP basic authentication - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. -{{#hasHttpSignatureMethods}} - :param signing_info: Configuration parameters for the HTTP signature security scheme. - Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration -{{/hasHttpSignatureMethods}} - :param server_index: Index to servers configuration. - :param server_variables: Mapping with string values to replace variables in - templated server configuration. The validation of enums is performed for - variables with defined enum values before. - :param server_operation_index: Mapping from operation ID to an index to server - configuration. - :param server_operation_variables: Mapping from operation ID to a mapping with - string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum values before. - -{{#hasAuthMethods}} - :Example: -{{#hasApiKeyMethods}} - - API Key Authentication Example. - Given the following security scheme in the OpenAPI specification: - components: - securitySchemes: - cookieAuth: # name for the security scheme - type: apiKey - in: cookie - name: JSESSIONID # cookie name - - You can programmatically set the cookie: - -conf = {{{packageName}}}.Configuration( - api_key={'cookieAuth': 'abc123'} - api_key_prefix={'cookieAuth': 'JSESSIONID'} -) - - The following cookie will be added to the HTTP request: - Cookie: JSESSIONID abc123 -{{/hasApiKeyMethods}} -{{#hasHttpBasicMethods}} - - HTTP Basic Authentication Example. - Given the following security scheme in the OpenAPI specification: - components: - securitySchemes: - http_basic_auth: - type: http - scheme: basic - - Configure API client with HTTP basic authentication: - -conf = {{{packageName}}}.Configuration( - username='the-user', - password='the-password', -) - -{{/hasHttpBasicMethods}} -{{#hasHttpSignatureMethods}} - - HTTP Signature Authentication Example. - Given the following security scheme in the OpenAPI specification: - components: - securitySchemes: - http_basic_auth: - type: http - scheme: signature - - Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, - sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time - of the signature to 5 minutes after the signature has been created. - Note you can use the constants defined in the {{{packageName}}}.signing module, and you can - also specify arbitrary HTTP headers to be included in the HTTP signature, except for the - 'Authorization' header, which is used to carry the signature. - - One may be tempted to sign all headers by default, but in practice it rarely works. - This is beccause explicit proxies, transparent proxies, TLS termination endpoints or - load balancers may add/modify/remove headers. Include the HTTP headers that you know - are not going to be modified in transit. - -conf = {{{packageName}}}.Configuration( - signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( - key_id = 'my-key-id', - private_key_path = 'rsa.pem', - signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, - signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS, - signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET, - {{{packageName}}}.signing.HEADER_CREATED, - {{{packageName}}}.signing.HEADER_EXPIRES, - {{{packageName}}}.signing.HEADER_HOST, - {{{packageName}}}.signing.HEADER_DATE, - {{{packageName}}}.signing.HEADER_DIGEST, - 'Content-Type', - 'User-Agent' - ], - signature_max_validity = datetime.timedelta(minutes=5) - ) -) -{{/hasHttpSignatureMethods}} -{{/hasAuthMethods}} - """ - - _default = None - - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", -{{#hasHttpSignatureMethods}} - signing_info=None, -{{/hasHttpSignatureMethods}} - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ): - """Constructor - """ - self._base_path = "{{{basePath}}}" if host is None else host - """Default Base url - """ - self.server_index = 0 if server_index is None and host is None else server_index - self.server_operation_index = server_operation_index or {} - """Default server index - """ - self.server_variables = server_variables or {} - self.server_operation_variables = server_operation_variables or {} - """Default server variables - """ - self.temp_folder_path = None - """Temp file folder for downloading files - """ - # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - """dict to store API key(s) - """ - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - """dict to store API prefix (e.g. Bearer) - """ - self.refresh_api_key_hook = None - """function hook to refresh API key if expired - """ - self.username = username - """Username for HTTP basic authentication - """ - self.password = password - """Password for HTTP basic authentication - """ - self.discard_unknown_keys = discard_unknown_keys - self.disabled_client_side_validations = disabled_client_side_validations -{{#hasHttpSignatureMethods}} - if signing_info is not None: - signing_info.host = host - self.signing_info = signing_info - """The HTTP signing configuration - """ -{{/hasHttpSignatureMethods}} -{{#hasOAuthMethods}} - self.access_token = None - """access token for OAuth/Bearer - """ -{{/hasOAuthMethods}} -{{^hasOAuthMethods}} -{{#hasBearerMethods}} - self.access_token = None - """access token for OAuth/Bearer - """ -{{/hasBearerMethods}} -{{/hasOAuthMethods}} - self.logger = {} - """Logging Settings - """ - self.logger["package_logger"] = logging.getLogger("{{packageName}}") - self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = '%(asctime)s %(levelname)s %(message)s' - """Log format - """ - self.logger_stream_handler = None - """Log stream handler - """ - self.logger_file_handler = None - """Log file handler - """ - self.logger_file = None - """Debug file location - """ - self.debug = False - """Debug switch - """ - - self.verify_ssl = True - """SSL/TLS verification - Set this to false to skip verifying SSL certificate when calling API - from https server. - """ - self.ssl_ca_cert = None - """Set this to customize the certificate file to verify the peer. - """ - self.cert_file = None - """client certificate file - """ - self.key_file = None - """client key file - """ - self.assert_hostname = None - """Set this to True/False to enable/disable SSL hostname verification. - """ - - {{#asyncio}} - self.connection_pool_maxsize = 100 - """This value is passed to the aiohttp to limit simultaneous connections. - Default values is 100, None means no-limit. - """ - {{/asyncio}} - {{^asyncio}} - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 - """urllib3 connection pool's maximum number of connections saved - per pool. urllib3 uses 1 connection as default value, but this is - not the best value when you are making a lot of possibly parallel - requests to the same host, which is often the case here. - cpu_count * 5 is used as default value to increase performance. - """ - {{/asyncio}} - - self.proxy = None - """Proxy URL - """ - self.proxy_headers = None - """Proxy headers - """ - self.safe_chars_for_path_param = '' - """Safe chars for path_param - """ - self.retries = None - """Adding retries to override urllib3 default value 3 - """ - # Enable client side validation - self.client_side_validation = True - - # Options to pass down to the underlying urllib3 socket - self.socket_options = None - - def __deepcopy__(self, memo): - cls = self.__class__ - result = cls.__new__(cls) - memo[id(self)] = result - for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): - setattr(result, k, copy.deepcopy(v, memo)) - # shallow copy of loggers - result.logger = copy.copy(self.logger) - # use setters to configure loggers - result.logger_file = self.logger_file - result.debug = self.debug - return result - - def __setattr__(self, name, value): - object.__setattr__(self, name, value) - if name == 'disabled_client_side_validations': - s = set(filter(None, value.split(','))) - for v in s: - if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError( - "Invalid keyword: '{0}''".format(v)) - self._disabled_client_side_validations = s -{{#hasHttpSignatureMethods}} - if name == "signing_info" and value is not None: - # Ensure the host paramater from signing info is the same as - # Configuration.host. - value.host = self.host -{{/hasHttpSignatureMethods}} - - @classmethod - def set_default(cls, default): - """Set default instance of configuration. - - It stores default configuration, which can be - returned by get_default_copy method. - - :param default: object of Configuration - """ - cls._default = copy.deepcopy(default) - - @classmethod - def get_default_copy(cls): - """Return new instance of configuration. - - This method returns newly created, based on default constructor, - object of Configuration class or returns a copy of default - configuration passed by the set_default method. - - :return: The configuration object. - """ - if cls._default is not None: - return copy.deepcopy(cls._default) - return Configuration() - - @property - def logger_file(self): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - return self.__logger_file - - @logger_file.setter - def logger_file(self, value): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - self.__logger_file = value - if self.__logger_file: - # If set logging file, - # then add file handler and remove stream handler. - self.logger_file_handler = logging.FileHandler(self.__logger_file) - self.logger_file_handler.setFormatter(self.logger_formatter) - for _, logger in self.logger.items(): - logger.addHandler(self.logger_file_handler) - - @property - def debug(self): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - return self.__debug - - @debug.setter - def debug(self, value): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - self.__debug = value - if self.__debug: - # if debug status is True, turn on debug logging - for _, logger in self.logger.items(): - logger.setLevel(logging.DEBUG) - # turn on http_client debug - http_client.HTTPConnection.debuglevel = 1 - else: - # if debug status is False, turn off debug logging, - # setting log level to default `logging.WARNING` - for _, logger in self.logger.items(): - logger.setLevel(logging.WARNING) - # turn off http_client debug - http_client.HTTPConnection.debuglevel = 0 - - @property - def logger_format(self): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - return self.__logger_format - - @logger_format.setter - def logger_format(self, value): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - self.__logger_format = value - self.logger_formatter = logging.Formatter(self.__logger_format) - - def get_api_key_with_prefix(self, identifier, alias=None): - """Gets API key (with prefix if set). - - :param identifier: The identifier of apiKey. - :param alias: The alternative identifier of apiKey. - :return: The token for api key authentication. - """ - if self.refresh_api_key_hook is not None: - self.refresh_api_key_hook(self) - key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) - if key: - prefix = self.api_key_prefix.get(identifier) - if prefix: - return "%s %s" % (prefix, key) - else: - return key - - def get_basic_auth_token(self): - """Gets HTTP basic authentication header (string). - - :return: The token for basic HTTP authentication. - """ - username = "" - if self.username is not None: - username = self.username - password = "" - if self.password is not None: - password = self.password - return urllib3.util.make_headers( - basic_auth=username + ':' + password - ).get('authorization') - - def auth_settings(self): - """Gets Auth Settings dict for api client. - - :return: The Auth Settings information dict. - """ - auth = {} -{{#authMethods}} -{{#isApiKey}} - if '{{name}}' in self.api_key{{#vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/vendorExtensions.x-auth-id-alias}}: - auth['{{name}}'] = { - 'type': 'api_key', - 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, - 'key': '{{keyParamName}}', - 'value': self.get_api_key_with_prefix( - '{{name}}',{{#vendorExtensions.x-auth-id-alias}} - alias='{{.}}',{{/vendorExtensions.x-auth-id-alias}} - ), - } -{{/isApiKey}} -{{#isBasic}} - {{#isBasicBasic}} - if self.username is not None and self.password is not None: - auth['{{name}}'] = { - 'type': 'basic', - 'in': 'header', - 'key': 'Authorization', - 'value': self.get_basic_auth_token() - } - {{/isBasicBasic}} - {{#isBasicBearer}} - if self.access_token is not None: - auth['{{name}}'] = { - 'type': 'bearer', - 'in': 'header', - {{#bearerFormat}} - 'format': '{{{.}}}', - {{/bearerFormat}} - 'key': 'Authorization', - 'value': 'Bearer ' + self.access_token - } - {{/isBasicBearer}} - {{#isHttpSignature}} - if self.signing_info is not None: - auth['{{name}}'] = { - 'type': 'http-signature', - 'in': 'header', - 'key': 'Authorization', - 'value': None # Signature headers are calculated for every HTTP request - } - {{/isHttpSignature}} -{{/isBasic}} -{{#isOAuth}} - if self.access_token is not None: - auth['{{name}}'] = { - 'type': 'oauth2', - 'in': 'header', - 'key': 'Authorization', - 'value': 'Bearer ' + self.access_token - } -{{/isOAuth}} -{{/authMethods}} - return auth - - def to_debug_report(self): - """Gets the essential information for debugging. - - :return: The report for debugging. - """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: {{version}}\n"\ - "SDK Package Version: {{packageVersion}}".\ - format(env=sys.platform, pyversion=sys.version) - - def get_host_settings(self): - """Gets an array of host settings - - :return: An array of host settings - """ - return [ - {{#servers}} - { - 'url': "{{{url}}}", - 'description': "{{{description}}}{{^description}}No description provided{{/description}}", - {{#variables}} - {{#-first}} - 'variables': { - {{/-first}} - '{{{name}}}': { - 'description': "{{{description}}}{{^description}}No description provided{{/description}}", - 'default_value': "{{{defaultValue}}}", - {{#enumValues}} - {{#-first}} - 'enum_values': [ - {{/-first}} - "{{{.}}}"{{^-last}},{{/-last}} - {{#-last}} - ] - {{/-last}} - {{/enumValues}} - }{{^-last}},{{/-last}} - {{#-last}} - } - {{/-last}} - {{/variables}} - }{{^-last}},{{/-last}} - {{/servers}} - ] - - def get_host_from_settings(self, index, variables=None, servers=None): - """Gets host URL based on the index and variables - :param index: array index of the host settings - :param variables: hash of variable and the corresponding value - :param servers: an array of host settings or None - :return: URL based on host settings - """ - if index is None: - return self._base_path - - variables = {} if variables is None else variables - servers = self.get_host_settings() if servers is None else servers - - try: - server = servers[index] - except IndexError: - raise ValueError( - "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers))) - - url = server['url'] - - # go through variables and replace placeholders - for variable_name, variable in server.get('variables', {}).items(): - used_value = variables.get( - variable_name, variable['default_value']) - - if 'enum_values' in variable \ - and used_value not in variable['enum_values']: - raise ValueError( - "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format( - variable_name, variables[variable_name], - variable['enum_values'])) - - url = url.replace("{" + variable_name + "}", used_value) - - return url - - @property - def host(self): - """Return generated host.""" - return self.get_host_from_settings(self.server_index, variables=self.server_variables) - - @host.setter - def host(self, value): - """Fix base path.""" - self._base_path = value - self.server_index = None diff --git a/python-experimental/exceptions.mustache b/python-experimental/exceptions.mustache deleted file mode 100644 index 8d445c6e24..0000000000 --- a/python-experimental/exceptions.mustache +++ /dev/null @@ -1,129 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - - -class OpenApiException(Exception): - """The base exception class for all OpenAPIExceptions""" - - -class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None): - """ Raises an exception for TypeErrors - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list): a list of keys an indices to get to the - current_item - None if unset - valid_classes (tuple): the primitive classes that current item - should be an instance of - None if unset - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a list - None if unset - """ - self.path_to_item = path_to_item - self.valid_classes = valid_classes - self.key_type = key_type - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiTypeError, self).__init__(full_msg) - - -class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None): - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list) the path to the exception in the - received_data dict. None if unset - """ - - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiValueError, self).__init__(full_msg) - - -class ApiAttributeError(OpenApiException, AttributeError): - def __init__(self, msg, path_to_item=None): - """ - Raised when an attribute reference or assignment fails. - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiAttributeError, self).__init__(full_msg) - - -class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None): - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiKeyError, self).__init__(full_msg) - - -class ApiException(OpenApiException): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message - - -def render_path(path_to_item): - """Returns a string representation of a path""" - result = "" - for pth in path_to_item: - if isinstance(pth, int): - result += "[{0}]".format(pth) - else: - result += "['{0}']".format(pth) - return result diff --git a/python-experimental/gitlab-ci.mustache b/python-experimental/gitlab-ci.mustache deleted file mode 100644 index 60c4b37893..0000000000 --- a/python-experimental/gitlab-ci.mustache +++ /dev/null @@ -1,29 +0,0 @@ -# ref: https://docs.gitlab.com/ee/ci/README.html - -stages: - - test - -.tests: - stage: test - script: - - pip install -r requirements.txt - - pip install -r test-requirements.txt - {{#useNose}} - - nosetests - {{/useNose}} - {{^useNose}} - - pytest --cov={{{packageName}}} - {{/useNose}} - -test-3.5: - extends: .tests - image: python:3.5-alpine -test-3.6: - extends: .tests - image: python:3.6-alpine -test-3.7: - extends: .tests - image: python:3.7-alpine -test-3.8: - extends: .tests - image: python:3.8-alpine diff --git a/python-experimental/model.mustache b/python-experimental/model.mustache deleted file mode 100644 index 1fc47d9056..0000000000 --- a/python-experimental/model.mustache +++ /dev/null @@ -1,59 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import re # noqa: F401 -import sys # noqa: F401 - -import nulltype # noqa: F401 - -from {{packageName}}.model_utils import ( # noqa: F401 - ApiTypeError, - ModelComposed, - ModelNormal, - ModelSimple, - cached_property, - change_keys_js_to_python, - convert_js_args_to_python_args, - date, - datetime, - file_type, - none_type, - validate_get_composed_info, -) -{{#models}} -{{#model}} -{{#imports}} -{{#-first}} - -def lazy_import(): -{{/-first}} - {{{.}}} -{{/imports}} - - -{{^interfaces}} -{{#isArray}} -{{> python-experimental/model_templates/model_simple }} -{{/isArray}} -{{#isEnum}} -{{> python-experimental/model_templates/model_simple }} -{{/isEnum}} -{{#isAlias}} -{{> python-experimental/model_templates/model_simple }} -{{/isAlias}} -{{^isArray}} -{{^isEnum}} -{{^isAlias}} -{{> python-experimental/model_templates/model_normal }} -{{/isAlias}} -{{/isEnum}} -{{/isArray}} -{{/interfaces}} -{{#interfaces}} -{{#-last}} -{{> python-experimental/model_templates/model_composed }} -{{/-last}} -{{/interfaces}} -{{/model}} -{{/models}} diff --git a/python-experimental/model_doc.mustache b/python-experimental/model_doc.mustache deleted file mode 100644 index 7971d6c85f..0000000000 --- a/python-experimental/model_doc.mustache +++ /dev/null @@ -1,36 +0,0 @@ -{{#models}}{{#model}}# {{classname}} - -{{#description}}{{&description}} -{{/description}} -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -{{#isEnum}} -**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}}{{#allowableValues}}{{#defaultValue}}, {{/defaultValue}} must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} -{{/isEnum}} -{{#isAlias}} -**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} -{{/isAlias}} -{{#isArray}} -**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}}{{#arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} -{{/isArray}} -{{#requiredVars}} -{{^defaultValue}} -**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} -{{/defaultValue}} -{{/requiredVars}} -{{#requiredVars}} -{{#defaultValue}} -**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} -{{/defaultValue}} -{{/requiredVars}} -{{#optionalVars}} -**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} -{{/optionalVars}} -{{#additionalPropertiesType}} -**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] -{{/additionalPropertiesType}} - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - -{{/model}}{{/models}} diff --git a/python-experimental/model_test.mustache b/python-experimental/model_test.mustache deleted file mode 100644 index 669cc12185..0000000000 --- a/python-experimental/model_test.mustache +++ /dev/null @@ -1,36 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import sys -import unittest - -import {{packageName}} -{{#models}} -{{#model}} -{{#imports}} -{{{.}}} -{{/imports}} -from {{modelPackage}}.{{classFilename}} import {{classname}} - - -class Test{{classname}}(unittest.TestCase): - """{{classname}} unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def test{{classname}}(self): - """Test {{classname}}""" - # FIXME: construct object with mandatory attributes with example values - # model = {{classname}}() # noqa: E501 - pass - -{{/model}} -{{/models}} - -if __name__ == '__main__': - unittest.main() diff --git a/python-experimental/requirements.mustache b/python-experimental/requirements.mustache deleted file mode 100644 index 2c2f00fcb2..0000000000 --- a/python-experimental/requirements.mustache +++ /dev/null @@ -1,5 +0,0 @@ -nulltype -certifi >= 14.05.14 -python_dateutil >= 2.5.3 -setuptools >= 21.0.0 -urllib3 >= 1.15.1 diff --git a/python-experimental/rest.mustache b/python-experimental/rest.mustache deleted file mode 100644 index 5fb2da0af2..0000000000 --- a/python-experimental/rest.mustache +++ /dev/null @@ -1,282 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import io -import json -import logging -import re -import ssl -from urllib.parse import urlencode - -import certifi -import urllib3 - -from {{packageName}}.exceptions import ApiException, ApiValueError - - -logger = logging.getLogger(__name__) - - -class RESTResponse(io.IOBase): - - def __init__(self, resp): - self.urllib3_response = resp - self.status = resp.status - self.reason = resp.reason - self.data = resp.data - - def getheaders(self): - """Returns a dictionary of the response headers.""" - return self.urllib3_response.getheaders() - - def getheader(self, name, default=None): - """Returns a given response header.""" - return self.urllib3_response.getheader(name, default) - - -class RESTClientObject(object): - - def __init__(self, configuration, pools_size=4, maxsize=None): - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 - - # cert_reqs - if configuration.verify_ssl: - cert_reqs = ssl.CERT_REQUIRED - else: - cert_reqs = ssl.CERT_NONE - - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - addition_pool_args = {} - if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 - - if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries - - if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options - - if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 - - # https pool manager - if configuration.proxy: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) - else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): - """Perform requests. - - :param method: http request method - :param url: http request url - :param query_params: query parameters in the url - :param headers: http request headers - :param body: request json body, for `application/json` - :param post_params: request post parameters, - `application/x-www-form-urlencoded` - and `multipart/form-data` - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - """ - method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] - - if post_params and body: - raise ApiValueError( - "body parameter cannot be used with post_params parameter." - ) - - post_params = post_params or {} - headers = headers or {} - - timeout = None - if _request_timeout: - if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 - timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): - timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) - - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' - - try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - if query_params: - url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): - request_body = None - if body is not None: - request_body = json.dumps(body) - r = self.pool_manager.request( - method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 - r = self.pool_manager.request( - method, url, - fields=post_params, - encode_multipart=False, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct - # Content-Type which generated by urllib3 will be - # overwritten. - del headers['Content-Type'] - r = self.pool_manager.request( - method, url, - fields=post_params, - encode_multipart=True, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form - elif isinstance(body, str) or isinstance(body, bytes): - request_body = body - r = self.pool_manager.request( - method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided - arguments. Please check that your arguments match - declared content type.""" - raise ApiException(status=0, reason=msg) - # For `GET`, `HEAD` - else: - r = self.pool_manager.request(method, url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) - raise ApiException(status=0, reason=msg) - - if _preload_content: - r = RESTResponse(r) - - # log response body - logger.debug("response body: %s", r.data) - - if not 200 <= r.status <= 299: - raise ApiException(http_resp=r) - - return r - - def GET(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def OPTIONS(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def DELETE(self, url, headers=None, query_params=None, body=None, - _preload_content=True, _request_timeout=None): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def POST(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("POST", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PUT(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PATCH(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) diff --git a/python-experimental/setup.mustache b/python-experimental/setup.mustache deleted file mode 100644 index 632584a592..0000000000 --- a/python-experimental/setup.mustache +++ /dev/null @@ -1,55 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -from setuptools import setup, find_packages # noqa: H301 - -NAME = "{{{projectName}}}" -VERSION = "{{packageVersion}}" -{{#apiInfo}} -{{#apis}} -{{#-last}} -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = [ - "urllib3 >= 1.15", - "certifi", - "python-dateutil", - "nulltype", -{{#asyncio}} - "aiohttp >= 3.0.0", -{{/asyncio}} -{{#tornado}} - "tornado>=4.2,<5", -{{/tornado}} -{{#hasHttpSignatureMethods}} - "pem>=19.3.0", - "pycryptodome>=3.9.0", -{{/hasHttpSignatureMethods}} -] - -setup( - name=NAME, - version=VERSION, - description="{{appName}}", - author="{{#infoName}}{{infoName}}{{/infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", - author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", - url="{{packageUrl}}", - keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], - python_requires=">=3.5", - install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), - include_package_data=True, - {{#licenseInfo}}license="{{licenseInfo}}", - {{/licenseInfo}}long_description="""\ - {{appDescription}} # noqa: E501 - """ -) -{{/-last}} -{{/apis}} -{{/apiInfo}} diff --git a/python-experimental/test-requirements.mustache b/python-experimental/test-requirements.mustache deleted file mode 100644 index cc68f6484f..0000000000 --- a/python-experimental/test-requirements.mustache +++ /dev/null @@ -1,15 +0,0 @@ -{{#useNose}} -coverage>=4.0.3 -nose>=1.3.7 -pluggy>=0.3.1 -py>=1.4.31 -randomize>=0.13 -{{/useNose}} -{{^useNose}} -pytest~=4.6.7 # needed for python 3.4 -pytest-cov>=2.8.1 -pytest-randomly==1.2.3 # needed for python 3.4 -{{/useNose}} -{{#hasHttpSignatureMethods}} -pycryptodome>=3.9.0 -{{/hasHttpSignatureMethods}} \ No newline at end of file diff --git a/python-experimental/tox.mustache b/python-experimental/tox.mustache deleted file mode 100644 index 4c771c472b..0000000000 --- a/python-experimental/tox.mustache +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py3 - -[testenv] -deps=-r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -commands= - {{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} diff --git a/python-experimental/travis.mustache b/python-experimental/travis.mustache deleted file mode 100644 index 3c255f64e9..0000000000 --- a/python-experimental/travis.mustache +++ /dev/null @@ -1,18 +0,0 @@ -# ref: https://docs.travis-ci.com/user/languages/python -language: python -python: - - "3.5" - - "3.6" - - "3.7" - - "3.8" -# command to install dependencies -install: - - "pip install -r requirements.txt" - - "pip install -r test-requirements.txt" -# command to run tests -{{#useNose}} -script: nosetests -{{/useNose}} -{{^useNose}} -script: pytest --cov={{{packageName}}} -{{/useNose}} diff --git a/requirements.mustache b/requirements.mustache index eb358efd5b..2c2f00fcb2 100644 --- a/requirements.mustache +++ b/requirements.mustache @@ -1,6 +1,5 @@ +nulltype certifi >= 14.05.14 -future; python_version<="2.7" -six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.15.1 diff --git a/rest.mustache b/rest.mustache index 3916878624..5fb2da0af2 100644 --- a/rest.mustache +++ b/rest.mustache @@ -2,21 +2,17 @@ {{>partial_header}} -from __future__ import absolute_import - import io import json import logging import re import ssl +from urllib.parse import urlencode import certifi -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import urlencode import urllib3 -from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from {{packageName}}.exceptions import ApiException, ApiValueError logger = logging.getLogger(__name__) @@ -136,7 +132,7 @@ class RESTClientObject(object): timeout = None if _request_timeout: - if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821 + if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): @@ -216,18 +212,6 @@ class RESTClientObject(object): logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: - if r.status == 401: - raise UnauthorizedException(http_resp=r) - - if r.status == 403: - raise ForbiddenException(http_resp=r) - - if r.status == 404: - raise NotFoundException(http_resp=r) - - if 500 <= r.status <= 599: - raise ServiceException(http_resp=r) - raise ApiException(http_resp=r) return r diff --git a/setup.mustache b/setup.mustache index a14de4016f..632584a592 100644 --- a/setup.mustache +++ b/setup.mustache @@ -16,13 +16,22 @@ VERSION = "{{packageVersion}}" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +REQUIRES = [ + "urllib3 >= 1.15", + "certifi", + "python-dateutil", + "nulltype", {{#asyncio}} -REQUIRES.append("aiohttp >= 3.0.0") + "aiohttp >= 3.0.0", {{/asyncio}} {{#tornado}} -REQUIRES.append("tornado>=4.2,<5") + "tornado>=4.2,<5", {{/tornado}} +{{#hasHttpSignatureMethods}} + "pem>=19.3.0", + "pycryptodome>=3.9.0", +{{/hasHttpSignatureMethods}} +] setup( name=NAME, @@ -32,6 +41,7 @@ setup( author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], + python_requires=">=3.5", install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, diff --git a/python-experimental/signing.mustache b/signing.mustache similarity index 100% rename from python-experimental/signing.mustache rename to signing.mustache diff --git a/test-requirements.mustache b/test-requirements.mustache index 12021b47a1..cc68f6484f 100644 --- a/test-requirements.mustache +++ b/test-requirements.mustache @@ -6,7 +6,10 @@ py>=1.4.31 randomize>=0.13 {{/useNose}} {{^useNose}} -pytest~=4.6.7 # needed for python 2.7+3.4 +pytest~=4.6.7 # needed for python 3.4 pytest-cov>=2.8.1 -pytest-randomly==1.2.3 # needed for python 2.7+3.4 -{{/useNose}} \ No newline at end of file +pytest-randomly==1.2.3 # needed for python 3.4 +{{/useNose}} +{{#hasHttpSignatureMethods}} +pycryptodome>=3.9.0 +{{/hasHttpSignatureMethods}} \ No newline at end of file diff --git a/tox.mustache b/tox.mustache index fe989faf93..4c771c472b 100644 --- a/tox.mustache +++ b/tox.mustache @@ -1,10 +1,5 @@ [tox] -{{^asyncio}} -envlist = py27, py3 -{{/asyncio}} -{{#asyncio}} envlist = py3 -{{/asyncio}} [testenv] deps=-r{toxinidir}/requirements.txt diff --git a/travis.mustache b/travis.mustache index 195488737d..3c255f64e9 100644 --- a/travis.mustache +++ b/travis.mustache @@ -1,10 +1,6 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "2.7" - - "3.2" - - "3.3" - - "3.4" - "3.5" - "3.6" - "3.7" From bd8874e85211117646786d81efd7138849c5153e Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 5 Dec 2020 23:02:00 +0300 Subject: [PATCH 154/185] [python] Re-merge Subclass Python exceptions (#7321) (#8095) * Subclass Python exceptions (#7321) * Subclass Python exceptions: - UnauthorizedException (401) - ForbiddenException (403) - NotFoundException (404) - ServiceException [500 - 599] Fixes #2151 * add generated sample code * use Python 2 flavor inheritance * regenerate samples * update samples Co-authored-by: Ryan Rishi Co-authored-by: William Cheng --- exceptions.mustache | 24 ++++++++++++++++++++++++ rest.mustache | 14 +++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/exceptions.mustache b/exceptions.mustache index 8d445c6e24..a60554dc5e 100644 --- a/exceptions.mustache +++ b/exceptions.mustache @@ -118,6 +118,30 @@ class ApiException(OpenApiException): return error_message +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ServiceException, self).__init__(status, reason, http_resp) + + def render_path(path_to_item): """Returns a string representation of a path""" result = "" diff --git a/rest.mustache b/rest.mustache index 5fb2da0af2..cc8884fb77 100644 --- a/rest.mustache +++ b/rest.mustache @@ -12,7 +12,7 @@ from urllib.parse import urlencode import certifi import urllib3 -from {{packageName}}.exceptions import ApiException, ApiValueError +from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -212,6 +212,18 @@ class RESTClientObject(object): logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + raise ApiException(http_resp=r) return r From 19b2ceccebb3868e0b3e28d357a5a3b595e2b7d4 Mon Sep 17 00:00:00 2001 From: itaru2622 <70509350+itaru2622@users.noreply.github.com> Date: Tue, 8 Dec 2020 02:50:09 +0900 Subject: [PATCH 155/185] Fix bug [python][client] generated python client code cannot POST object in multipart/form-data (#8075) * encode object in json and add content-type:application/json for multipart/form-data fix issue https://github.com/OpenAPITools/openapi-generator/issues/8068 * update samples by ./bin/generate-samples.sh * non-ascii chars supported in encoding object to json, and add "content-type:application/json; charset=utf-8" * update samples again, by ./bin/generate-samples.sh * update comment(docstring) in parameters_to_multipart according to the discussion in PR review. * fix default value in parameters_to_multipart function as described in PR review comment. * update samples again, by ./bin/generate-samples.sh --- api_client.mustache | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/api_client.mustache b/api_client.mustache index fd3d0b8a20..63ad0f1f8f 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -10,6 +10,7 @@ import os import re import typing from urllib.parse import quote +from urllib3.fields import RequestField {{#tornado}} import tornado.gen @@ -169,6 +170,9 @@ class ApiClient(object): post_params = self.parameters_to_tuples(post_params, collection_formats) post_params.extend(self.files_parameters(files)) + if header_params['Content-Type'].startswith("multipart"): + post_params = self.parameters_to_multipart(post_params, + (dict) ) # body if body: @@ -243,6 +247,26 @@ class ApiClient(object): response_data.getheaders())) {{/tornado}} + def parameters_to_multipart(self, params, collection_types): + """Get parameters as list of tuples, formatting as json if value is collection_types + + :param params: Parameters as list of two-tuples + :param dict collection_types: Parameter collection types + :return: Parameters as list of tuple or urllib3.fields.RequestField + """ + new_params = [] + if collection_types is None: + collection_types = (dict) + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, collection_types): # v is instance of collection_type, formatting as application/json + v = json.dumps(v, ensure_ascii=False).encode("utf-8") + field = RequestField(k, v) + field.make_multipart(content_type="application/json; charset=utf-8") + new_params.append(field) + else: + new_params.append((k, v)) + return new_params + @classmethod def sanitize_for_serialization(cls, obj): """Builds a JSON POST object. From 39618772c7b5a401745a89451bd5909c944ac702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Mon, 7 Dec 2020 23:07:35 +0300 Subject: [PATCH 156/185] [python] Update python versions (#8042) * Remove redundant encoding definitions UTF-8 is already the default encoding in Python 3. * Remove Python3.4 related requirements * Remove dead Python version 3.5 * Add Python 3.9 to CI and test configs * Update petstore example --- README.mustache | 2 +- README_onlypackage.mustache | 2 +- __init__apis.mustache | 1 - __init__models.mustache | 2 -- __init__package.mustache | 2 -- api.mustache | 2 -- api_client.mustache | 1 - api_test.mustache | 2 -- asyncio/rest.mustache | 2 -- configuration.mustache | 2 -- exceptions.mustache | 2 -- gitlab-ci.mustache | 6 +++--- model.mustache | 2 -- model_test.mustache | 2 -- model_utils.mustache | 2 -- rest.mustache | 2 -- setup.mustache | 4 +--- signing.mustache | 1 - test-requirements.mustache | 4 +--- tornado/rest.mustache | 2 -- travis.mustache | 2 +- 21 files changed, 8 insertions(+), 39 deletions(-) diff --git a/README.mustache b/README.mustache index 463e4e0d56..65a06eaae0 100644 --- a/README.mustache +++ b/README.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python >= 3.5 +Python >= 3.6 ## Installation & Usage ### pip install diff --git a/README_onlypackage.mustache b/README_onlypackage.mustache index 40dc242b7b..684f4a5efb 100644 --- a/README_onlypackage.mustache +++ b/README_onlypackage.mustache @@ -17,7 +17,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements. -Python >= 3.5 +Python >= 3.6 ## Installation & Usage diff --git a/__init__apis.mustache b/__init__apis.mustache index 32d101a97d..b4ec8a9a47 100644 --- a/__init__apis.mustache +++ b/__init__apis.mustache @@ -1,7 +1,6 @@ {{#apiInfo}} {{#apis}} {{#-first}} -# coding: utf-8 # flake8: noqa diff --git a/__init__models.mustache b/__init__models.mustache index 5a2f25f875..76d91fc5d4 100644 --- a/__init__models.mustache +++ b/__init__models.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - # flake8: noqa # import all models into this package diff --git a/__init__package.mustache b/__init__package.mustache index d7ff5b8260..6308ba683f 100644 --- a/__init__package.mustache +++ b/__init__package.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - # flake8: noqa {{>partial_header}} diff --git a/api.mustache b/api.mustache index 0e76b3f29f..eb9a9cd2ef 100644 --- a/api.mustache +++ b/api.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import re # noqa: F401 diff --git a/api_client.mustache b/api_client.mustache index 63ad0f1f8f..aaf14c4af3 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -1,4 +1,3 @@ -# coding: utf-8 {{>partial_header}} import json diff --git a/api_test.mustache b/api_test.mustache index f9276b443c..bf2cd19285 100644 --- a/api_test.mustache +++ b/api_test.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import unittest diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 44531fce5a..7d1f477ea5 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import io diff --git a/configuration.mustache b/configuration.mustache index ca6fc37747..88697bc45f 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import copy diff --git a/exceptions.mustache b/exceptions.mustache index a60554dc5e..046dcd9a5a 100644 --- a/exceptions.mustache +++ b/exceptions.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} diff --git a/gitlab-ci.mustache b/gitlab-ci.mustache index 60c4b37893..cf785a80ab 100644 --- a/gitlab-ci.mustache +++ b/gitlab-ci.mustache @@ -15,9 +15,6 @@ stages: - pytest --cov={{{packageName}}} {{/useNose}} -test-3.5: - extends: .tests - image: python:3.5-alpine test-3.6: extends: .tests image: python:3.6-alpine @@ -27,3 +24,6 @@ test-3.7: test-3.8: extends: .tests image: python:3.8-alpine +test-3.9: + extends: .tests + image: python:3.9-alpine diff --git a/model.mustache b/model.mustache index f2cb2368ca..34fd9e5cde 100644 --- a/model.mustache +++ b/model.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{> partial_header }} import re # noqa: F401 diff --git a/model_test.mustache b/model_test.mustache index 669cc12185..aa95f64944 100644 --- a/model_test.mustache +++ b/model_test.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import sys diff --git a/model_utils.mustache b/model_utils.mustache index 1523dbc2d7..9f3264e98e 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} from datetime import date, datetime # noqa: F401 diff --git a/rest.mustache b/rest.mustache index cc8884fb77..0fbb0831ae 100644 --- a/rest.mustache +++ b/rest.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import io diff --git a/setup.mustache b/setup.mustache index 632584a592..a009be3f91 100644 --- a/setup.mustache +++ b/setup.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} from setuptools import setup, find_packages # noqa: H301 @@ -41,7 +39,7 @@ setup( author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], - python_requires=">=3.5", + python_requires=">=3.6", install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, diff --git a/signing.mustache b/signing.mustache index 26d2b8cb37..8dfbf5148f 100644 --- a/signing.mustache +++ b/signing.mustache @@ -1,4 +1,3 @@ -# coding: utf-8 {{>partial_header}} from base64 import b64encode diff --git a/test-requirements.mustache b/test-requirements.mustache index cc68f6484f..635b816e74 100644 --- a/test-requirements.mustache +++ b/test-requirements.mustache @@ -6,10 +6,8 @@ py>=1.4.31 randomize>=0.13 {{/useNose}} {{^useNose}} -pytest~=4.6.7 # needed for python 3.4 pytest-cov>=2.8.1 -pytest-randomly==1.2.3 # needed for python 3.4 {{/useNose}} {{#hasHttpSignatureMethods}} pycryptodome>=3.9.0 -{{/hasHttpSignatureMethods}} \ No newline at end of file +{{/hasHttpSignatureMethods}} diff --git a/tornado/rest.mustache b/tornado/rest.mustache index 2679760ea5..9e5cc12092 100644 --- a/tornado/rest.mustache +++ b/tornado/rest.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} import io diff --git a/travis.mustache b/travis.mustache index 3c255f64e9..a26c984f3d 100644 --- a/travis.mustache +++ b/travis.mustache @@ -1,10 +1,10 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "3.5" - "3.6" - "3.7" - "3.8" + - "3.9" # command to install dependencies install: - "pip install -r requirements.txt" From 3acda73be21d8e85aa637b9068febe3aa932719b Mon Sep 17 00:00:00 2001 From: fbl100 Date: Mon, 7 Dec 2020 15:18:16 -0500 Subject: [PATCH 157/185] Fixes issue #8014, _check_type flag not being honored. (#8053) * Fixes issue 8014, _check_type flag not being honored. Updated model_utils.mustache to pass the check_type flag into attempt_convert_item(). Failure to do so results in type validation errors occurring when the user has specifically requested that they be disabled. * regenerated samples Co-authored-by: Frank Levine --- model_utils.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/model_utils.mustache b/model_utils.mustache index 9f3264e98e..9c299d4b3e 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1116,7 +1116,8 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, configuration, spec_property_naming, key_type=False, - must_convert=True + must_convert=True, + check_type=_check_type ) return converted_instance else: @@ -1136,7 +1137,8 @@ def validate_and_convert_types(input_value, required_types_mixed, path_to_item, configuration, spec_property_naming, key_type=False, - must_convert=False + must_convert=False, + check_type=_check_type ) return converted_instance From 0e0444a4ed3bef2ceb6fbacc7cae375e00e35214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Herv=C3=A9?= Date: Tue, 15 Dec 2020 18:30:50 +0100 Subject: [PATCH 158/185] Include description directly in python docstrings (#8154) * Include description directly in python docstrings mustache escaping the description make them render weirdly, including sometimes unsupported characters in python. * More parameters --- api.mustache | 6 +++--- model_templates/method_init_shared.mustache | 6 +++--- model_templates/method_init_simple.mustache | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api.mustache b/api.mustache index eb9a9cd2ef..a2a3d53697 100644 --- a/api.mustache +++ b/api.mustache @@ -64,17 +64,17 @@ class {{classname}}(object): {{/requiredParams}} {{#requiredParams}} {{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}} + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}{{/description}} {{/defaultValue}} {{/requiredParams}} {{#requiredParams}} {{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] {{/defaultValue}} {{/requiredParams}} Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object diff --git a/model_templates/method_init_shared.mustache b/model_templates/method_init_shared.mustache index f3497ef53b..a766c14bac 100644 --- a/model_templates/method_init_shared.mustache +++ b/model_templates/method_init_shared.mustache @@ -7,7 +7,7 @@ Args: {{/-first}} {{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} {{/defaultValue}} {{#-last}} @@ -16,12 +16,12 @@ Keyword Args: {{#requiredVars}} {{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{/defaultValue}} {{/requiredVars}} {{> model_templates/docstring_init_required_kwargs }} {{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 {{/optionalVars}} """ diff --git a/model_templates/method_init_simple.mustache b/model_templates/method_init_simple.mustache index 2340cf74ef..c1f323881e 100644 --- a/model_templates/method_init_simple.mustache +++ b/model_templates/method_init_simple.mustache @@ -14,10 +14,10 @@ Note that value can be passed either in args or in kwargs, but not in both. Args: - args[0] ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + args[0] ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 Keyword Args: - value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{> model_templates/docstring_init_required_kwargs }} """ From d79ed54a0427081cdcbb147de68486a65176e29c Mon Sep 17 00:00:00 2001 From: Robert Parini Date: Wed, 16 Dec 2020 00:36:35 +0000 Subject: [PATCH 159/185] [Python][Client] Default to system CA instead of certifi (#8108) * Use system CA by default and remove certifi See https://github.com/OpenAPITools/openapi-generator/issues/6506 * Use system CA by default in asyncio client * Update README_onlypackage.mustache * Result of ./bin/generate-samples.sh * Add ssl_ca_cert argument for Configuration * Result of ./bin/generate-samples.sh * Remove certifi, use system CA by default --- README_onlypackage.mustache | 3 +-- asyncio/rest.mustache | 10 +--------- configuration.mustache | 5 ++++- requirements.mustache | 3 +-- rest.mustache | 12 ++---------- setup.mustache | 3 +-- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/README_onlypackage.mustache b/README_onlypackage.mustache index 684f4a5efb..7202059fba 100644 --- a/README_onlypackage.mustache +++ b/README_onlypackage.mustache @@ -25,8 +25,7 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: -* urllib3 >= 1.15 -* certifi +* urllib3 >= 1.25.3 * python-dateutil {{#asyncio}} * aiohttp diff --git a/asyncio/rest.mustache b/asyncio/rest.mustache index 7d1f477ea5..3744b62c81 100644 --- a/asyncio/rest.mustache +++ b/asyncio/rest.mustache @@ -7,7 +7,6 @@ import re import ssl import aiohttp -import certifi # python 2 and python 3 compatibility library from six.moves.urllib.parse import urlencode @@ -41,14 +40,7 @@ class RESTClientObject(object): if maxsize is None: maxsize = configuration.connection_pool_maxsize - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - ssl_context = ssl.create_default_context(cafile=ca_certs) + ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert) if configuration.cert_file: ssl_context.load_cert_chain( configuration.cert_file, keyfile=configuration.key_file diff --git a/configuration.mustache b/configuration.mustache index 88697bc45f..2f698db3fe 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -71,6 +71,8 @@ class Configuration(object): :param server_operation_variables: Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format {{#hasAuthMethods}} :Example: @@ -169,6 +171,7 @@ conf = {{{packageName}}}.Configuration( {{/hasHttpSignatureMethods}} server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, ): """Constructor """ @@ -253,7 +256,7 @@ conf = {{{packageName}}}.Configuration( Set this to false to skip verifying SSL certificate when calling API from https server. """ - self.ssl_ca_cert = None + self.ssl_ca_cert = ssl_ca_cert """Set this to customize the certificate file to verify the peer. """ self.cert_file = None diff --git a/requirements.mustache b/requirements.mustache index 2c2f00fcb2..73a84334c8 100644 --- a/requirements.mustache +++ b/requirements.mustache @@ -1,5 +1,4 @@ nulltype -certifi >= 14.05.14 python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.15.1 +urllib3 >= 1.25.3 diff --git a/rest.mustache b/rest.mustache index 0fbb0831ae..9e73386489 100644 --- a/rest.mustache +++ b/rest.mustache @@ -7,7 +7,6 @@ import re import ssl from urllib.parse import urlencode -import certifi import urllib3 from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError @@ -48,13 +47,6 @@ class RESTClientObject(object): else: cert_reqs = ssl.CERT_NONE - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - addition_pool_args = {} if configuration.assert_hostname is not None: addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 @@ -77,7 +69,7 @@ class RESTClientObject(object): num_pools=pools_size, maxsize=maxsize, cert_reqs=cert_reqs, - ca_certs=ca_certs, + ca_certs=configuration.ssl_ca_cert, cert_file=configuration.cert_file, key_file=configuration.key_file, proxy_url=configuration.proxy, @@ -89,7 +81,7 @@ class RESTClientObject(object): num_pools=pools_size, maxsize=maxsize, cert_reqs=cert_reqs, - ca_certs=ca_certs, + ca_certs=configuration.ssl_ca_cert, cert_file=configuration.cert_file, key_file=configuration.key_file, **addition_pool_args diff --git a/setup.mustache b/setup.mustache index a009be3f91..707ff5bb50 100644 --- a/setup.mustache +++ b/setup.mustache @@ -15,8 +15,7 @@ VERSION = "{{packageVersion}}" # http://pypi.python.org/pypi/setuptools REQUIRES = [ - "urllib3 >= 1.15", - "certifi", + "urllib3 >= 1.25.3", "python-dateutil", "nulltype", {{#asyncio}} From 48a3cacc5645ff8c4d49cae1ca9b610796c74c98 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 8 Jan 2021 13:15:55 -0800 Subject: [PATCH 160/185] Fixes object serialization when there is an inline array property which contains a refed enum (#8387) * Fixes object inline enum defintion with refed enum item * Adds refed array model example w/ serialization + deserialization --- model_utils.mustache | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/model_utils.mustache b/model_utils.mustache index 9c299d4b3e..07b77a99d1 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1211,10 +1211,13 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: model_to_dict(x, serialize=serialize) - if hasattr(x, '_data_store') else x, value - )) + if not value or isinstance(value[0], PRIMITIVE_TYPES): + # empty list or primitive types + result[attr] = value + elif isinstance(value[0], ModelSimple): + result[attr] = [x.value for x in value] + else: + result[attr] = [model_to_dict(x, serialize=serialize) for x in value] elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], From 1dd008e926b98598f00e4380e17e3d640ca3a89b Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 13 Jan 2021 17:38:41 +0100 Subject: [PATCH 161/185] [python] fix #8404: avoid shadowing the name Endpoint (#8405) if a type was named Endpoint, its import for use in the api would shadow the name Endpoint for the internal utility --- api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.mustache b/api.mustache index a2a3d53697..cbad6df2c5 100644 --- a/api.mustache +++ b/api.mustache @@ -3,7 +3,7 @@ import re # noqa: F401 import sys # noqa: F401 -from {{packageName}}.api_client import ApiClient, Endpoint +from {{packageName}}.api_client import ApiClient, Endpoint as _Endpoint from {{packageName}}.model_utils import ( # noqa: F401 check_allowed_values, check_validations, @@ -125,7 +125,7 @@ class {{classname}}(object): {{/requiredParams}} return self.call_with_http_info(**kwargs) - self.{{operationId}} = Endpoint( + self.{{operationId}} = _Endpoint( settings={ 'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}}, {{#authMethods}} From 0937196534313d51a7572d49dd40dcbbbb26e072 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 15 Jan 2021 13:27:33 -0800 Subject: [PATCH 162/185] [python] Fixes file upload + download, adds tests (#8437) * Adds tests for file upload and files upload * Adds test_download_attachment * Fixes test_upload_file * Adds download_attachment endpoint * Adds test_download_attachment * Updates assert_request_called_with signature * Samples regen * Adds upload download file spec route and sample gen * Fixes file upload for application/octet-stream, writes test_upload_download_file * Changes if into elif * Improves python code in api_client --- api_client.mustache | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/api_client.mustache b/api_client.mustache index aaf14c4af3..9b9a04fefd 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -199,8 +199,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -214,15 +212,17 @@ class ApiClient(object): {{/tornado}} return return_data - if response_type not in ["file", "bytes"]: - match = None - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_data.data = response_data.data.decode(encoding) - # deserialize response data if response_type: + if response_type != (file_type,): + encoding = "utf-8" + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + if match: + encoding = match.group(1) + response_data.data = response_data.data.decode(encoding) + return_data = self.deserialize( response_data, response_type, @@ -268,7 +268,7 @@ class ApiClient(object): @classmethod def sanitize_for_serialization(cls, obj): - """Builds a JSON POST object. + """Prepares data for transmission before it is sent with the rest client If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date @@ -276,6 +276,7 @@ class ApiClient(object): If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. + If obj is io.IOBase, return the bytes :param obj: The data to serialize. :return: The serialized form of data. """ @@ -283,6 +284,8 @@ class ApiClient(object): return { key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() } + elif isinstance(obj, io.IOBase): + return cls.get_file_data_and_close_file(obj) elif isinstance(obj, (str, int, float, none_type, bool)): return obj elif isinstance(obj, (datetime, date)): @@ -526,6 +529,12 @@ class ApiClient(object): new_params.append((k, v)) return new_params + @staticmethod + def get_file_data_and_close_file(file_instance: io.IOBase) -> bytes: + file_data = file_instance.read() + file_instance.close() + return file_data + def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): """Builds form parameters. @@ -551,12 +560,11 @@ class ApiClient(object): "for %s must be open." % param_name ) filename = os.path.basename(file_instance.name) - filedata = file_instance.read() + filedata = self.get_file_data_and_close_file(file_instance) mimetype = (mimetypes.guess_type(filename)[0] or 'application/octet-stream') params.append( tuple([param_name, tuple([filename, filedata, mimetype])])) - file_instance.close() return params From ba1b7aa172fa6821f1c24dbca6bb0bec53c210d5 Mon Sep 17 00:00:00 2001 From: Johannes Wienke Date: Fri, 15 Jan 2021 22:51:12 +0100 Subject: [PATCH 163/185] Fix counting for large API solutions in generated Python README (#8403) * Fix counting for large API solutions Let 2 follow 1. * Update Python samples with new readme --- README_common.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_common.mustache b/README_common.mustache index ec525d175b..9999f508c8 100644 --- a/README_common.mustache +++ b/README_common.mustache @@ -100,7 +100,7 @@ Use specific imports for apis and models like: - `from {{{packageName}}}.api.default_api import DefaultApi` - `from {{{packageName}}}.model.pet import Pet` -Solution 1: +Solution 2: Before importing the package, adjust the maximum recursion limit as shown below: ``` import sys From 6c8f7fe80722d5514205d79c455fb33a08cfe43c Mon Sep 17 00:00:00 2001 From: Justin Black Date: Thu, 28 Jan 2021 09:30:36 -0800 Subject: [PATCH 164/185] Removes nulltype from python, updates samples (#8555) * Removes nulltype from python, updates samples * Removes nulltype from the python requirements * Removes nulltype import in models, moves requiredVars to optionalVars when approprieate --- model.mustache | 2 -- model_templates/method_init_composed.mustache | 5 ----- requirements.mustache | 1 - setup.mustache | 1 - 4 files changed, 9 deletions(-) diff --git a/model.mustache b/model.mustache index 34fd9e5cde..680b60644c 100644 --- a/model.mustache +++ b/model.mustache @@ -3,8 +3,6 @@ import re # noqa: F401 import sys # noqa: F401 -import nulltype # noqa: F401 - from {{packageName}}.model_utils import ( # noqa: F401 ApiTypeError, ModelComposed, diff --git a/model_templates/method_init_composed.mustache b/model_templates/method_init_composed.mustache index 8b3650b33a..9b29837971 100644 --- a/model_templates/method_init_composed.mustache +++ b/model_templates/method_init_composed.mustache @@ -24,11 +24,6 @@ '{{name}}': {{name}}, {{/requiredVars}} } - # remove args whose value is Null because they are unset - required_arg_names = list(required_args.keys()) - for required_arg_name in required_arg_names: - if required_args[required_arg_name] is nulltype.Null: - del required_args[required_arg_name] model_args = {} model_args.update(required_args) model_args.update(kwargs) diff --git a/requirements.mustache b/requirements.mustache index 73a84334c8..96947f6040 100644 --- a/requirements.mustache +++ b/requirements.mustache @@ -1,4 +1,3 @@ -nulltype python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3 diff --git a/setup.mustache b/setup.mustache index 707ff5bb50..d5154f3fa6 100644 --- a/setup.mustache +++ b/setup.mustache @@ -17,7 +17,6 @@ VERSION = "{{packageVersion}}" REQUIRES = [ "urllib3 >= 1.25.3", "python-dateutil", - "nulltype", {{#asyncio}} "aiohttp >= 3.0.0", {{/asyncio}} From 4222aa0130bc18db9780efe68a9b42fc3d4a7a70 Mon Sep 17 00:00:00 2001 From: adpoliak <3969913+adpoliak@users.noreply.github.com> Date: Fri, 29 Jan 2021 19:24:10 -0500 Subject: [PATCH 165/185] [PYTHON] use customized default Configuration() objects if configured by the programmer (#8500) --- api_client.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_client.mustache b/api_client.mustache index 9b9a04fefd..8d6395a4c2 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -61,7 +61,7 @@ class ApiClient(object): def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration() + configuration = Configuration.get_default_copy() self.configuration = configuration self.pool_threads = pool_threads From a94b5ecd1d53225ca41e38475385487317e8ec7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDilvinas=20Urbonas?= Date: Fri, 5 Feb 2021 23:09:53 +0200 Subject: [PATCH 166/185] [BUG][Python] init access token for python client configuration (#7469) * fix: init access token for python client configuration * fix: remove duplicate initializations for access_token --- configuration.mustache | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/configuration.mustache b/configuration.mustache index 2f698db3fe..9ab0a84089 100644 --- a/configuration.mustache +++ b/configuration.mustache @@ -163,6 +163,7 @@ conf = {{{packageName}}}.Configuration( def __init__(self, host=None, api_key=None, api_key_prefix=None, + access_token=None, username=None, password=None, discard_unknown_keys=False, disabled_client_side_validations="", @@ -190,6 +191,7 @@ conf = {{{packageName}}}.Configuration( """Temp file folder for downloading files """ # Authentication Settings + self.access_token = access_token self.api_key = {} if api_key: self.api_key = api_key @@ -218,18 +220,6 @@ conf = {{{packageName}}}.Configuration( """The HTTP signing configuration """ {{/hasHttpSignatureMethods}} -{{#hasOAuthMethods}} - self.access_token = None - """access token for OAuth/Bearer - """ -{{/hasOAuthMethods}} -{{^hasOAuthMethods}} -{{#hasBearerMethods}} - self.access_token = None - """access token for OAuth/Bearer - """ -{{/hasBearerMethods}} -{{/hasOAuthMethods}} self.logger = {} """Logging Settings """ From e6909406b3ff381542163da98978645452d72de2 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 23 Feb 2021 06:00:14 +0100 Subject: [PATCH 167/185] [python][template] move _path_to_item of simple init to avoid name error (#8737) * [python][template] move _path_to_item of simple init up so its avaliable for missing default errors * update generated examples --- model_templates/method_init_simple.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model_templates/method_init_simple.mustache b/model_templates/method_init_simple.mustache index c1f323881e..9e06a6a22e 100644 --- a/model_templates/method_init_simple.mustache +++ b/model_templates/method_init_simple.mustache @@ -20,6 +20,8 @@ value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{> model_templates/docstring_init_required_kwargs }} """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) if 'value' in kwargs: value = kwargs.pop('value') @@ -41,7 +43,6 @@ _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) - _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) From 9f9dee6eed23b99f34a6ec6bdbffd484400c3f59 Mon Sep 17 00:00:00 2001 From: Tyler Ballast Date: Mon, 8 Mar 2021 14:40:54 +0100 Subject: [PATCH 168/185] Add whitespace to SDK documentation where necessary (#8919) * Add a space between table title and the line above it to resolve issues when translating markdown to asciidoc * Regenerate Samples Co-authored-by: Tyler Ballast Co-authored-by: tballast --- api_doc.mustache | 2 ++ model_doc.mustache | 1 + 2 files changed, 3 insertions(+) diff --git a/api_doc.mustache b/api_doc.mustache index 36eac3ca91..7c19d58ebd 100644 --- a/api_doc.mustache +++ b/api_doc.mustache @@ -38,6 +38,7 @@ Method | HTTP request | Description {{/authMethods}} {{/hasAuthMethods}} {{> api_doc_example }} + ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes @@ -61,6 +62,7 @@ Name | Type | Description | Notes - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} {{#responses.0}} + ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| diff --git a/model_doc.mustache b/model_doc.mustache index 7971d6c85f..ff7358618e 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -2,6 +2,7 @@ {{#description}}{{&description}} {{/description}} + ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- From 5991fc96bd43697c73ab55f9bcd0ad382852fbb1 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 31 Mar 2021 08:48:12 -0700 Subject: [PATCH 169/185] [python] Fixes additional_properties_type for models (#8802) * Fixes additionalProperties values for models, updates docs, adds tag test of it, fixes frit and gmfruit tests * Moves this.setDisallowAdditionalPropertiesIfNotPresent higher * Makes setting additional_properties_model_instances contingent on the presence of addprosp in schema, updates sample spec composed schemas to remove addprops False form two * Fixes oneOf anyOf allOf instantiation logic * Removes Address from Cat definition * Adds required vars for apple and banana, removes required vars from composed schema init sig * Updates composed schema vars to be set on self and all composed instances * Removes get_unused_args, get_var_name_to_model_instances, and get_additional_properties_model_instances * Fixes fruit + deserilization tests, creates ComposedSchemaWithPropsAndNoAddProps * Fixes FruitReq tests * Fixes GmFruit tests * Fixes discard_unknown_keys tests * Samples updated * Removes additionalproperties False in Child * Samples updated * Improves handling of v2 and v3 specs for isFreeFormObject, v2 sample spec updated with link to bug * Adds cli option disallowAdditionalPropertiesIfNotPresent to python * Adds getAdditionalProperties method so the value for addProps will be correct * Reverts file * Reverts file * Updates python doc * Reverted anytype_3 definition * Updates test_deserialize_lizard * Updates test_deserialize_dict_str_dog * Updates testDog * Updates testChild * Adds v2 python_composition sample * Adds needed files for python testing * Adds existing tests into the new python sample * Fixes test_dog * Removes addProps false form Dog * Fixes testChild * Updates how additionalProperties are set * Fixes empty_map type * Type generation fixed for v2 and v3 specs * Refactors getTypeString, updates artifactids in pom.xml files * Adds new python sample to CI testing I think * Fixes artifactId collision, regenrates docs --- model_doc.mustache | 6 +- model_templates/classvars.mustache | 10 +- model_templates/method_init_composed.mustache | 65 +++++-- .../methods_setattr_getattr_composed.mustache | 67 ++++--- model_utils.mustache | 182 +++++++----------- 5 files changed, 164 insertions(+), 166 deletions(-) diff --git a/model_doc.mustache b/model_doc.mustache index ff7358618e..3f7c8263df 100644 --- a/model_doc.mustache +++ b/model_doc.mustache @@ -28,9 +28,9 @@ Name | Type | Description | Notes {{#optionalVars}} **{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} -{{#additionalPropertiesType}} -**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] -{{/additionalPropertiesType}} +{{#additionalProperties}} +**any string name** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | any string name can be used but the value must be the correct type | [optional] +{{/additionalProperties}} [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/model_templates/classvars.mustache b/model_templates/classvars.mustache index 88ae5df9f1..0e5ff25b97 100644 --- a/model_templates/classvars.mustache +++ b/model_templates/classvars.mustache @@ -60,7 +60,7 @@ {{/optionalVars}} } -{{#additionalPropertiesType}} +{{#additionalProperties}} @cached_property def additional_properties_type(): """ @@ -72,11 +72,11 @@ lazy_import() {{/-first}} {{/imports}} - return ({{{additionalPropertiesType}}},) # noqa: E501 -{{/additionalPropertiesType}} -{{^additionalPropertiesType}} + return ({{{dataType}}},) # noqa: E501 +{{/additionalProperties}} +{{^additionalProperties}} additional_properties_type = None -{{/additionalPropertiesType}} +{{/additionalProperties}} _nullable = {{#isNullable}}True{{/isNullable}}{{^isNullable}}False{{/isNullable}} diff --git a/model_templates/method_init_composed.mustache b/model_templates/method_init_composed.mustache index 9b29837971..ca0505ead9 100644 --- a/model_templates/method_init_composed.mustache +++ b/model_templates/method_init_composed.mustache @@ -10,7 +10,52 @@ '_additional_properties_model_instances', ]) -{{> model_templates/method_init_shared }} + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, @@ -19,28 +64,18 @@ '_configuration': _configuration, '_visited_composed_classes': self._visited_composed_classes, } - required_args = { -{{#requiredVars}} - '{{name}}': {{name}}, -{{/requiredVars}} - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) composed_info = validate_get_composed_info( - constant_args, model_args, self) + constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] + discarded_args = composed_info[3] - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) for var_name, var_value in kwargs.items(): - if var_name in unused_args and \ + if var_name in discarded_args and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ - not self._additional_properties_model_instances: + self._additional_properties_model_instances: # discard variable. continue setattr(self, var_name, var_value) \ No newline at end of file diff --git a/model_templates/methods_setattr_getattr_composed.mustache b/model_templates/methods_setattr_getattr_composed.mustache index 6b1013ca99..de7887ebdb 100644 --- a/model_templates/methods_setattr_getattr_composed.mustache +++ b/model_templates/methods_setattr_getattr_composed.mustache @@ -4,27 +4,43 @@ self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__['_var_name_to_model_instances'][name] = ( - model_instance - ) - return None + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -34,13 +50,12 @@ return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get( - name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: diff --git a/model_utils.mustache b/model_utils.mustache index 07b77a99d1..9b5a8dd9e8 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1291,8 +1291,13 @@ def get_allof_instances(self, model_args, constant_args): self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1300,20 +1305,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas['allOf']: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1373,31 +1366,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1454,24 +1425,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1484,47 +1439,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances( - composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas['allOf']: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1568,36 +1510,42 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] - # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances( - self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = ( - get_additional_properties_model_instances(composed_instances, self) - ) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if len(unused_args) > 0 and \ - len(additional_properties_model_instances) == 0 and \ - (self._configuration is None or - not self._configuration.discard_unknown_keys): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + # map variable names to composed_instances + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, - unused_args + discarded_args ] From 01bc01a5a350b14f5c7ae2c28acc03b963984e6a Mon Sep 17 00:00:00 2001 From: Justin Black Date: Thu, 1 Apr 2021 13:34:19 -0700 Subject: [PATCH 170/185] Fixes serialization of array items in model_to_dict [python] (#9153) * Adds tests of endpoint with inline and refed model * Regen samples * Samples regenerated --- model_utils.mustache | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/model_utils.mustache b/model_utils.mustache index 07b77a99d1..396948e0a3 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1211,13 +1211,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types - result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] - else: - result[attr] = [model_to_dict(x, serialize=serialize) for x in value] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], From fac55a6924eecbac6b2569de44133e58977312ce Mon Sep 17 00:00:00 2001 From: gbmarc1 Date: Sat, 10 Apr 2021 22:00:32 -0400 Subject: [PATCH 171/185] Bug - python client deserialization when attribute named `self` (#9006) * fix by mapping outside of class * tests * regeneration and tests * server * INDENT * a * enable mapping * Revert "server" This reverts commit 6fc9712fb550d258d0332df243ea5080565c6770. * Samples regenerated Co-authored-by: Justin Black --- model_utils.mustache | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/model_utils.mustache b/model_utils.mustache index 396948e0a3..fb60afb60d 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1283,11 +1283,16 @@ def get_valid_classes_phrase(input_classes): def convert_js_args_to_python_args(fn): from functools import wraps @wraps(fn) - def wrapped_init(self, *args, **kwargs): + def wrapped_init(_self, *args, **kwargs): + """ + An attribute named `self` received from the api will conflicts with the reserved `self` + parameter of a class method. During generation, `self` attributes are mapped + to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. + """ spec_property_naming = kwargs.get('_spec_property_naming', False) if spec_property_naming: - kwargs = change_keys_js_to_python(kwargs, self.__class__) - return fn(self, *args, **kwargs) + kwargs = change_keys_js_to_python(kwargs, _self.__class__) + return fn(_self, *args, **kwargs) return wrapped_init From 00a1cf6719ca026458687fadc922d0f6dbf10ce0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 26 Apr 2021 14:01:40 +0800 Subject: [PATCH 172/185] [Python] Fix exclusive min and max (#9340) * [Python] Fix exclusiveMinimum and exclusiveMaximum conditions * add tests, update samples Co-authored-by: Jiri Kuncar --- api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.mustache b/api.mustache index cbad6df2c5..37339fc511 100644 --- a/api.mustache +++ b/api.mustache @@ -230,8 +230,8 @@ class {{classname}}(object): 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} 'min_items': {{minItems}},{{/minItems}}{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}{{^exclusiveMaximum}}'inclusive_maximum'{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}{{^exclusiveMinimum}}'inclusive_minimum'{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} 'regex': { 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} From c5b155e31848d4f4b600809b758c3d52013b38ed Mon Sep 17 00:00:00 2001 From: gbmarc1 Date: Mon, 10 May 2021 21:41:26 -0400 Subject: [PATCH 173/185] [python] readonly constructors (#9409) * readonly * other tests * doc * python samples * model utils --- model.mustache | 3 + model_templates/invalid_pos_args.mustache | 9 + ...method_from_openapi_data_composed.mustache | 66 ++++++++ .../method_from_openapi_data_normal.mustache | 17 ++ .../method_from_openapi_data_shared.mustache | 49 ++++++ .../method_from_openapi_data_simple.mustache | 62 +++++++ model_templates/method_init_composed.mustache | 19 +-- model_templates/method_init_normal.mustache | 7 +- model_templates/method_init_shared.mustache | 18 +- model_templates/method_init_simple.mustache | 10 +- model_templates/model_composed.mustache | 15 ++ model_templates/model_normal.mustache | 15 ++ model_templates/model_simple.mustache | 6 +- model_utils.mustache | 155 +++++++++++++++--- 14 files changed, 400 insertions(+), 51 deletions(-) create mode 100644 model_templates/invalid_pos_args.mustache create mode 100644 model_templates/method_from_openapi_data_composed.mustache create mode 100644 model_templates/method_from_openapi_data_normal.mustache create mode 100644 model_templates/method_from_openapi_data_shared.mustache create mode 100644 model_templates/method_from_openapi_data_simple.mustache diff --git a/model.mustache b/model.mustache index 680b60644c..c8e1bfaa00 100644 --- a/model.mustache +++ b/model.mustache @@ -17,6 +17,9 @@ from {{packageName}}.model_utils import ( # noqa: F401 none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from {{packageName}}.exceptions import ApiAttributeError + {{#models}} {{#model}} {{#imports}} diff --git a/model_templates/invalid_pos_args.mustache b/model_templates/invalid_pos_args.mustache new file mode 100644 index 0000000000..143d50c825 --- /dev/null +++ b/model_templates/invalid_pos_args.mustache @@ -0,0 +1,9 @@ + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) \ No newline at end of file diff --git a/model_templates/method_from_openapi_data_composed.mustache b/model_templates/method_from_openapi_data_composed.mustache new file mode 100644 index 0000000000..81a4af3f82 --- /dev/null +++ b/model_templates/method_from_openapi_data_composed.mustache @@ -0,0 +1,66 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + +{{> model_templates/invalid_pos_args }} + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + return self \ No newline at end of file diff --git a/model_templates/method_from_openapi_data_normal.mustache b/model_templates/method_from_openapi_data_normal.mustache new file mode 100644 index 0000000000..3b82ba7fc3 --- /dev/null +++ b/model_templates/method_from_openapi_data_normal.mustache @@ -0,0 +1,17 @@ +{{> model_templates/method_from_openapi_data_shared }} + +{{#isEnum}} + self.value = value +{{/isEnum}} +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self \ No newline at end of file diff --git a/model_templates/method_from_openapi_data_shared.mustache b/model_templates/method_from_openapi_data_shared.mustache new file mode 100644 index 0000000000..9dd84236b9 --- /dev/null +++ b/model_templates/method_from_openapi_data_shared.mustache @@ -0,0 +1,49 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + +{{> model_templates/invalid_pos_args }} + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) \ No newline at end of file diff --git a/model_templates/method_from_openapi_data_simple.mustache b/model_templates/method_from_openapi_data_simple.mustache new file mode 100644 index 0000000000..0756046ede --- /dev/null +++ b/model_templates/method_from_openapi_data_simple.mustache @@ -0,0 +1,62 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """{{classname}} - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + + Keyword Args: + value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{> model_templates/docstring_init_required_kwargs }} + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) +{{#defaultValue}} + else: + value = {{{defaultValue}}} +{{/defaultValue}} +{{^defaultValue}} + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) +{{/defaultValue}} + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + +{{> model_templates/invalid_pos_args }} + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self \ No newline at end of file diff --git a/model_templates/method_init_composed.mustache b/model_templates/method_init_composed.mustache index ca0505ead9..cc6f4b46bd 100644 --- a/model_templates/method_init_composed.mustache +++ b/model_templates/method_init_composed.mustache @@ -16,12 +16,14 @@ Keyword Args: {{#requiredVars}} +{{^isReadOnly}} {{#defaultValue}} {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{/defaultValue}} {{^defaultValue}} {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} {{/defaultValue}} +{{/isReadOnly}} {{/requiredVars}} {{> model_templates/docstring_init_required_kwargs }} {{#optionalVars}} @@ -30,9 +32,11 @@ """ {{#requiredVars}} +{{^isReadOnly}} {{#defaultValue}} {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) {{/defaultValue}} +{{/isReadOnly}} {{/requiredVars}} _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -40,15 +44,7 @@ _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if args: - raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( - args, - self.__class__.__name__, - ), - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) +{{> model_templates/invalid_pos_args }} self._data_store = {} self._check_type = _check_type @@ -78,4 +74,7 @@ self._additional_properties_model_instances: # discard variable. continue - setattr(self, var_name, var_value) \ No newline at end of file + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") \ No newline at end of file diff --git a/model_templates/method_init_normal.mustache b/model_templates/method_init_normal.mustache index e670b4ffb4..bc5e7686f8 100644 --- a/model_templates/method_init_normal.mustache +++ b/model_templates/method_init_normal.mustache @@ -13,7 +13,9 @@ self.value = value {{/isEnum}} {{#requiredVars}} +{{^isReadOnly}} self.{{name}} = {{name}} +{{/isReadOnly}} {{/requiredVars}} for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ @@ -22,4 +24,7 @@ self.additional_properties_type is None: # discard variable. continue - setattr(self, var_name, var_value) \ No newline at end of file + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") \ No newline at end of file diff --git a/model_templates/method_init_shared.mustache b/model_templates/method_init_shared.mustache index a766c14bac..0eb4de6a13 100644 --- a/model_templates/method_init_shared.mustache +++ b/model_templates/method_init_shared.mustache @@ -1,8 +1,9 @@ @convert_js_args_to_python_args - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 + def __init__(self{{#requiredVars}}{{^isReadOnly}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/isReadOnly}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#requiredVars}} +{{^isReadOnly}} {{#-first}} Args: {{/-first}} @@ -12,12 +13,15 @@ {{#-last}} {{/-last}} +{{/isReadOnly}} {{/requiredVars}} Keyword Args: {{#requiredVars}} +{{^isReadOnly}} {{#defaultValue}} {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{/defaultValue}} +{{/isReadOnly}} {{/requiredVars}} {{> model_templates/docstring_init_required_kwargs }} {{#optionalVars}} @@ -26,9 +30,11 @@ """ {{#requiredVars}} +{{^isReadOnly}} {{#defaultValue}} {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) {{/defaultValue}} +{{/isReadOnly}} {{/requiredVars}} _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -36,15 +42,7 @@ _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if args: - raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( - args, - self.__class__.__name__, - ), - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) +{{> model_templates/invalid_pos_args }} self._data_store = {} self._check_type = _check_type diff --git a/model_templates/method_init_simple.mustache b/model_templates/method_init_simple.mustache index 9e06a6a22e..c6950a7d36 100644 --- a/model_templates/method_init_simple.mustache +++ b/model_templates/method_init_simple.mustache @@ -46,15 +46,7 @@ _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if args: - raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( - args, - self.__class__.__name__, - ), - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) +{{> model_templates/invalid_pos_args }} self._data_store = {} self._check_type = _check_type diff --git a/model_templates/model_composed.mustache b/model_templates/model_composed.mustache index 76fe3a8f50..9a5ab0f66b 100644 --- a/model_templates/model_composed.mustache +++ b/model_templates/model_composed.mustache @@ -24,6 +24,21 @@ class {{classname}}(ModelComposed): {{/optionalVars}} } + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + +{{> model_templates/method_from_openapi_data_composed }} + {{> model_templates/method_init_composed }} @cached_property diff --git a/model_templates/model_normal.mustache b/model_templates/model_normal.mustache index 9aada8f5a0..513aa01e66 100644 --- a/model_templates/model_normal.mustache +++ b/model_templates/model_normal.mustache @@ -24,6 +24,21 @@ class {{classname}}(ModelNormal): {{/optionalVars}} } + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + _composed_schemas = {} +{{> model_templates/method_from_openapi_data_normal}} + {{> model_templates/method_init_normal}} \ No newline at end of file diff --git a/model_templates/model_simple.mustache b/model_templates/model_simple.mustache index a4055af756..1a41a9cf7e 100644 --- a/model_templates/model_simple.mustache +++ b/model_templates/model_simple.mustache @@ -13,6 +13,10 @@ class {{classname}}(ModelSimple): attribute_map = {} + read_only_vars = set() + _composed_schemas = None -{{> model_templates/method_init_simple}} \ No newline at end of file +{{> model_templates/method_init_simple}} + +{{> model_templates/method_from_openapi_data_simple}} \ No newline at end of file diff --git a/model_utils.mustache b/model_utils.mustache index 3621a5eec5..73e6e7d555 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -21,6 +21,22 @@ none_type = type(None) file_type = io.IOBase +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(_self, *args, **kwargs): + """ + An attribute named `self` received from the api will conflicts with the reserved `self` + parameter of a class method. During generation, `self` attributes are mapped + to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. + """ + spec_property_naming = kwargs.get('_spec_property_naming', False) + if spec_property_naming: + kwargs = change_keys_js_to_python(kwargs, _self if isinstance(_self, type) else _self.__class__) + return fn(_self, *args, **kwargs) + return wrapped_init + + class cached_property(object): # this caches the result of the function call for fn with no inputs # use this as a decorator on fuction methods that you want converted @@ -212,6 +228,121 @@ class OpenApiModel(object): return new_inst + @classmethod + @convert_js_args_to_python_args + def _new_from_openapi_data(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: If Animal has a discriminator + # petType and we pass in "Dog", and the class Dog + # allOf includes Animal, we move through Animal + # once using the discriminator, and pick Dog. + # Then in the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return cls._from_openapi_data(*args, **kwargs) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get('_path_to_item', ()) + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return cls._from_openapi_data(*args, **kwargs) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = cls._from_openapi_data(*args, **kwargs) + + + new_inst = new_cls._new_from_openapi_data(*args, **kwargs) + return new_inst + + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their swagger/openapi""" @@ -911,14 +1042,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _spec_property_naming=spec_property_naming) if issubclass(model_class, ModelSimple): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) elif isinstance(model_data, list): - return model_class(*model_data, **kw_args) + return model_class._new_from_openapi_data(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) - return model_class(**kw_args) + return model_class._new_from_openapi_data(**kw_args) elif isinstance(model_data, PRIMITIVE_TYPES): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) def deserialize_file(response_data, configuration, content_disposition=None): @@ -1280,22 +1411,6 @@ def get_valid_classes_phrase(input_classes): return "is one of [{0}]".format(", ".join(all_class_names)) -def convert_js_args_to_python_args(fn): - from functools import wraps - @wraps(fn) - def wrapped_init(_self, *args, **kwargs): - """ - An attribute named `self` received from the api will conflicts with the reserved `self` - parameter of a class method. During generation, `self` attributes are mapped - to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. - """ - spec_property_naming = kwargs.get('_spec_property_naming', False) - if spec_property_naming: - kwargs = change_keys_js_to_python(kwargs, _self.__class__) - return fn(_self, *args, **kwargs) - return wrapped_init - - def get_allof_instances(self, model_args, constant_args): """ Args: From 2c7a470f913ede4b1a6da1aacf47c58d9f8846c7 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 17 May 2021 20:15:53 -0700 Subject: [PATCH 174/185] Fixes python test_fake_api tests (#9483) * Fixes test_upload_download_file * Fixes test_string * Fixes test_string_enum * Fixes test_number_with_validations test_composed_one_of_number_with_validations * Fixes two more tests * Fixes test_array_of_enums * Fixes two tests * Removes comment * Fixes serializationf of composed schema object models, fixes test * Samples regenerated * Removes pdb --- model_utils.mustache | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/model_utils.mustache b/model_utils.mustache index 73e6e7d555..c7944e4fdc 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -1335,12 +1335,20 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) + seen_json_attribute_names = set() + used_fallback_python_attribute_names = set() + py_to_json_map = {} for model_instance in model_instances: for attr, value in model_instance._data_store.items(): if serialize: # we use get here because additional property key names do not # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) + try: + attr = model_instance.attribute_map[attr] + py_to_json_map.update(model_instance.attribute_map) + seen_json_attribute_names.add(attr) + except KeyError: + used_fallback_python_attribute_names.add(attr) if isinstance(value, list): if not value: # empty list or None @@ -1368,6 +1376,16 @@ def model_to_dict(model_instance, serialize=True): result[attr] = model_to_dict(value, serialize=serialize) else: result[attr] = value + if serialize: + for python_key in used_fallback_python_attribute_names: + json_key = py_to_json_map.get(python_key) + if json_key is None: + continue + if python_key == json_key: + continue + json_key_assigned_no_need_for_python_key = json_key in seen_json_attribute_names + if json_key_assigned_no_need_for_python_key: + del result[python_key] return result From f68be9ea6351f45da7b4b6afe4d5fd56720b2860 Mon Sep 17 00:00:00 2001 From: Daniel Krebs Date: Fri, 18 Jun 2021 09:09:55 +0200 Subject: [PATCH 175/185] [python][client] allow passing floats for _request_timeout (#9532) * [python][client] allow passing floats for _request_timeout While several method docstrings suggested that you could pass floats for _request_timeout and the underlying urllib3.Timeout can deal with them, the code only allowed integer values so far when passed as a single number. * [python][samples] update with fix for _request_timeout type --- api.mustache | 4 ++-- api_client.mustache | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.mustache b/api.mustache index 37339fc511..4be68cdf12 100644 --- a/api.mustache +++ b/api.mustache @@ -80,8 +80,8 @@ class {{classname}}(object): _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. - _request_timeout (float/tuple): timeout setting for this request. If one - number provided, it will be total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking diff --git a/api_client.mustache b/api_client.mustache index 8d6395a4c2..31d9e48354 100644 --- a/api_client.mustache +++ b/api_client.mustache @@ -127,7 +127,7 @@ class ApiClient(object): _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None ): @@ -359,7 +359,7 @@ class ApiClient(object): _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None ): @@ -695,7 +695,7 @@ class Endpoint(object): 'async_req': (bool,), '_host_index': (none_type, int), '_preload_content': (bool,), - '_request_timeout': (none_type, int, (int,), [int]), + '_request_timeout': (none_type, float, (float,), [float], int, (int,), [int]), '_return_http_data_only': (bool,), '_check_input_type': (bool,), '_check_return_type': (bool,) From 09212e5be86c11d6f37b73872f8a7b0e9ed0c44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Sun, 4 Jul 2021 06:29:55 +0200 Subject: [PATCH 176/185] Fix minor typo in @cached_property docstring (#9886) --- model_utils.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_utils.mustache b/model_utils.mustache index c7944e4fdc..4615a34ec3 100644 --- a/model_utils.mustache +++ b/model_utils.mustache @@ -39,7 +39,7 @@ def convert_js_args_to_python_args(fn): class cached_property(object): # this caches the result of the function call for fn with no inputs - # use this as a decorator on fuction methods that you want converted + # use this as a decorator on function methods that you want converted # into cached properties result_key = '_results' From 0786ea492e1f57cd77603ea8e95aa05caec18812 Mon Sep 17 00:00:00 2001 From: John Boyes <154404+johnboyes@users.noreply.github.com> Date: Wed, 7 Jul 2021 04:04:26 +0100 Subject: [PATCH 177/185] [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests (#9852) * [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests The Python generator no longer sets a default `Content-Type` of `application/json` for `GET`, `HEAD` and `DELETE` requests. Having the `Content-Type` set for these requests was causing issues with other tools which insist that GET, HEAD and DELETE requests do not have a Content-Type (as per the OpenAPI 3 specification). An example of the problem that this commit fixes is when using [Prism][1] as a [validation proxy][2]. [Prism rejects any GET request that has a Content-Type][3]. Here is [an example of the problem manifesting itself][4]. To validate the fix in this commit: 1. Start with any OpenAPI3 spec e.g. the Petstore example at https://editor.swagger.io/ 2. Generate Python client code for the spec 3. Look at the generated `rest.py` e.g. in the [standard sample in this repo][5] and see that the `Content-Type` defaults to `application/json` for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than there being no `Content-Type` for `GET`, `HEAD` and `DELETE`. Fixes #9831 [1]: https://github.com/stoplightio/prism [2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md [3]: https://github.com/stoplightio/prism/issues/1408#issuecomment-690948020 [4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18 [5]: https://github.com/OpenAPITools/openapi-generator/blob/969cea8ce10cb9d012c3936fb377d631c0d044c9/samples/openapi3/client/petstore/python/petstore_api/rest.py#L141 * update samples * Fix Python DELETE bug introduced in earlier commit The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the standard Python generator. This commit fixes that bug and also includes the updated samples. Co-authored-by: William Cheng --- rest.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rest.mustache b/rest.mustache index 9e73386489..21c8d5b44c 100644 --- a/rest.mustache +++ b/rest.mustache @@ -129,15 +129,15 @@ class RESTClientObject(object): timeout = urllib3.Timeout( connect=_request_timeout[0], read=_request_timeout[1]) - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' - try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests + if (method != 'DELETE') and ('Content-Type' not in headers): + headers['Content-Type'] = 'application/json' if query_params: url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): + if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)): request_body = None if body is not None: request_body = json.dumps(body) From e8d36dd699c70d1bd660bdede2de4c6fce578a26 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Tue, 27 Jul 2021 14:41:15 +0200 Subject: [PATCH 178/185] Add missing _from_openapi_data --- .generator/templates/model_templates/model_composed.mustache | 2 ++ .generator/templates/model_templates/model_normal.mustache | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.generator/templates/model_templates/model_composed.mustache b/.generator/templates/model_templates/model_composed.mustache index 5b348e9d23..8f6a8dc0b5 100644 --- a/.generator/templates/model_templates/model_composed.mustache +++ b/.generator/templates/model_templates/model_composed.mustache @@ -17,6 +17,8 @@ class {{classname}}(ModelComposed): attribute_map = {} +{{> model_templates/method_from_openapi_data_composed }} + {{> model_templates/method_init_composed }} @cached_property diff --git a/.generator/templates/model_templates/model_normal.mustache b/.generator/templates/model_templates/model_normal.mustache index 9aada8f5a0..041452233d 100644 --- a/.generator/templates/model_templates/model_normal.mustache +++ b/.generator/templates/model_templates/model_normal.mustache @@ -26,4 +26,6 @@ class {{classname}}(ModelNormal): _composed_schemas = {} +{{> model_templates/method_from_openapi_data_normal}} + {{> model_templates/method_init_normal}} \ No newline at end of file From cda9b1a0651719d4633fc837ef83968bfd118fb8 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Tue, 27 Jul 2021 19:06:08 +0200 Subject: [PATCH 179/185] Add missing read_only_vars --- .../model_templates/model_composed.mustache | 13 +++++++++++++ .../templates/model_templates/model_normal.mustache | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/.generator/templates/model_templates/model_composed.mustache b/.generator/templates/model_templates/model_composed.mustache index 8f6a8dc0b5..38d9ba296e 100644 --- a/.generator/templates/model_templates/model_composed.mustache +++ b/.generator/templates/model_templates/model_composed.mustache @@ -17,6 +17,19 @@ class {{classname}}(ModelComposed): attribute_map = {} + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + {{> model_templates/method_from_openapi_data_composed }} {{> model_templates/method_init_composed }} diff --git a/.generator/templates/model_templates/model_normal.mustache b/.generator/templates/model_templates/model_normal.mustache index 041452233d..513aa01e66 100644 --- a/.generator/templates/model_templates/model_normal.mustache +++ b/.generator/templates/model_templates/model_normal.mustache @@ -24,6 +24,19 @@ class {{classname}}(ModelNormal): {{/optionalVars}} } + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + _composed_schemas = {} {{> model_templates/method_from_openapi_data_normal}} From 90fd51299cec27e3cdefb92713bada2e65a5c4f6 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Wed, 28 Jul 2021 10:44:12 +0200 Subject: [PATCH 180/185] Fix case for one list --- .generator/templates/model_utils.mustache | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.generator/templates/model_utils.mustache b/.generator/templates/model_utils.mustache index 6be247b904..d16c9e235f 100644 --- a/.generator/templates/model_utils.mustache +++ b/.generator/templates/model_utils.mustache @@ -1044,7 +1044,10 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, if issubclass(model_class, ModelSimple): return model_class._new_from_openapi_data(model_data, **kw_args) elif isinstance(model_data, list): - return model_class._new_from_openapi_data(*model_data, **kw_args) + if issubclass(model_class, ModelComposed) and allows_single_value_input(model_class): + return model_class._new_from_openapi_data(model_data, **kw_args) + else: + return model_class._new_from_openapi_data(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) return model_class._new_from_openapi_data(**kw_args) From 0e26a9e7df4cb1075bc37ba4bdfde4241cc7f061 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Wed, 28 Jul 2021 10:46:13 +0200 Subject: [PATCH 181/185] Fix readme links --- .generator/templates/model_doc.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.generator/templates/model_doc.mustache b/.generator/templates/model_doc.mustache index f0a3a81320..d50213c365 100644 --- a/.generator/templates/model_doc.mustache +++ b/.generator/templates/model_doc.mustache @@ -37,6 +37,6 @@ Name | Type | Description | Notes {{/additionalProperties}} {{/oneOf}} -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) +[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) {{/model}}{{/models}} From 4acacbaa21f174152826585ba6c6b9d8bed4c5e3 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Wed, 28 Jul 2021 16:30:53 +0200 Subject: [PATCH 182/185] fix oneOf --- .../methods_setattr_getattr_composed.mustache | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/.generator/templates/model_templates/methods_setattr_getattr_composed.mustache b/.generator/templates/model_templates/methods_setattr_getattr_composed.mustache index de7887ebdb..2de622eb65 100644 --- a/.generator/templates/model_templates/methods_setattr_getattr_composed.mustache +++ b/.generator/templates/model_templates/methods_setattr_getattr_composed.mustache @@ -4,37 +4,7 @@ self.__dict__[name] = value return - """ - Use cases: - 1. additional_properties_type is None (additionalProperties == False in spec) - Check for property presence in self.openapi_types - if not present then throw an error - if present set in self, set attribute - always set on composed schemas - 2. additional_properties_type exists - set attribute on self - always set on composed schemas - """ - if self.additional_properties_type is None: - """ - For an attribute to exist on a composed schema it must: - - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND - - fulfill schema_requirements in each oneOf/anyOf/allOf schemas - - schema_requirements: - For an attribute to exist on a schema it must: - - be present in properties at the schema OR - - have additionalProperties unset (defaults additionalProperties = any type) OR - - have additionalProperties set - """ - if name not in self.openapi_types: - raise ApiAttributeError( - "{0} has no attribute '{1}'".format( - type(self).__name__, name), - [e for e in [self._path_to_item, name] if e] - ) - # attribute must be set on self and composed instances - self.set_attribute(name, value) + # Set attribute on composed instances for model_instance in self._composed_instances: setattr(model_instance, name, value) if name not in self._var_name_to_model_instances: From c494bd77d5f1961910932dacccbc087ac3776fc3 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Thu, 29 Jul 2021 11:48:29 +0200 Subject: [PATCH 183/185] don't set attributes on composed schema --- .../method_from_openapi_data_composed.mustache | 9 --------- .../model_templates/method_init_composed.mustache | 12 ------------ 2 files changed, 21 deletions(-) diff --git a/.generator/templates/model_templates/method_from_openapi_data_composed.mustache b/.generator/templates/model_templates/method_from_openapi_data_composed.mustache index 81a4af3f82..80d0934fb3 100644 --- a/.generator/templates/model_templates/method_from_openapi_data_composed.mustache +++ b/.generator/templates/model_templates/method_from_openapi_data_composed.mustache @@ -54,13 +54,4 @@ self._additional_properties_model_instances = composed_info[2] discarded_args = composed_info[3] - for var_name, var_value in kwargs.items(): - if var_name in discarded_args and \ - self._configuration is not None and \ - self._configuration.discard_unknown_keys and \ - self._additional_properties_model_instances: - # discard variable. - continue - setattr(self, var_name, var_value) - return self \ No newline at end of file diff --git a/.generator/templates/model_templates/method_init_composed.mustache b/.generator/templates/model_templates/method_init_composed.mustache index cc6f4b46bd..b95c56386a 100644 --- a/.generator/templates/model_templates/method_init_composed.mustache +++ b/.generator/templates/model_templates/method_init_composed.mustache @@ -66,15 +66,3 @@ self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] discarded_args = composed_info[3] - - for var_name, var_value in kwargs.items(): - if var_name in discarded_args and \ - self._configuration is not None and \ - self._configuration.discard_unknown_keys and \ - self._additional_properties_model_instances: - # discard variable. - continue - setattr(self, var_name, var_value) - if var_name in self.read_only_vars: - raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes.") \ No newline at end of file From 195c41eee1235097de714411ec670eab1989dce0 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Fri, 30 Jul 2021 13:55:01 +0200 Subject: [PATCH 184/185] add gitattributes --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..30d4b1d940 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +src/datadog_api_client/v*/**/* linguist-generated +docs/v*/* linguist-generated From 91ce590e715bfe33cb1d99feea43d01adc0562b9 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 30 Jul 2021 12:49:47 +0000 Subject: [PATCH 185/185] Regenerate client from commit a54f925 of spec repo --- .apigentools-info | 8 +- .openapi-generator/FILES | 1 - .openapi-generator/VERSION | 2 +- docs/v1/AWSIntegrationApi.md | 16 +- docs/v1/AWSLogsIntegrationApi.md | 12 +- docs/v1/AzureIntegrationApi.md | 16 +- docs/v1/DashboardListsApi.md | 22 - docs/v1/DashboardsApi.md | 10 - docs/v1/DowntimesApi.md | 62 --- docs/v1/EventsApi.md | 3 - docs/v1/GCPIntegrationApi.md | 12 +- docs/v1/KeyManagementApi.md | 10 - docs/v1/LogsApi.md | 4 +- docs/v1/LogsIndexesApi.md | 1 - docs/v1/LogsPipelinesApi.md | 6 - docs/v1/MetricsApi.md | 1 - docs/v1/MonitorSearchCount.md | 2 +- docs/v1/MonitorsApi.md | 97 +---- docs/v1/OrganizationsApi.md | 1 - docs/v1/SLOBulkDelete.md | 2 +- docs/v1/ServiceLevelObjectivesApi.md | 8 - docs/v1/SyntheticsAPITestResultData.md | 4 +- docs/v1/SyntheticsApi.md | 46 +- docs/v1/SyntheticsAssertionTarget.md | 2 +- ...ntheticsPrivateLocationCreationResponse.md | 2 +- docs/v1/SyntheticsStep.md | 2 +- docs/v1/SyntheticsStepDetail.md | 2 +- docs/v1/SyntheticsTestRequest.md | 2 +- docs/v1/UsersApi.md | 4 - docs/v2/IncidentServicesApi.md | 28 -- docs/v2/IncidentTeamsApi.md | 28 -- docs/v2/RolesApi.md | 4 - .../v1/api/aws_integration_api.py | 16 +- .../v1/api/aws_logs_integration_api.py | 12 +- .../v1/api/azure_integration_api.py | 16 +- .../v1/api/gcp_integration_api.py | 12 +- src/datadog_api_client/v1/api/logs_api.py | 4 +- src/datadog_api_client/v1/api/monitors_api.py | 4 +- src/datadog_api_client/v1/api_client.py | 6 +- .../v1/model/access_role.py | 96 +++++ .../v1/model/alert_graph_widget_definition.py | 97 +++++ .../alert_graph_widget_definition_type.py | 96 +++++ .../v1/model/alert_value_widget_definition.py | 97 +++++ .../alert_value_widget_definition_type.py | 96 +++++ .../v1/model/api_error_response.py | 89 ++++ src/datadog_api_client/v1/model/api_key.py | 93 +++++ .../v1/model/api_key_list_response.py | 86 ++++ .../v1/model/api_key_response.py | 86 ++++ .../v1/model/apm_stats_query_column_type.py | 92 ++++ .../v1/model/apm_stats_query_definition.py | 99 +++++ .../v1/model/apm_stats_query_row_type.py | 100 +++++ .../v1/model/application_key.py | 91 ++++ .../v1/model/application_key_list_response.py | 86 ++++ .../v1/model/application_key_response.py | 86 ++++ .../authentication_validation_response.py | 88 ++++ .../v1/model/aws_account.py | 93 +++++ .../model/aws_account_and_lambda_request.py | 91 ++++ .../v1/model/aws_account_create_response.py | 86 ++++ .../v1/model/aws_account_delete_request.py | 88 ++++ .../v1/model/aws_account_list_response.py | 86 ++++ .../v1/model/aws_logs_async_error.py | 87 ++++ .../v1/model/aws_logs_async_response.py | 87 ++++ .../v1/model/aws_logs_lambda.py | 86 ++++ .../v1/model/aws_logs_list_response.py | 88 ++++ .../model/aws_logs_list_services_response.py | 87 ++++ .../v1/model/aws_logs_services_request.py | 91 ++++ .../v1/model/aws_namespace.py | 100 +++++ .../v1/model/aws_tag_filter.py | 87 ++++ .../v1/model/aws_tag_filter_create_request.py | 88 ++++ .../v1/model/aws_tag_filter_delete_request.py | 87 ++++ .../v1/model/aws_tag_filter_list_response.py | 86 ++++ .../v1/model/azure_account.py | 92 ++++ .../v1/model/azure_account_list_response.py | 93 ++++- .../cancel_downtimes_by_scope_request.py | 89 ++++ .../v1/model/canceled_downtimes_ids.py | 86 ++++ .../v1/model/change_widget_definition.py | 96 +++++ .../v1/model/change_widget_definition_type.py | 96 +++++ .../v1/model/change_widget_request.py | 100 +++++ .../check_can_delete_monitor_response.py | 90 ++++ .../check_can_delete_monitor_response_data.py | 86 ++++ .../v1/model/check_can_delete_slo_response.py | 87 ++++ .../check_can_delete_slo_response_data.py | 86 ++++ .../model/check_status_widget_definition.py | 100 +++++ .../check_status_widget_definition_type.py | 96 +++++ .../v1/model/content_encoding.py | 100 +++++ src/datadog_api_client/v1/model/creator.py | 88 ++++ src/datadog_api_client/v1/model/dashboard.py | 111 +++++ .../v1/model/dashboard_bulk_action_data.py | 91 ++++ .../model/dashboard_bulk_action_data_list.py | 93 ++++- .../v1/model/dashboard_bulk_delete_request.py | 89 ++++ .../v1/model/dashboard_delete_response.py | 86 ++++ .../v1/model/dashboard_layout_type.py | 100 +++++ .../v1/model/dashboard_list.py | 103 +++++ .../model/dashboard_list_delete_response.py | 86 ++++ .../v1/model/dashboard_list_list_response.py | 86 ++++ .../v1/model/dashboard_reflow_type.py | 100 +++++ .../v1/model/dashboard_resource_type.py | 96 +++++ .../v1/model/dashboard_restore_request.py | 89 ++++ .../v1/model/dashboard_summary.py | 86 ++++ .../v1/model/dashboard_summary_definition.py | 94 +++++ .../v1/model/dashboard_template_variable.py | 91 ++++ .../dashboard_template_variable_preset.py | 87 ++++ ...ashboard_template_variable_preset_value.py | 87 ++++ .../v1/model/deleted_monitor.py | 86 ++++ .../model/distribution_widget_definition.py | 100 +++++ .../distribution_widget_definition_type.py | 96 +++++ .../v1/model/distribution_widget_request.py | 95 +++++ .../v1/model/distribution_widget_x_axis.py | 89 ++++ .../v1/model/distribution_widget_y_axis.py | 90 ++++ src/datadog_api_client/v1/model/downtime.py | 109 +++++ .../v1/model/downtime_child.py | 108 +++++ .../v1/model/downtime_recurrence.py | 91 ++++ src/datadog_api_client/v1/model/event.py | 101 +++++ .../v1/model/event_alert_type.py | 100 +++++ .../v1/model/event_create_request.py | 107 +++++ .../v1/model/event_create_response.py | 103 +++++ .../v1/model/event_list_response.py | 87 ++++ .../v1/model/event_priority.py | 100 +++++ .../v1/model/event_query_definition.py | 91 ++++ .../v1/model/event_response.py | 87 ++++ .../model/event_stream_widget_definition.py | 97 +++++ .../event_stream_widget_definition_type.py | 96 +++++ .../model/event_timeline_widget_definition.py | 96 +++++ .../event_timeline_widget_definition_type.py | 96 +++++ .../formula_and_function_event_aggregation.py | 100 +++++ ...ula_and_function_event_query_definition.py | 96 +++++ ...function_event_query_definition_compute.py | 91 ++++ ..._function_event_query_definition_search.py | 89 ++++ ...rmula_and_function_event_query_group_by.py | 91 ++++ ..._and_function_event_query_group_by_sort.py | 91 ++++ ...formula_and_function_events_data_source.py | 100 +++++ ...formula_and_function_metric_aggregation.py | 100 +++++ ...formula_and_function_metric_data_source.py | 96 +++++ ...la_and_function_metric_query_definition.py | 94 +++++ ..._and_function_process_query_data_source.py | 100 +++++ ...a_and_function_process_query_definition.py | 99 +++++ .../formula_and_function_query_definition.py | 137 ++++-- .../formula_and_function_response_format.py | 100 +++++ .../v1/model/free_text_widget_definition.py | 94 +++++ .../model/free_text_widget_definition_type.py | 96 +++++ .../v1/model/gcp_account.py | 98 +++++ .../v1/model/gcp_account_list_response.py | 93 ++++- .../v1/model/geomap_widget_definition.py | 100 +++++ .../model/geomap_widget_definition_style.py | 91 ++++ .../v1/model/geomap_widget_definition_type.py | 96 +++++ .../v1/model/geomap_widget_definition_view.py | 89 ++++ .../v1/model/geomap_widget_request.py | 92 ++++ .../v1/model/graph_snapshot.py | 88 ++++ .../v1/model/group_widget_definition.py | 98 +++++ .../v1/model/group_widget_definition_type.py | 96 +++++ .../v1/model/heat_map_widget_definition.py | 100 +++++ .../model/heat_map_widget_definition_type.py | 96 +++++ .../v1/model/heat_map_widget_request.py | 95 +++++ src/datadog_api_client/v1/model/host.py | 99 +++++ .../v1/model/host_list_response.py | 88 ++++ .../v1/model/host_map_request.py | 94 +++++ .../v1/model/host_map_widget_definition.py | 102 +++++ .../host_map_widget_definition_requests.py | 87 ++++ .../model/host_map_widget_definition_style.py | 89 ++++ .../model/host_map_widget_definition_type.py | 96 +++++ src/datadog_api_client/v1/model/host_meta.py | 86 ++++ .../v1/model/host_metrics.py | 88 ++++ .../v1/model/host_mute_response.py | 89 ++++ .../v1/model/host_mute_settings.py | 88 ++++ src/datadog_api_client/v1/model/host_tags.py | 87 ++++ .../v1/model/host_totals.py | 87 ++++ src/datadog_api_client/v1/model/http_log.py | 93 ++++- .../v1/model/http_log_error.py | 91 ++++ .../v1/model/http_log_item.py | 90 ++++ .../v1/model/http_method.py | 100 +++++ .../v1/model/i_frame_widget_definition.py | 91 ++++ .../model/i_frame_widget_definition_type.py | 96 +++++ .../v1/model/idp_form_data.py | 89 ++++ .../v1/model/idp_response.py | 89 ++++ .../v1/model/image_widget_definition.py | 98 +++++ .../v1/model/image_widget_definition_type.py | 96 +++++ .../v1/model/intake_payload_accepted.py | 86 ++++ .../v1/model/ip_prefixes_agents.py | 87 ++++ .../v1/model/ip_prefixes_api.py | 87 ++++ .../v1/model/ip_prefixes_apm.py | 87 ++++ .../v1/model/ip_prefixes_logs.py | 87 ++++ .../v1/model/ip_prefixes_process.py | 87 ++++ .../v1/model/ip_prefixes_synthetics.py | 89 ++++ .../v1/model/ip_prefixes_webhooks.py | 87 ++++ src/datadog_api_client/v1/model/ip_ranges.py | 94 +++++ .../v1/model/list_stream_column.py | 91 ++++ .../v1/model/list_stream_column_width.py | 100 +++++ .../v1/model/list_stream_query.py | 92 ++++ .../v1/model/list_stream_response_format.py | 96 +++++ .../v1/model/list_stream_source.py | 96 +++++ .../v1/model/list_stream_widget_definition.py | 97 +++++ .../list_stream_widget_definition_type.py | 96 +++++ .../v1/model/list_stream_widget_request.py | 93 +++++ src/datadog_api_client/v1/model/log.py | 87 ++++ .../v1/model/log_content.py | 91 ++++ .../v1/model/log_query_definition.py | 90 ++++ .../v1/model/log_query_definition_group_by.py | 91 ++++ .../log_query_definition_group_by_sort.py | 92 ++++ .../v1/model/log_query_definition_search.py | 89 ++++ .../v1/model/log_stream_widget_definition.py | 101 +++++ .../log_stream_widget_definition_type.py | 96 +++++ .../v1/model/logs_api_error.py | 88 ++++ .../v1/model/logs_api_error_response.py | 86 ++++ .../v1/model/logs_arithmetic_processor.py | 96 +++++ .../model/logs_arithmetic_processor_type.py | 96 +++++ .../v1/model/logs_attribute_remapper.py | 100 +++++ .../v1/model/logs_attribute_remapper_type.py | 96 +++++ .../v1/model/logs_by_retention.py | 88 ++++ .../model/logs_by_retention_monthly_usage.py | 87 ++++ .../v1/model/logs_by_retention_org_usage.py | 86 ++++ .../v1/model/logs_by_retention_orgs.py | 86 ++++ .../v1/model/logs_category_processor.py | 95 +++++ .../model/logs_category_processor_category.py | 87 ++++ .../v1/model/logs_category_processor_type.py | 96 +++++ .../v1/model/logs_date_remapper.py | 93 +++++ .../v1/model/logs_date_remapper_type.py | 96 +++++ .../v1/model/logs_exclusion.py | 91 ++++ .../v1/model/logs_exclusion_filter.py | 90 ++++ .../v1/model/logs_filter.py | 86 ++++ .../v1/model/logs_geo_ip_parser.py | 97 +++++ .../v1/model/logs_geo_ip_parser_type.py | 96 +++++ .../v1/model/logs_grok_parser.py | 97 +++++ .../v1/model/logs_grok_parser_rules.py | 90 ++++ .../v1/model/logs_grok_parser_type.py | 96 +++++ src/datadog_api_client/v1/model/logs_index.py | 97 +++++ .../v1/model/logs_index_list_response.py | 86 ++++ .../v1/model/logs_index_update_request.py | 93 +++++ .../v1/model/logs_indexes_order.py | 89 ++++ .../v1/model/logs_list_request.py | 94 +++++ .../v1/model/logs_list_request_time.py | 92 ++++ .../v1/model/logs_list_response.py | 88 ++++ .../v1/model/logs_lookup_processor.py | 98 +++++ .../v1/model/logs_lookup_processor_type.py | 96 +++++ .../v1/model/logs_message_remapper.py | 94 +++++ .../v1/model/logs_message_remapper_type.py | 96 +++++ .../v1/model/logs_pipeline.py | 99 +++++ .../v1/model/logs_pipeline_list.py | 93 ++++- .../v1/model/logs_pipeline_processor.py | 93 +++++ .../v1/model/logs_pipeline_processor_type.py | 96 +++++ .../v1/model/logs_pipelines_order.py | 89 ++++ .../v1/model/logs_processor.py | 146 +++++-- .../v1/model/logs_query_compute.py | 91 ++++ .../v1/model/logs_retention_agg_sum_usage.py | 89 ++++ .../v1/model/logs_retention_sum_usage.py | 89 ++++ .../v1/model/logs_service_remapper.py | 93 +++++ .../v1/model/logs_service_remapper_type.py | 96 +++++ src/datadog_api_client/v1/model/logs_sort.py | 100 +++++ .../v1/model/logs_status_remapper.py | 93 +++++ .../v1/model/logs_status_remapper_type.py | 96 +++++ .../v1/model/logs_string_builder_processor.py | 96 +++++ .../logs_string_builder_processor_type.py | 96 +++++ .../v1/model/logs_trace_remapper.py | 92 ++++ .../v1/model/logs_trace_remapper_type.py | 96 +++++ .../v1/model/logs_url_parser.py | 98 +++++ .../v1/model/logs_url_parser_type.py | 96 +++++ .../v1/model/logs_user_agent_parser.py | 98 +++++ .../v1/model/logs_user_agent_parser_type.py | 96 +++++ .../v1/model/metric_metadata.py | 94 +++++ .../v1/model/metric_search_response.py | 86 ++++ .../model/metric_search_response_results.py | 86 ++++ .../v1/model/metrics_list_response.py | 87 ++++ .../v1/model/metrics_payload.py | 89 ++++ .../v1/model/metrics_query_metadata.py | 112 +++++ .../v1/model/metrics_query_response.py | 104 +++++ .../v1/model/metrics_query_unit.py | 96 +++++ src/datadog_api_client/v1/model/monitor.py | 111 +++++ .../v1/model/monitor_device_id.py | 100 +++++ .../v1/model/monitor_group_search_response.py | 90 ++++ .../monitor_group_search_response_counts.py | 87 ++++ .../v1/model/monitor_group_search_result.py | 99 +++++ .../v1/model/monitor_options.py | 108 +++++ .../v1/model/monitor_options_aggregation.py | 88 ++++ .../v1/model/monitor_overall_states.py | 100 +++++ .../v1/model/monitor_search_count.py | 99 ++++- .../v1/model/monitor_search_response.py | 90 ++++ .../model/monitor_search_response_counts.py | 89 ++++ .../model/monitor_search_response_metadata.py | 94 +++++ .../v1/model/monitor_search_result.py | 106 +++++ .../monitor_search_result_notification.py | 90 ++++ .../v1/model/monitor_state.py | 86 ++++ .../v1/model/monitor_state_group.py | 91 ++++ .../monitor_summary_widget_definition.py | 102 +++++ .../monitor_summary_widget_definition_type.py | 96 +++++ .../model/monitor_threshold_window_options.py | 87 ++++ .../v1/model/monitor_thresholds.py | 91 ++++ .../v1/model/monitor_type.py | 100 +++++ .../v1/model/monitor_update_request.py | 107 +++++ .../v1/model/note_widget_definition.py | 99 +++++ .../v1/model/note_widget_definition_type.py | 96 +++++ .../v1/model/notebook_absolute_time.py | 92 ++++ .../v1/model/notebook_author.py | 94 +++++ .../v1/model/notebook_cell_create_request.py | 91 ++++ ...notebook_cell_create_request_attributes.py | 127 ++++-- .../v1/model/notebook_cell_resource_type.py | 96 +++++ .../v1/model/notebook_cell_response.py | 93 +++++ .../notebook_cell_response_attributes.py | 127 ++++-- .../v1/model/notebook_cell_time.py | 127 ++++-- .../v1/model/notebook_cell_update_request.py | 93 +++++ ...notebook_cell_update_request_attributes.py | 127 ++++-- .../v1/model/notebook_create_data.py | 91 ++++ .../model/notebook_create_data_attributes.py | 94 +++++ .../v1/model/notebook_create_request.py | 89 ++++ .../notebook_distribution_cell_attributes.py | 92 ++++ .../v1/model/notebook_global_time.py | 127 ++++-- .../v1/model/notebook_graph_size.py | 100 +++++ .../notebook_heat_map_cell_attributes.py | 92 ++++ .../notebook_log_stream_cell_attributes.py | 91 ++++ .../notebook_markdown_cell_attributes.py | 89 ++++ .../notebook_markdown_cell_definition.py | 91 ++++ .../notebook_markdown_cell_definition_type.py | 96 +++++ .../v1/model/notebook_relative_time.py | 89 ++++ .../v1/model/notebook_resource_type.py | 96 +++++ .../v1/model/notebook_response.py | 86 ++++ .../v1/model/notebook_response_data.py | 99 ++++- .../notebook_response_data_attributes.py | 100 +++++ .../v1/model/notebook_split_by.py | 91 ++++ .../v1/model/notebook_status.py | 96 +++++ .../notebook_timeseries_cell_attributes.py | 92 ++++ .../model/notebook_toplist_cell_attributes.py | 92 ++++ .../v1/model/notebook_update_cell.py | 126 ++++-- .../v1/model/notebook_update_data.py | 91 ++++ .../model/notebook_update_data_attributes.py | 94 +++++ .../v1/model/notebook_update_request.py | 89 ++++ .../v1/model/notebooks_response.py | 87 ++++ .../v1/model/notebooks_response_data.py | 99 ++++- .../notebooks_response_data_attributes.py | 98 +++++ .../v1/model/notebooks_response_meta.py | 86 ++++ .../v1/model/notebooks_response_page.py | 87 ++++ .../v1/model/organization.py | 94 +++++ .../v1/model/organization_billing.py | 86 ++++ .../v1/model/organization_create_body.py | 91 ++++ .../v1/model/organization_create_response.py | 89 ++++ .../v1/model/organization_list_response.py | 86 ++++ .../v1/model/organization_response.py | 86 ++++ .../v1/model/organization_settings.py | 95 +++++ .../v1/model/organization_settings_saml.py | 86 ++++ ..._settings_saml_autocreate_users_domains.py | 87 ++++ ...ation_settings_saml_idp_initiated_login.py | 86 ++++ .../organization_settings_saml_strict_mode.py | 86 ++++ .../v1/model/organization_subscription.py | 86 ++++ .../v1/model/pager_duty_service.py | 91 ++++ .../v1/model/pager_duty_service_key.py | 89 ++++ .../v1/model/pager_duty_service_name.py | 89 ++++ src/datadog_api_client/v1/model/pagination.py | 87 ++++ src/datadog_api_client/v1/model/point.py | 93 ++++- .../v1/model/process_query_definition.py | 92 ++++ .../v1/model/query_sort_order.py | 96 +++++ .../v1/model/query_value_widget_definition.py | 100 +++++ .../query_value_widget_definition_type.py | 96 +++++ .../v1/model/query_value_widget_request.py | 100 +++++ .../v1/model/response_meta_attributes.py | 86 ++++ .../v1/model/scatter_plot_request.py | 95 +++++ .../model/scatter_plot_widget_definition.py | 99 +++++ ...scatter_plot_widget_definition_requests.py | 91 ++++ .../scatter_plot_widget_definition_type.py | 96 +++++ src/datadog_api_client/v1/model/series.py | 95 +++++ .../v1/model/service_check.py | 97 +++++ .../v1/model/service_check_status.py | 100 +++++ .../v1/model/service_checks.py | 93 ++++- .../v1/model/service_level_objective.py | 107 +++++ .../v1/model/service_level_objective_query.py | 91 ++++ .../model/service_level_objective_request.py | 98 +++++ .../v1/model/service_map_widget_definition.py | 97 +++++ .../service_map_widget_definition_type.py | 96 +++++ .../service_summary_widget_definition.py | 107 +++++ .../service_summary_widget_definition_type.py | 96 +++++ .../v1/model/slack_integration_channel.py | 87 ++++ .../slack_integration_channel_display.py | 89 ++++ .../v1/model/slack_integration_channels.py | 93 ++++- .../v1/model/slo_bulk_delete.py | 85 ++++ .../v1/model/slo_bulk_delete_error.py | 93 +++++ .../v1/model/slo_bulk_delete_response.py | 87 ++++ .../v1/model/slo_bulk_delete_response_data.py | 87 ++++ .../v1/model/slo_correction.py | 88 ++++ .../v1/model/slo_correction_category.py | 100 +++++ .../v1/model/slo_correction_create_data.py | 87 ++++ .../v1/model/slo_correction_create_request.py | 86 ++++ ...lo_correction_create_request_attributes.py | 97 +++++ .../v1/model/slo_correction_list_response.py | 87 ++++ .../v1/model/slo_correction_response.py | 86 ++++ .../slo_correction_response_attributes.py | 92 ++++ .../v1/model/slo_correction_type.py | 96 +++++ .../v1/model/slo_correction_update_data.py | 87 ++++ .../v1/model/slo_correction_update_request.py | 86 ++++ ...lo_correction_update_request_attributes.py | 90 ++++ .../v1/model/slo_delete_response.py | 87 ++++ .../model/slo_error_budget_remaining_data.py | 85 ++++ .../v1/model/slo_error_timeframe.py | 100 +++++ .../v1/model/slo_history_metrics.py | 104 +++++ .../v1/model/slo_history_metrics_series.py | 95 +++++ .../slo_history_metrics_series_metadata.py | 91 ++++ ...lo_history_metrics_series_metadata_unit.py | 91 ++++ .../v1/model/slo_history_response.py | 87 ++++ .../v1/model/slo_history_response_data.py | 95 +++++ .../v1/model/slo_history_response_error.py | 86 ++++ .../v1/model/slo_history_sli_data.py | 97 +++++ .../v1/model/slo_list_response.py | 88 ++++ .../v1/model/slo_list_response_metadata.py | 86 ++++ .../model/slo_list_response_metadata_page.py | 87 ++++ .../v1/model/slo_response.py | 87 ++++ .../v1/model/slo_response_data.py | 103 +++++ .../v1/model/slo_threshold.py | 94 +++++ .../v1/model/slo_timeframe.py | 100 +++++ src/datadog_api_client/v1/model/slo_type.py | 100 +++++ .../v1/model/slo_type_numeric.py | 100 +++++ .../v1/model/slo_widget_definition.py | 100 +++++ .../v1/model/slo_widget_definition_type.py | 96 +++++ .../v1/model/synthetics_api_step.py | 92 ++++ .../v1/model/synthetics_api_step_subtype.py | 96 +++++ .../v1/model/synthetics_api_test.py | 99 +++++ .../v1/model/synthetics_api_test_config.py | 89 ++++ .../model/synthetics_api_test_result_data.py | 107 ++++- .../model/synthetics_api_test_result_full.py | 92 ++++ .../synthetics_api_test_result_full_check.py | 89 ++++ .../model/synthetics_api_test_result_short.py | 90 ++++ ...synthetics_api_test_result_short_result.py | 87 ++++ .../v1/model/synthetics_api_test_type.py | 96 +++++ .../v1/model/synthetics_assertion.py | 127 ++++-- ...synthetics_assertion_json_path_operator.py | 96 +++++ .../synthetics_assertion_json_path_target.py | 93 +++++ ...etics_assertion_json_path_target_target.py | 88 ++++ .../v1/model/synthetics_assertion_operator.py | 100 +++++ .../v1/model/synthetics_assertion_target.py | 96 ++++- .../v1/model/synthetics_assertion_type.py | 100 +++++ .../v1/model/synthetics_basic_auth.py | 91 ++++ .../v1/model/synthetics_browser_error.py | 94 +++++ .../v1/model/synthetics_browser_error_type.py | 100 +++++ .../v1/model/synthetics_browser_test.py | 102 +++++ .../model/synthetics_browser_test_config.py | 94 +++++ .../synthetics_browser_test_result_data.py | 96 +++++ .../synthetics_browser_test_result_full.py | 92 ++++ ...nthetics_browser_test_result_full_check.py | 89 ++++ .../synthetics_browser_test_result_short.py | 90 ++++ ...hetics_browser_test_result_short_result.py | 90 ++++ .../v1/model/synthetics_browser_test_type.py | 96 +++++ .../v1/model/synthetics_browser_variable.py | 94 +++++ .../model/synthetics_browser_variable_type.py | 100 +++++ .../v1/model/synthetics_check_type.py | 100 +++++ .../v1/model/synthetics_ci_test.py | 102 +++++ .../v1/model/synthetics_ci_test_body.py | 86 ++++ .../v1/model/synthetics_ci_test_metadata.py | 87 ++++ .../model/synthetics_ci_test_metadata_ci.py | 87 ++++ .../model/synthetics_ci_test_metadata_git.py | 87 ++++ .../v1/model/synthetics_config_variable.py | 94 +++++ .../model/synthetics_config_variable_type.py | 100 +++++ .../v1/model/synthetics_core_web_vitals.py | 88 ++++ .../model/synthetics_delete_tests_payload.py | 86 ++++ .../model/synthetics_delete_tests_response.py | 86 ++++ .../v1/model/synthetics_deleted_test.py | 87 ++++ .../v1/model/synthetics_device.py | 96 +++++ .../v1/model/synthetics_device_id.py | 100 +++++ .../v1/model/synthetics_error_code.py | 100 +++++ ...cs_get_api_test_latest_results_response.py | 87 ++++ ...et_browser_test_latest_results_response.py | 87 ++++ .../v1/model/synthetics_global_variable.py | 100 +++++ ...tics_global_variable_parse_test_options.py | 92 ++++ ...global_variable_parse_test_options_type.py | 100 +++++ .../synthetics_global_variable_parser_type.py | 100 +++++ .../model/synthetics_global_variable_value.py | 87 ++++ ...nthetics_list_global_variables_response.py | 86 ++++ .../model/synthetics_list_tests_response.py | 86 ++++ .../v1/model/synthetics_location.py | 87 ++++ .../v1/model/synthetics_locations.py | 86 ++++ .../v1/model/synthetics_parsing_options.py | 89 ++++ .../v1/model/synthetics_playing_tab.py | 100 +++++ .../v1/model/synthetics_private_location.py | 97 +++++ ...tics_private_location_creation_response.py | 92 +++- ...ion_creation_response_result_encryption.py | 87 ++++ .../synthetics_private_location_secrets.py | 87 ++++ ...private_location_secrets_authentication.py | 90 ++++ ...vate_location_secrets_config_decryption.py | 88 ++++ .../v1/model/synthetics_ssl_certificate.py | 97 +++++ .../synthetics_ssl_certificate_issuer.py | 91 ++++ .../synthetics_ssl_certificate_subject.py | 92 ++++ .../v1/model/synthetics_step.py | 94 ++++- .../v1/model/synthetics_step_detail.py | 106 ++++- .../model/synthetics_step_detail_warning.py | 91 ++++ .../v1/model/synthetics_step_type.py | 100 +++++ .../v1/model/synthetics_test_config.py | 89 ++++ .../v1/model/synthetics_test_details.py | 100 +++++ .../model/synthetics_test_details_sub_type.py | 100 +++++ .../v1/model/synthetics_test_details_type.py | 100 +++++ .../v1/model/synthetics_test_headers.py | 85 ++++ .../model/synthetics_test_monitor_status.py | 100 +++++ .../v1/model/synthetics_test_options.py | 98 +++++ ...synthetics_test_options_monitor_options.py | 86 ++++ .../v1/model/synthetics_test_options_retry.py | 87 ++++ .../v1/model/synthetics_test_pause_status.py | 100 +++++ .../model/synthetics_test_process_status.py | 100 +++++ .../v1/model/synthetics_test_request.py | 105 ++++- .../synthetics_test_request_certificate.py | 87 ++++ ...ynthetics_test_request_certificate_item.py | 88 ++++ .../v1/model/synthetics_timing.py | 94 +++++ .../synthetics_trigger_ci_test_location.py | 87 ++++ .../synthetics_trigger_ci_test_run_result.py | 89 ++++ .../synthetics_trigger_ci_tests_response.py | 88 ++++ ...hetics_update_test_pause_status_payload.py | 86 ++++ .../v1/model/synthetics_variable_parser.py | 90 ++++ .../v1/model/synthetics_warning_type.py | 96 +++++ .../model/table_widget_cell_display_mode.py | 100 +++++ .../v1/model/table_widget_definition.py | 97 +++++ .../v1/model/table_widget_definition_type.py | 96 +++++ .../v1/model/table_widget_has_search_bar.py | 100 +++++ .../v1/model/table_widget_request.py | 104 +++++ .../v1/model/tag_to_hosts.py | 86 ++++ .../v1/model/target_format_type.py | 100 +++++ .../v1/model/timeseries_widget_definition.py | 104 +++++ .../timeseries_widget_definition_type.py | 96 +++++ .../timeseries_widget_expression_alias.py | 90 ++++ .../model/timeseries_widget_legend_column.py | 100 +++++ .../model/timeseries_widget_legend_layout.py | 100 +++++ .../v1/model/timeseries_widget_request.py | 102 +++++ .../v1/model/toplist_widget_definition.py | 96 +++++ .../model/toplist_widget_definition_type.py | 96 +++++ .../v1/model/toplist_widget_request.py | 100 +++++ .../v1/model/tree_map_color_by.py | 96 +++++ .../v1/model/tree_map_group_by.py | 100 +++++ .../v1/model/tree_map_size_by.py | 100 +++++ .../v1/model/tree_map_widget_definition.py | 98 +++++ .../model/tree_map_widget_definition_type.py | 96 +++++ .../v1/model/tree_map_widget_request.py | 86 ++++ .../v1/model/usage_analyzed_logs_hour.py | 87 ++++ .../v1/model/usage_analyzed_logs_response.py | 86 ++++ .../v1/model/usage_attribution_aggregates.py | 93 ++++- .../usage_attribution_aggregates_body.py | 88 ++++ .../v1/model/usage_attribution_body.py | 92 ++++ .../v1/model/usage_attribution_metadata.py | 87 ++++ .../v1/model/usage_attribution_pagination.py | 88 ++++ .../v1/model/usage_attribution_response.py | 87 ++++ .../v1/model/usage_attribution_sort.py | 96 +++++ .../usage_attribution_supported_metrics.py | 100 +++++ .../v1/model/usage_attribution_tag_names.py | 85 ++++ .../v1/model/usage_attribution_values.py | 119 ++++++ .../v1/model/usage_audit_logs_hour.py | 87 ++++ .../v1/model/usage_audit_logs_response.py | 86 ++++ .../v1/model/usage_billable_summary_body.py | 92 ++++ .../v1/model/usage_billable_summary_hour.py | 93 +++++ .../v1/model/usage_billable_summary_keys.py | 117 ++++++ .../model/usage_billable_summary_response.py | 86 ++++ ..._cloud_security_posture_management_hour.py | 88 ++++ ...ud_security_posture_management_response.py | 86 ++++ .../model/usage_custom_reports_attributes.py | 90 ++++ .../v1/model/usage_custom_reports_data.py | 88 ++++ .../v1/model/usage_custom_reports_meta.py | 86 ++++ .../v1/model/usage_custom_reports_page.py | 86 ++++ .../v1/model/usage_custom_reports_response.py | 87 ++++ .../v1/model/usage_cws_hour.py | 88 ++++ .../v1/model/usage_cws_response.py | 86 ++++ .../v1/model/usage_fargate_hour.py | 87 ++++ .../v1/model/usage_fargate_response.py | 86 ++++ .../v1/model/usage_host_hour.py | 99 +++++ .../v1/model/usage_hosts_response.py | 86 ++++ .../model/usage_incident_management_hour.py | 87 ++++ .../usage_incident_management_response.py | 86 ++++ .../v1/model/usage_indexed_spans_hour.py | 87 ++++ .../v1/model/usage_indexed_spans_response.py | 86 ++++ .../v1/model/usage_ingested_spans_hour.py | 87 ++++ .../v1/model/usage_ingested_spans_response.py | 86 ++++ .../v1/model/usage_io_t_hour.py | 87 ++++ .../v1/model/usage_io_t_response.py | 86 ++++ .../v1/model/usage_lambda_hour.py | 88 ++++ .../v1/model/usage_lambda_response.py | 86 ++++ .../v1/model/usage_logs_by_index_hour.py | 90 ++++ .../v1/model/usage_logs_by_index_response.py | 86 ++++ .../v1/model/usage_logs_by_retention_hour.py | 89 ++++ .../model/usage_logs_by_retention_response.py | 86 ++++ .../v1/model/usage_logs_hour.py | 93 +++++ .../v1/model/usage_logs_response.py | 86 ++++ .../v1/model/usage_metric_category.py | 100 +++++ .../v1/model/usage_network_flows_hour.py | 87 ++++ .../v1/model/usage_network_flows_response.py | 86 ++++ .../v1/model/usage_network_hosts_hour.py | 87 ++++ .../v1/model/usage_network_hosts_response.py | 86 ++++ .../v1/model/usage_profiling_hour.py | 88 ++++ .../v1/model/usage_profiling_response.py | 86 ++++ .../v1/model/usage_reports_type.py | 96 +++++ .../v1/model/usage_rum_sessions_hour.py | 89 ++++ .../v1/model/usage_rum_sessions_response.py | 86 ++++ .../v1/model/usage_snmp_hour.py | 87 ++++ .../v1/model/usage_snmp_response.py | 86 ++++ src/datadog_api_client/v1/model/usage_sort.py | 96 +++++ .../v1/model/usage_sort_direction.py | 96 +++++ ...age_specified_custom_reports_attributes.py | 91 ++++ .../usage_specified_custom_reports_data.py | 88 ++++ .../usage_specified_custom_reports_meta.py | 86 ++++ .../usage_specified_custom_reports_page.py | 86 ++++ ...usage_specified_custom_reports_response.py | 87 ++++ .../v1/model/usage_summary_date.py | 128 ++++++ .../v1/model/usage_summary_date_org.py | 129 ++++++ .../v1/model/usage_summary_response.py | 137 ++++++ .../v1/model/usage_synthetics_api_hour.py | 87 ++++ .../v1/model/usage_synthetics_api_response.py | 86 ++++ .../v1/model/usage_synthetics_browser_hour.py | 87 ++++ .../usage_synthetics_browser_response.py | 86 ++++ .../v1/model/usage_synthetics_hour.py | 87 ++++ .../v1/model/usage_synthetics_response.py | 86 ++++ .../v1/model/usage_timeseries_hour.py | 89 ++++ .../v1/model/usage_timeseries_response.py | 86 ++++ .../v1/model/usage_top_avg_metrics_hour.py | 89 ++++ .../model/usage_top_avg_metrics_metadata.py | 88 ++++ .../model/usage_top_avg_metrics_response.py | 87 ++++ src/datadog_api_client/v1/model/user.py | 95 +++++ .../v1/model/user_disable_response.py | 86 ++++ .../v1/model/user_list_response.py | 86 ++++ .../v1/model/user_response.py | 86 ++++ src/datadog_api_client/v1/model/widget.py | 91 ++++ .../v1/model/widget_aggregator.py | 100 +++++ .../v1/model/widget_axis.py | 90 ++++ .../v1/model/widget_change_type.py | 100 +++++ .../v1/model/widget_color_preference.py | 100 +++++ .../v1/model/widget_comparator.py | 100 +++++ .../v1/model/widget_compare_to.py | 100 +++++ .../v1/model/widget_conditional_format.py | 99 +++++ .../v1/model/widget_custom_link.py | 89 ++++ .../v1/model/widget_definition.py | 217 ++++++++-- .../v1/model/widget_display_type.py | 100 +++++ .../v1/model/widget_event.py | 90 ++++ .../v1/model/widget_event_size.py | 100 +++++ .../v1/model/widget_field_sort.py | 91 ++++ .../v1/model/widget_formula.py | 93 +++++ .../v1/model/widget_formula_limit.py | 87 ++++ .../v1/model/widget_grouping.py | 100 +++++ .../v1/model/widget_horizontal_align.py | 100 +++++ .../v1/model/widget_image_sizing.py | 100 +++++ .../v1/model/widget_layout.py | 96 +++++ .../v1/model/widget_layout_type.py | 96 +++++ .../v1/model/widget_line_type.py | 100 +++++ .../v1/model/widget_line_width.py | 100 +++++ .../v1/model/widget_live_span.py | 100 +++++ .../v1/model/widget_margin.py | 100 +++++ .../v1/model/widget_marker.py | 92 ++++ .../v1/model/widget_message_display.py | 100 +++++ .../widget_monitor_summary_display_format.py | 100 +++++ .../v1/model/widget_monitor_summary_sort.py | 100 +++++ .../v1/model/widget_node_type.py | 100 +++++ .../v1/model/widget_order_by.py | 100 +++++ .../v1/model/widget_palette.py | 100 +++++ .../v1/model/widget_request_style.py | 88 ++++ .../widget_service_summary_display_format.py | 100 +++++ .../v1/model/widget_size_format.py | 100 +++++ .../v1/model/widget_sort.py | 100 +++++ .../v1/model/widget_style.py | 86 ++++ .../v1/model/widget_summary_type.py | 100 +++++ .../v1/model/widget_text_align.py | 100 +++++ .../v1/model/widget_tick_edge.py | 100 +++++ .../v1/model/widget_time.py | 86 ++++ .../v1/model/widget_time_windows.py | 100 +++++ .../v1/model/widget_vertical_align.py | 100 +++++ .../v1/model/widget_view_mode.py | 100 +++++ .../v1/model/widget_viz_type.py | 100 +++++ src/datadog_api_client/v1/model_utils.py | 393 +++++++++++------- src/datadog_api_client/v1/openapi.yaml | 3 +- src/datadog_api_client/v1/rest.py | 8 +- src/datadog_api_client/v2/api_client.py | 6 +- .../v2/model/api_error_response.py | 89 ++++ .../v2/model/api_key_create_attributes.py | 89 ++++ .../v2/model/api_key_create_data.py | 91 ++++ .../v2/model/api_key_create_request.py | 89 ++++ .../v2/model/api_key_relationships.py | 87 ++++ .../v2/model/api_key_response.py | 87 ++++ .../model/api_key_response_included_item.py | 127 ++++-- .../v2/model/api_key_update_attributes.py | 89 ++++ .../v2/model/api_key_update_data.py | 93 +++++ .../v2/model/api_key_update_request.py | 89 ++++ .../v2/model/api_keys_response.py | 87 ++++ .../v2/model/api_keys_sort.py | 96 +++++ .../v2/model/api_keys_type.py | 96 +++++ .../application_key_create_attributes.py | 89 ++++ .../v2/model/application_key_create_data.py | 91 ++++ .../model/application_key_create_request.py | 89 ++++ .../v2/model/application_key_relationships.py | 86 ++++ .../v2/model/application_key_response.py | 87 ++++ .../application_key_response_included_item.py | 127 ++++-- .../application_key_update_attributes.py | 89 ++++ .../v2/model/application_key_update_data.py | 93 +++++ .../model/application_key_update_request.py | 89 ++++ .../v2/model/application_keys_sort.py | 96 +++++ .../v2/model/application_keys_type.py | 96 +++++ src/datadog_api_client/v2/model/creator.py | 88 ++++ .../model/dashboard_list_add_items_request.py | 86 ++++ .../dashboard_list_add_items_response.py | 86 ++++ .../dashboard_list_delete_items_request.py | 86 ++++ .../dashboard_list_delete_items_response.py | 86 ++++ .../v2/model/dashboard_list_item.py | 111 +++++ .../v2/model/dashboard_list_item_request.py | 91 ++++ .../v2/model/dashboard_list_item_response.py | 98 ++++- .../v2/model/dashboard_list_items.py | 92 ++++ .../dashboard_list_update_items_request.py | 86 ++++ .../dashboard_list_update_items_response.py | 86 ++++ .../v2/model/dashboard_type.py | 100 +++++ .../v2/model/full_api_key.py | 89 ++++ .../v2/model/full_api_key_attributes.py | 95 +++++ .../v2/model/full_application_key.py | 89 ++++ .../model/full_application_key_attributes.py | 93 +++++ .../v2/model/incident_create_attributes.py | 94 +++++ .../v2/model/incident_create_data.py | 92 ++++ .../v2/model/incident_create_relationships.py | 89 ++++ .../v2/model/incident_create_request.py | 89 ++++ .../v2/model/incident_field_attributes.py | 133 ++++-- ...ncident_field_attributes_multiple_value.py | 87 ++++ .../incident_field_attributes_single_value.py | 87 ++++ ...dent_field_attributes_single_value_type.py | 96 +++++ .../incident_field_attributes_value_type.py | 96 +++++ .../incident_integration_metadata_type.py | 96 +++++ .../v2/model/incident_postmortem_type.py | 96 +++++ .../v2/model/incident_related_object.py | 96 +++++ .../v2/model/incident_response.py | 92 ++++ .../v2/model/incident_response_attributes.py | 114 +++++ .../v2/model/incident_response_data.py | 93 +++++ .../model/incident_response_included_item.py | 127 ++++-- .../model/incident_response_relationships.py | 90 ++++ .../incident_service_create_attributes.py | 89 ++++ .../v2/model/incident_service_create_data.py | 91 ++++ .../model/incident_service_create_request.py | 89 ++++ .../model/incident_service_included_items.py | 127 ++++-- .../model/incident_service_relationships.py | 87 ++++ .../v2/model/incident_service_response.py | 92 ++++ .../incident_service_response_attributes.py | 91 ++++ .../model/incident_service_response_data.py | 93 +++++ .../v2/model/incident_service_type.py | 96 +++++ .../incident_service_update_attributes.py | 89 ++++ .../v2/model/incident_service_update_data.py | 92 ++++ .../model/incident_service_update_request.py | 89 ++++ .../v2/model/incident_services_response.py | 93 +++++ .../model/incident_services_response_meta.py | 86 ++++ ...ident_services_response_meta_pagination.py | 88 ++++ .../model/incident_team_create_attributes.py | 89 ++++ .../v2/model/incident_team_create_data.py | 91 ++++ .../v2/model/incident_team_create_request.py | 89 ++++ .../v2/model/incident_team_included_items.py | 127 ++++-- .../v2/model/incident_team_relationships.py | 87 ++++ .../v2/model/incident_team_response.py | 92 ++++ .../incident_team_response_attributes.py | 91 ++++ .../v2/model/incident_team_response_data.py | 89 ++++ .../v2/model/incident_team_type.py | 96 +++++ .../model/incident_team_update_attributes.py | 89 ++++ .../v2/model/incident_team_update_data.py | 92 ++++ .../v2/model/incident_team_update_request.py | 89 ++++ .../v2/model/incident_teams_response.py | 93 +++++ ...ncident_timeline_cell_create_attributes.py | 126 ++++-- ...ent_timeline_cell_markdown_content_type.py | 96 +++++ ...imeline_cell_markdown_create_attributes.py | 92 ++++ ...cell_markdown_create_attributes_content.py | 86 ++++ .../v2/model/incident_type.py | 96 +++++ .../v2/model/incident_update_attributes.py | 94 +++++ .../v2/model/incident_update_data.py | 93 +++++ .../v2/model/incident_update_relationships.py | 90 ++++ .../v2/model/incident_update_request.py | 89 ++++ .../v2/model/incidents_response.py | 93 +++++ .../model/list_application_keys_response.py | 87 ++++ src/datadog_api_client/v2/model/log.py | 88 ++++ .../v2/model/log_attributes.py | 92 ++++ src/datadog_api_client/v2/model/log_type.py | 96 +++++ .../v2/model/logs_aggregate_bucket.py | 87 ++++ .../v2/model/logs_aggregate_bucket_value.py | 123 ++++-- .../logs_aggregate_bucket_value_timeseries.py | 93 ++++- ...aggregate_bucket_value_timeseries_point.py | 87 ++++ .../v2/model/logs_aggregate_request.py | 90 ++++ .../v2/model/logs_aggregate_request_page.py | 86 ++++ .../v2/model/logs_aggregate_response.py | 87 ++++ .../v2/model/logs_aggregate_response_data.py | 86 ++++ .../model/logs_aggregate_response_status.py | 100 +++++ .../v2/model/logs_aggregate_sort.py | 89 ++++ .../v2/model/logs_aggregate_sort_type.py | 96 +++++ .../v2/model/logs_aggregation_function.py | 100 +++++ .../v2/model/logs_archive.py | 86 ++++ .../v2/model/logs_archive_attributes.py | 96 +++++ .../v2/model/logs_archive_create_request.py | 86 ++++ .../logs_archive_create_request_attributes.py | 95 +++++ .../logs_archive_create_request_definition.py | 91 ++++ ...logs_archive_create_request_destination.py | 130 ++++-- .../v2/model/logs_archive_definition.py | 100 ++++- .../v2/model/logs_archive_destination.py | 130 ++++-- .../model/logs_archive_destination_azure.py | 97 +++++ .../logs_archive_destination_azure_type.py | 96 +++++ .../v2/model/logs_archive_destination_gcs.py | 94 +++++ .../logs_archive_destination_gcs_type.py | 96 +++++ .../v2/model/logs_archive_destination_s3.py | 94 +++++ .../model/logs_archive_destination_s3_type.py | 96 +++++ .../model/logs_archive_integration_azure.py | 91 ++++ .../v2/model/logs_archive_integration_gcs.py | 91 ++++ .../v2/model/logs_archive_integration_s3.py | 91 ++++ .../v2/model/logs_archive_order.py | 86 ++++ .../v2/model/logs_archive_order_attributes.py | 89 ++++ .../v2/model/logs_archive_order_definition.py | 91 ++++ .../logs_archive_order_definition_type.py | 96 +++++ .../v2/model/logs_archive_state.py | 100 +++++ .../v2/model/logs_archives.py | 86 ++++ .../v2/model/logs_compute.py | 92 ++++ .../v2/model/logs_compute_type.py | 96 +++++ .../v2/model/logs_group_by.py | 94 +++++ .../v2/model/logs_group_by_histogram.py | 93 +++++ .../v2/model/logs_group_by_missing.py | 103 ++++- .../v2/model/logs_group_by_total.py | 103 ++++- .../v2/model/logs_list_request.py | 89 ++++ .../v2/model/logs_list_request_page.py | 87 ++++ .../v2/model/logs_list_response.py | 88 ++++ .../v2/model/logs_list_response_links.py | 86 ++++ .../v2/model/logs_metric_compute.py | 90 ++++ .../logs_metric_compute_aggregation_type.py | 100 +++++ .../v2/model/logs_metric_create_attributes.py | 91 ++++ .../v2/model/logs_metric_create_data.py | 93 +++++ .../v2/model/logs_metric_create_request.py | 89 ++++ .../v2/model/logs_metric_filter.py | 86 ++++ .../v2/model/logs_metric_group_by.py | 90 ++++ .../v2/model/logs_metric_response.py | 86 ++++ .../model/logs_metric_response_attributes.py | 88 ++++ .../v2/model/logs_metric_response_compute.py | 87 ++++ ...etric_response_compute_aggregation_type.py | 100 +++++ .../v2/model/logs_metric_response_data.py | 88 ++++ .../v2/model/logs_metric_response_filter.py | 86 ++++ .../v2/model/logs_metric_response_group_by.py | 87 ++++ .../v2/model/logs_metric_type.py | 96 +++++ .../v2/model/logs_metric_update_attributes.py | 87 ++++ .../v2/model/logs_metric_update_data.py | 91 ++++ .../v2/model/logs_metric_update_request.py | 89 ++++ .../v2/model/logs_metrics_response.py | 86 ++++ .../v2/model/logs_query_filter.py | 89 ++++ .../v2/model/logs_query_options.py | 87 ++++ .../v2/model/logs_response_metadata.py | 90 ++++ .../v2/model/logs_response_metadata_page.py | 86 ++++ src/datadog_api_client/v2/model/logs_sort.py | 100 +++++ .../v2/model/logs_sort_order.py | 100 +++++ .../v2/model/logs_warning.py | 88 ++++ src/datadog_api_client/v2/model/metric.py | 87 ++++ .../v2/model/metric_all_tags.py | 88 ++++ .../v2/model/metric_all_tags_attributes.py | 86 ++++ .../v2/model/metric_all_tags_response.py | 86 ++++ .../v2/model/metric_distinct_volume.py | 88 ++++ .../metric_distinct_volume_attributes.py | 86 ++++ .../v2/model/metric_distinct_volume_type.py | 96 +++++ .../model/metric_ingested_indexed_volume.py | 88 ++++ ...tric_ingested_indexed_volume_attributes.py | 87 ++++ .../metric_ingested_indexed_volume_type.py | 96 +++++ .../v2/model/metric_tag_configuration.py | 88 ++++ .../metric_tag_configuration_attributes.py | 90 ++++ ...ric_tag_configuration_create_attributes.py | 93 +++++ .../metric_tag_configuration_create_data.py | 92 ++++ ...metric_tag_configuration_create_request.py | 89 ++++ .../metric_tag_configuration_metric_types.py | 96 +++++ .../metric_tag_configuration_response.py | 86 ++++ .../v2/model/metric_tag_configuration_type.py | 96 +++++ ...ric_tag_configuration_update_attributes.py | 87 ++++ .../metric_tag_configuration_update_data.py | 92 ++++ ...metric_tag_configuration_update_request.py | 89 ++++ .../v2/model/metric_type.py | 96 +++++ .../v2/model/metric_volumes.py | 126 ++++-- .../v2/model/metric_volumes_response.py | 86 ++++ .../metrics_and_metric_tag_configurations.py | 126 ++++-- ..._and_metric_tag_configurations_response.py | 86 ++++ .../v2/model/organization.py | 91 ++++ .../v2/model/organization_attributes.py | 93 +++++ .../v2/model/organizations_type.py | 96 +++++ src/datadog_api_client/v2/model/pagination.py | 87 ++++ .../v2/model/partial_api_key.py | 89 ++++ .../v2/model/partial_api_key_attributes.py | 93 +++++ .../v2/model/partial_application_key.py | 89 ++++ .../partial_application_key_attributes.py | 91 ++++ src/datadog_api_client/v2/model/permission.py | 91 ++++ .../v2/model/permission_attributes.py | 92 ++++ .../v2/model/permissions_response.py | 86 ++++ .../v2/model/permissions_type.py | 96 +++++ .../v2/model/process_summaries_meta.py | 86 ++++ .../v2/model/process_summaries_meta_page.py | 87 ++++ .../v2/model/process_summaries_response.py | 87 ++++ .../v2/model/process_summary.py | 88 ++++ .../v2/model/process_summary_attributes.py | 93 +++++ .../v2/model/process_summary_type.py | 96 +++++ .../v2/model/query_sort_order.py | 96 +++++ ...p_to_incident_integration_metadata_data.py | 91 ++++ ...nship_to_incident_integration_metadatas.py | 89 ++++ .../relationship_to_incident_postmortem.py | 89 ++++ ...elationship_to_incident_postmortem_data.py | 91 ++++ .../v2/model/relationship_to_organization.py | 89 ++++ .../relationship_to_organization_data.py | 91 ++++ .../v2/model/relationship_to_organizations.py | 89 ++++ .../v2/model/relationship_to_permission.py | 86 ++++ .../model/relationship_to_permission_data.py | 87 ++++ .../v2/model/relationship_to_permissions.py | 86 ++++ .../v2/model/relationship_to_role.py | 86 ++++ .../v2/model/relationship_to_role_data.py | 87 ++++ .../v2/model/relationship_to_roles.py | 86 ++++ .../v2/model/relationship_to_user.py | 89 ++++ .../v2/model/relationship_to_user_data.py | 91 ++++ .../v2/model/relationship_to_users.py | 89 ++++ .../v2/model/response_meta_attributes.py | 86 ++++ src/datadog_api_client/v2/model/role.py | 92 ++++ .../v2/model/role_attributes.py | 93 +++++ .../v2/model/role_create_attributes.py | 94 +++++ .../v2/model/role_create_data.py | 91 ++++ .../v2/model/role_create_request.py | 89 ++++ .../v2/model/role_create_response.py | 86 ++++ .../v2/model/role_create_response_data.py | 92 ++++ .../v2/model/role_relationships.py | 87 ++++ .../v2/model/role_response.py | 86 ++++ .../v2/model/role_response_relationships.py | 86 ++++ .../v2/model/role_update_attributes.py | 91 ++++ .../v2/model/role_update_data.py | 93 +++++ .../v2/model/role_update_request.py | 89 ++++ .../v2/model/role_update_response.py | 86 ++++ .../v2/model/role_update_response_data.py | 92 ++++ .../v2/model/roles_response.py | 87 ++++ src/datadog_api_client/v2/model/roles_sort.py | 96 +++++ src/datadog_api_client/v2/model/roles_type.py | 96 +++++ .../v2/model/security_filter.py | 88 ++++ .../v2/model/security_filter_attributes.py | 92 ++++ .../security_filter_create_attributes.py | 99 +++++ .../v2/model/security_filter_create_data.py | 91 ++++ .../model/security_filter_create_request.py | 89 ++++ .../model/security_filter_exclusion_filter.py | 91 ++++ ...curity_filter_exclusion_filter_response.py | 87 ++++ .../security_filter_filtered_data_type.py | 96 +++++ .../v2/model/security_filter_meta.py | 86 ++++ .../v2/model/security_filter_response.py | 87 ++++ .../v2/model/security_filter_type.py | 96 +++++ .../security_filter_update_attributes.py | 91 ++++ .../v2/model/security_filter_update_data.py | 91 ++++ .../model/security_filter_update_request.py | 89 ++++ .../v2/model/security_filters_response.py | 87 ++++ .../v2/model/security_monitoring_filter.py | 87 ++++ .../security_monitoring_filter_action.py | 100 +++++ ...security_monitoring_list_rules_response.py | 87 ++++ .../v2/model/security_monitoring_rule_case.py | 89 ++++ .../security_monitoring_rule_case_create.py | 92 ++++ ...security_monitoring_rule_create_payload.py | 102 +++++ ...curity_monitoring_rule_detection_method.py | 100 +++++ ...urity_monitoring_rule_evaluation_window.py | 100 +++++ .../security_monitoring_rule_keep_alive.py | 100 +++++ ...ity_monitoring_rule_max_signal_duration.py | 100 +++++ ...urity_monitoring_rule_new_value_options.py | 87 ++++ ...ing_rule_new_value_options_forget_after.py | 100 +++++ ...ule_new_value_options_learning_duration.py | 100 +++++ .../model/security_monitoring_rule_options.py | 90 ++++ .../model/security_monitoring_rule_query.py | 92 ++++ ...urity_monitoring_rule_query_aggregation.py | 100 +++++ .../security_monitoring_rule_query_create.py | 95 +++++ .../security_monitoring_rule_response.py | 101 +++++ .../security_monitoring_rule_severity.py | 100 +++++ ...security_monitoring_rule_update_payload.py | 95 +++++ .../security_monitoring_runtime_agent_rule.py | 87 ++++ .../v2/model/security_monitoring_signal.py | 88 ++++ .../security_monitoring_signal_attributes.py | 89 ++++ ...security_monitoring_signal_list_request.py | 88 ++++ ...y_monitoring_signal_list_request_filter.py | 88 ++++ ...ity_monitoring_signal_list_request_page.py | 87 ++++ .../model/security_monitoring_signal_type.py | 96 +++++ ...curity_monitoring_signals_list_response.py | 88 ++++ ..._monitoring_signals_list_response_links.py | 86 ++++ ...y_monitoring_signals_list_response_meta.py | 86 ++++ ...itoring_signals_list_response_meta_page.py | 86 ++++ .../model/security_monitoring_signals_sort.py | 100 +++++ src/datadog_api_client/v2/model/user.py | 89 ++++ .../v2/model/user_attributes.py | 95 +++++ .../v2/model/user_create_attributes.py | 91 ++++ .../v2/model/user_create_data.py | 92 ++++ .../v2/model/user_create_request.py | 89 ++++ .../v2/model/user_invitation_data.py | 91 ++++ .../model/user_invitation_data_attributes.py | 89 ++++ .../v2/model/user_invitation_relationships.py | 89 ++++ .../v2/model/user_invitation_response.py | 86 ++++ .../v2/model/user_invitation_response_data.py | 88 ++++ .../v2/model/user_invitations_request.py | 89 ++++ .../v2/model/user_invitations_response.py | 86 ++++ .../v2/model/user_invitations_type.py | 96 +++++ .../v2/model/user_relationships.py | 86 ++++ .../v2/model/user_response.py | 87 ++++ .../v2/model/user_response_included_item.py | 127 ++++-- .../v2/model/user_response_relationships.py | 89 ++++ .../v2/model/user_update_attributes.py | 88 ++++ .../v2/model/user_update_data.py | 93 +++++ .../v2/model/user_update_request.py | 89 ++++ .../v2/model/users_response.py | 88 ++++ src/datadog_api_client/v2/model/users_type.py | 96 +++++ src/datadog_api_client/v2/model_utils.py | 393 +++++++++++------- src/datadog_api_client/v2/rest.py | 8 +- tests/v1/features/synthetics.feature | 2 +- 976 files changed, 86535 insertions(+), 1677 deletions(-) diff --git a/.apigentools-info b/.apigentools-info index 89040f0428..305c412296 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.4.1.dev11", - "regenerated": "2021-07-23 09:17:27.076054", - "spec_repo_commit": "0b10309" + "regenerated": "2021-07-30 12:49:13.627605", + "spec_repo_commit": "a54f925" }, "v2": { "apigentools_version": "1.4.1.dev11", - "regenerated": "2021-07-23 09:17:49.537097", - "spec_repo_commit": "0b10309" + "regenerated": "2021-07-30 12:49:44.726331", + "spec_repo_commit": "a54f925" } } } \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index a1b151d647..e2a8821e2d 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -341,7 +341,6 @@ datadog_api_client/v2/model/users_response.py datadog_api_client/v2/model/users_type.py datadog_api_client/v2/model_utils.py datadog_api_client/v2/models/__init__.py -datadog_api_client/v2/models/__init__.py datadog_api_client/v2/rest.py docs/APIErrorResponse.md docs/APIKeyCreateAttributes.md diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index c30f0ec2be..862529f8ca 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -5.1.0-SNAPSHOT \ No newline at end of file +5.2.1-SNAPSHOT \ No newline at end of file diff --git a/docs/v1/AWSIntegrationApi.md b/docs/v1/AWSIntegrationApi.md index aa5762a000..30562fe6a4 100644 --- a/docs/v1/AWSIntegrationApi.md +++ b/docs/v1/AWSIntegrationApi.md @@ -95,7 +95,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **create_aws_tag_filter** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} create_aws_tag_filter(body) +> dict create_aws_tag_filter(body) Set an AWS tag filter. @@ -141,7 +141,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -238,7 +238,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **delete_aws_account** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} delete_aws_account(body) +> dict delete_aws_account(body) Delete a Datadog-AWS integration matching the specified `account_id` and `role_name parameters`. @@ -284,7 +284,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -307,7 +307,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **delete_aws_tag_filter** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} delete_aws_tag_filter(body) +> dict delete_aws_tag_filter(body) Delete a tag filtering entry. @@ -352,7 +352,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -566,7 +566,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **update_aws_account** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} update_aws_account(body) +> dict update_aws_account(body) Update a Datadog-Amazon Web Services integration. @@ -634,7 +634,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/AWSLogsIntegrationApi.md b/docs/v1/AWSLogsIntegrationApi.md index 2bfe4d77dd..eab8de1fd8 100644 --- a/docs/v1/AWSLogsIntegrationApi.md +++ b/docs/v1/AWSLogsIntegrationApi.md @@ -164,7 +164,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **create_aws_lambda_arn** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} create_aws_lambda_arn(body) +> dict create_aws_lambda_arn(body) Attach the Lambda ARN of the Lambda created for the Datadog-AWS log collection to your AWS account ID to enable log collection. @@ -209,7 +209,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -231,7 +231,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **delete_aws_lambda_arn** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} delete_aws_lambda_arn(body) +> dict delete_aws_lambda_arn(body) Delete a Datadog-AWS logs configuration by removing the specific Lambda ARN associated with a given AWS account. @@ -276,7 +276,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -298,7 +298,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **enable_aws_log_services** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} enable_aws_log_services(body) +> dict enable_aws_log_services(body) Enable automatic log collection for a list of services. This should be run after running `CreateAWSLambdaARN` to save the configuration. @@ -343,7 +343,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/AzureIntegrationApi.md b/docs/v1/AzureIntegrationApi.md index d159f051d1..a1026b30f2 100644 --- a/docs/v1/AzureIntegrationApi.md +++ b/docs/v1/AzureIntegrationApi.md @@ -12,7 +12,7 @@ Method | HTTP request | Description # **create_azure_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} create_azure_integration(body) +> dict create_azure_integration(body) Create a Datadog-Azure integration. @@ -68,7 +68,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -90,7 +90,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **delete_azure_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} delete_azure_integration(body) +> dict delete_azure_integration(body) Delete a given Datadog-Azure integration from your Datadog account. @@ -140,7 +140,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -222,7 +222,7 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **update_azure_host_filters** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} update_azure_host_filters(body) +> dict update_azure_host_filters(body) Update the defined list of host filters for a given Datadog-Azure integration. @@ -272,7 +272,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -294,7 +294,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **update_azure_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} update_azure_integration(body) +> dict update_azure_integration(body) Update a Datadog-Azure integration. Requires an existing `tenant_name` and `client_id`. Any other fields supplied will overwrite existing values. To overwrite `tenant_name` or `client_id`, @@ -346,7 +346,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/DashboardListsApi.md b/docs/v1/DashboardListsApi.md index db6a5a987c..b118d999bb 100644 --- a/docs/v1/DashboardListsApi.md +++ b/docs/v1/DashboardListsApi.md @@ -35,18 +35,7 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = dashboard_lists_api.DashboardListsApi(api_client) body = DashboardList( - author=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), - created=dateutil_parser('1970-01-01T00:00:00.00Z'), - dashboard_count=1, - id=1, - is_favorite=True, - modified=dateutil_parser('1970-01-01T00:00:00.00Z'), name="My Dashboard", - type="manual_dashboard_list", ) # DashboardList | Create a dashboard list request body. # example passing only required values which don't have defaults set @@ -300,18 +289,7 @@ with ApiClient(configuration) as api_client: api_instance = dashboard_lists_api.DashboardListsApi(api_client) list_id = 1 # int | ID of the dashboard list to update. body = DashboardList( - author=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), - created=dateutil_parser('1970-01-01T00:00:00.00Z'), - dashboard_count=1, - id=1, - is_favorite=True, - modified=dateutil_parser('1970-01-01T00:00:00.00Z'), name="My Dashboard", - type="manual_dashboard_list", ) # DashboardList | Update a dashboard list request body. # example passing only required values which don't have defaults set diff --git a/docs/v1/DashboardsApi.md b/docs/v1/DashboardsApi.md index ae4c0ed308..c34f115420 100644 --- a/docs/v1/DashboardsApi.md +++ b/docs/v1/DashboardsApi.md @@ -38,13 +38,9 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = dashboards_api.DashboardsApi(api_client) body = Dashboard( - author_handle="test@datadoghq.com", - created_at=dateutil_parser('1970-01-01T00:00:00.00Z'), description="description_example", - id="123-abc-456", is_read_only=False, layout_type=DashboardLayoutType("ordered"), - modified_at=dateutil_parser('1970-01-01T00:00:00.00Z'), notify_list=[ "notify_list_example", ], @@ -71,7 +67,6 @@ with ApiClient(configuration) as api_client: ), ], title="", - url="/dashboard/123-abc-456/example-dashboard-title", widgets=[ Widget( definition=WidgetDefinition(), @@ -488,13 +483,9 @@ with ApiClient(configuration) as api_client: api_instance = dashboards_api.DashboardsApi(api_client) dashboard_id = "dashboard_id_example" # str | The ID of the dashboard. body = Dashboard( - author_handle="test@datadoghq.com", - created_at=dateutil_parser('1970-01-01T00:00:00.00Z'), description="description_example", - id="123-abc-456", is_read_only=False, layout_type=DashboardLayoutType("ordered"), - modified_at=dateutil_parser('1970-01-01T00:00:00.00Z'), notify_list=[ "notify_list_example", ], @@ -521,7 +512,6 @@ with ApiClient(configuration) as api_client: ), ], title="", - url="/dashboard/123-abc-456/example-dashboard-title", widgets=[ Widget( definition=WidgetDefinition(), diff --git a/docs/v1/DowntimesApi.md b/docs/v1/DowntimesApi.md index fbb8d3812c..70445e69d3 100644 --- a/docs/v1/DowntimesApi.md +++ b/docs/v1/DowntimesApi.md @@ -167,38 +167,8 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = downtimes_api.DowntimesApi(api_client) body = Downtime( - active=True, - active_child=DowntimeChild( - active=True, - canceled=1412799983, - creator_id=123456, - disabled=False, - downtime_type=2, - end=1412793983, - id=1626, - message="Message on the downtime", - monitor_id=123456, - monitor_tags=["*"], - parent_id=123, - recurrence=DowntimeRecurrence( - period=1, - rrule="FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1", - type="weeks", - until_date=1447786293, - until_occurrences=2, - week_days=["Mon","Tue"], - ), - scope=["env:staging"], - start=1412792983, - timezone="America/New_York", - updater_id=123456, - ), - canceled=1412799983, - creator_id=123456, disabled=False, - downtime_type=2, end=1412793983, - id=1625, message="Message on the downtime", monitor_id=123456, monitor_tags=["*"], @@ -214,7 +184,6 @@ with ApiClient(configuration) as api_client: scope=["env:staging"], start=1412792983, timezone="America/New_York", - updater_id=123456, ) # Downtime | Schedule a downtime request body. # example passing only required values which don't have defaults set @@ -473,38 +442,8 @@ with ApiClient(configuration) as api_client: api_instance = downtimes_api.DowntimesApi(api_client) downtime_id = 123456 # int | ID of the downtime to update. body = Downtime( - active=True, - active_child=DowntimeChild( - active=True, - canceled=1412799983, - creator_id=123456, - disabled=False, - downtime_type=2, - end=1412793983, - id=1626, - message="Message on the downtime", - monitor_id=123456, - monitor_tags=["*"], - parent_id=123, - recurrence=DowntimeRecurrence( - period=1, - rrule="FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1", - type="weeks", - until_date=1447786293, - until_occurrences=2, - week_days=["Mon","Tue"], - ), - scope=["env:staging"], - start=1412792983, - timezone="America/New_York", - updater_id=123456, - ), - canceled=1412799983, - creator_id=123456, disabled=False, - downtime_type=2, end=1412793983, - id=1625, message="Message on the downtime", monitor_id=123456, monitor_tags=["*"], @@ -520,7 +459,6 @@ with ApiClient(configuration) as api_client: scope=["env:staging"], start=1412792983, timezone="America/New_York", - updater_id=123456, ) # Downtime | Update a downtime request body. # example passing only required values which don't have defaults set diff --git a/docs/v1/EventsApi.md b/docs/v1/EventsApi.md index 16c621b3d8..800a2ea98f 100644 --- a/docs/v1/EventsApi.md +++ b/docs/v1/EventsApi.md @@ -38,15 +38,12 @@ with ApiClient(configuration) as api_client: date_happened=1, device_name="device_name_example", host="host_example", - id=1, - payload="{}", priority=EventPriority("normal"), related_event_id=1, source_type_name="source_type_name_example", tags=["environment:test"], text="Oh boy!", title="Did you hear the news today?", - url="url_example", ) # EventCreateRequest | Event request object # example passing only required values which don't have defaults set diff --git a/docs/v1/GCPIntegrationApi.md b/docs/v1/GCPIntegrationApi.md index cf191f5777..e52c989fc9 100644 --- a/docs/v1/GCPIntegrationApi.md +++ b/docs/v1/GCPIntegrationApi.md @@ -11,7 +11,7 @@ Method | HTTP request | Description # **create_gcp_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} create_gcp_integration(body) +> dict create_gcp_integration(body) Create a Datadog-GCP integration. @@ -67,7 +67,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -89,7 +89,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **delete_gcp_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} delete_gcp_integration(body) +> dict delete_gcp_integration(body) Delete a given Datadog-GCP integration. @@ -145,7 +145,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization @@ -227,7 +227,7 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **update_gcp_integration** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} update_gcp_integration(body) +> dict update_gcp_integration(body) Update a Datadog-GCP integrations host_filters and/or auto-mute. Requires a `project_id` and `client_email`, however these fields cannot be updated. @@ -286,7 +286,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/KeyManagementApi.md b/docs/v1/KeyManagementApi.md index ef88a5b0fe..dd6c4fdca6 100644 --- a/docs/v1/KeyManagementApi.md +++ b/docs/v1/KeyManagementApi.md @@ -40,9 +40,6 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = key_management_api.KeyManagementApi(api_client) body = ApiKey( - created="2019-08-02 15:31:07", - created_by="john@example.com", - key="1234512345123456abcabc912349abcd", name="example user", ) # ApiKey | @@ -109,9 +106,7 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = key_management_api.KeyManagementApi(api_client) body = ApplicationKey( - hash="1234512345123459cda4eb9ced49a3d84fd0138c", name="example user", - owner="example.com", ) # ApplicationKey | # example passing only required values which don't have defaults set @@ -554,9 +549,6 @@ with ApiClient(configuration) as api_client: api_instance = key_management_api.KeyManagementApi(api_client) key = "key_example" # str | The specific API key you are working with. body = ApiKey( - created="2019-08-02 15:31:07", - created_by="john@example.com", - key="1234512345123456abcabc912349abcd", name="example user", ) # ApiKey | @@ -626,9 +618,7 @@ with ApiClient(configuration) as api_client: api_instance = key_management_api.KeyManagementApi(api_client) key = "key_example" # str | The specific APP key you are working with. body = ApplicationKey( - hash="1234512345123459cda4eb9ced49a3d84fd0138c", name="example user", - owner="example.com", ) # ApplicationKey | # example passing only required values which don't have defaults set diff --git a/docs/v1/LogsApi.md b/docs/v1/LogsApi.md index b24ec5e8e3..018624255a 100644 --- a/docs/v1/LogsApi.md +++ b/docs/v1/LogsApi.md @@ -92,7 +92,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **submit_log** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} submit_log(body) +> dict submit_log(body) Send your logs to your Datadog platform over HTTP. Limits per HTTP request are: @@ -172,7 +172,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/LogsIndexesApi.md b/docs/v1/LogsIndexesApi.md index f69cadd15e..9bfdc95940 100644 --- a/docs/v1/LogsIndexesApi.md +++ b/docs/v1/LogsIndexesApi.md @@ -50,7 +50,6 @@ with ApiClient(configuration) as api_client: filter=LogsFilter( query="source:python", ), - is_rate_limited=False, name="main", num_retention_days=15, ) # LogsIndex | Object containing the new index. diff --git a/docs/v1/LogsPipelinesApi.md b/docs/v1/LogsPipelinesApi.md index 26b75bbe97..3d828574a9 100644 --- a/docs/v1/LogsPipelinesApi.md +++ b/docs/v1/LogsPipelinesApi.md @@ -40,14 +40,11 @@ with ApiClient(configuration) as api_client: filter=LogsFilter( query="source:python", ), - id="id_example", is_enabled=True, - is_read_only=True, name="", processors=[ LogsProcessor(), ], - type="pipeline", ) # LogsPipeline | Definition of the new pipeline. # example passing only required values which don't have defaults set @@ -369,14 +366,11 @@ with ApiClient(configuration) as api_client: filter=LogsFilter( query="source:python", ), - id="id_example", is_enabled=True, - is_read_only=True, name="", processors=[ LogsProcessor(), ], - type="pipeline", ) # LogsPipeline | New definition of the pipeline. # example passing only required values which don't have defaults set diff --git a/docs/v1/MetricsApi.md b/docs/v1/MetricsApi.md index a2232dec10..d17d6cd328 100644 --- a/docs/v1/MetricsApi.md +++ b/docs/v1/MetricsApi.md @@ -399,7 +399,6 @@ with ApiClient(configuration) as api_client: metric_name = "metric_name_example" # str | Name of the metric for which to edit metadata. body = MetricMetadata( description="description_example", - integration="integration_example", per_unit="second", short_name="short_name_example", statsd_interval=1, diff --git a/docs/v1/MonitorSearchCount.md b/docs/v1/MonitorSearchCount.md index 1eac54111f..5871833a3f 100644 --- a/docs/v1/MonitorSearchCount.md +++ b/docs/v1/MonitorSearchCount.md @@ -5,7 +5,7 @@ Search facets. ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}]** | Search facets. | +**value** | **[dict]** | Search facets. | [[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) diff --git a/docs/v1/MonitorsApi.md b/docs/v1/MonitorsApi.md index 667c912ad0..4d826d368e 100644 --- a/docs/v1/MonitorsApi.md +++ b/docs/v1/MonitorsApi.md @@ -237,27 +237,9 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = monitors_api.MonitorsApi(api_client) body = Monitor( - created=dateutil_parser('1970-01-01T00:00:00.00Z'), - creator=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), - deleted=dateutil_parser('1970-01-01T00:00:00.00Z'), - id=1, message="message_example", - modified=dateutil_parser('1970-01-01T00:00:00.00Z'), - multi=True, name="name_example", options=MonitorOptions( - aggregation=MonitorOptionsAggregation( - group_by="host", - metric="metrics.name", - type="count", - ), - device_ids=[ - MonitorDeviceID("laptop_large"), - ], enable_logs_sample=True, escalation_message="none", evaluation_delay=1, @@ -290,24 +272,11 @@ with ApiClient(configuration) as api_client: ), timeout_h=1, ), - overall_state=MonitorOverallStates("Alert"), priority=1, query="avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100", restricted_roles=[ "restricted_roles_example", ], - state=MonitorState( - groups={ - "key": MonitorStateGroup( - last_nodata_ts=1, - last_notified_ts=1, - last_resolved_ts=1, - last_triggered_ts=1, - name="name_example", - status=MonitorOverallStates("Alert"), - ), - }, - ), tags=[ "tags_example", ], @@ -752,27 +721,9 @@ with ApiClient(configuration) as api_client: api_instance = monitors_api.MonitorsApi(api_client) monitor_id = 1 # int | The ID of the monitor. body = MonitorUpdateRequest( - created=dateutil_parser('1970-01-01T00:00:00.00Z'), - creator=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), - deleted=dateutil_parser('1970-01-01T00:00:00.00Z'), - id=1, message="message_example", - modified=dateutil_parser('1970-01-01T00:00:00.00Z'), - multi=True, name="name_example", options=MonitorOptions( - aggregation=MonitorOptionsAggregation( - group_by="host", - metric="metrics.name", - type="count", - ), - device_ids=[ - MonitorDeviceID("laptop_large"), - ], enable_logs_sample=True, escalation_message="none", evaluation_delay=1, @@ -805,24 +756,11 @@ with ApiClient(configuration) as api_client: ), timeout_h=1, ), - overall_state=MonitorOverallStates("Alert"), priority=1, query="query_example", restricted_roles=[ "restricted_roles_example", ], - state=MonitorState( - groups={ - "key": MonitorStateGroup( - last_nodata_ts=1, - last_notified_ts=1, - last_resolved_ts=1, - last_triggered_ts=1, - name="name_example", - status=MonitorOverallStates("Alert"), - ), - }, - ), tags=[ "tags_example", ], @@ -872,7 +810,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) # **validate_monitor** -> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} validate_monitor(body) +> dict validate_monitor(body) Validate the monitor provided in the request. @@ -895,27 +833,9 @@ with ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = monitors_api.MonitorsApi(api_client) body = Monitor( - created=dateutil_parser('1970-01-01T00:00:00.00Z'), - creator=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), - deleted=dateutil_parser('1970-01-01T00:00:00.00Z'), - id=1, message="message_example", - modified=dateutil_parser('1970-01-01T00:00:00.00Z'), - multi=True, name="name_example", options=MonitorOptions( - aggregation=MonitorOptionsAggregation( - group_by="host", - metric="metrics.name", - type="count", - ), - device_ids=[ - MonitorDeviceID("laptop_large"), - ], enable_logs_sample=True, escalation_message="none", evaluation_delay=1, @@ -948,24 +868,11 @@ with ApiClient(configuration) as api_client: ), timeout_h=1, ), - overall_state=MonitorOverallStates("Alert"), priority=1, query="avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100", restricted_roles=[ "restricted_roles_example", ], - state=MonitorState( - groups={ - "key": MonitorStateGroup( - last_nodata_ts=1, - last_notified_ts=1, - last_resolved_ts=1, - last_triggered_ts=1, - name="name_example", - status=MonitorOverallStates("Alert"), - ), - }, - ), tags=[ "tags_example", ], @@ -990,7 +897,7 @@ Name | Type | Description | Notes ### Return type -**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** +**dict** ### Authorization diff --git a/docs/v1/OrganizationsApi.md b/docs/v1/OrganizationsApi.md index cbe1e13caf..5574febfbe 100644 --- a/docs/v1/OrganizationsApi.md +++ b/docs/v1/OrganizationsApi.md @@ -243,7 +243,6 @@ with ApiClient(configuration) as api_client: billing=OrganizationBilling( type="type_example", ), - created="2019-09-26T17:28:28Z", description="some description", name="New child org", public_id="abcdef12345", diff --git a/docs/v1/SLOBulkDelete.md b/docs/v1/SLOBulkDelete.md index a76df1229d..2a83322f1e 100644 --- a/docs/v1/SLOBulkDelete.md +++ b/docs/v1/SLOBulkDelete.md @@ -5,7 +5,7 @@ A map of service level objective object IDs to arrays of timeframes, which indic ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**any string name** | **[SLOTimeframe]** | any string name can be used but the value must be the correct type | [optional] +**any string name** | [**[SLOTimeframe]**](SLOTimeframe.md) | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) diff --git a/docs/v1/ServiceLevelObjectivesApi.md b/docs/v1/ServiceLevelObjectivesApi.md index 99c68b9316..15638cb0f5 100644 --- a/docs/v1/ServiceLevelObjectivesApi.md +++ b/docs/v1/ServiceLevelObjectivesApi.md @@ -581,16 +581,8 @@ with ApiClient(configuration) as api_client: api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client) slo_id = "slo_id_example" # str | The ID of the service level objective object. body = ServiceLevelObjective( - created_at=1, - creator=Creator( - email="email_example", - handle="handle_example", - name="name_example", - ), description="description_example", groups=["env:prod","role:mysql"], - id="id_example", - modified_at=1, monitor_ids=[ 1, ], diff --git a/docs/v1/SyntheticsAPITestResultData.md b/docs/v1/SyntheticsAPITestResultData.md index a7875050ee..61e26f67af 100644 --- a/docs/v1/SyntheticsAPITestResultData.md +++ b/docs/v1/SyntheticsAPITestResultData.md @@ -10,9 +10,9 @@ Name | Type | Description | Notes **error_message** | **str** | The API test error message. | [optional] **event_type** | [**SyntheticsTestProcessStatus**](SyntheticsTestProcessStatus.md) | | [optional] **http_status_code** | **int** | The API test HTTP status code. | [optional] -**request_headers** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}** | Request header object used for the API test. | [optional] +**request_headers** | **{str: (dict,)}** | Request header object used for the API test. | [optional] **response_body** | **str** | Response body returned for the API test. | [optional] -**response_headers** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}** | Response headers returned for the API test. | [optional] +**response_headers** | **{str: (dict,)}** | Response headers returned for the API test. | [optional] **response_size** | **int** | Global size in byte of the API test response. | [optional] **timings** | [**SyntheticsTiming**](SyntheticsTiming.md) | | [optional] diff --git a/docs/v1/SyntheticsApi.md b/docs/v1/SyntheticsApi.md index 2c8974869a..10d2167f0b 100644 --- a/docs/v1/SyntheticsApi.md +++ b/docs/v1/SyntheticsApi.md @@ -56,7 +56,6 @@ with ApiClient(configuration) as api_client: api_instance = synthetics_api.SyntheticsApi(api_client) body = SyntheticsGlobalVariable( description="Example description", - id="id_example", name="MY_VARIABLE", parse_test_options=SyntheticsGlobalVariableParseTestOptions( field="content-type", @@ -138,17 +137,7 @@ with ApiClient(configuration) as api_client: api_instance = synthetics_api.SyntheticsApi(api_client) body = SyntheticsPrivateLocation( description="Description of private location", - id="id_example", name="New private location", - secrets=SyntheticsPrivateLocationSecrets( - authentication=SyntheticsPrivateLocationSecretsAuthentication( - id="id_example", - key="key_example", - ), - config_decryption=SyntheticsPrivateLocationSecretsConfigDecryption( - key="key_example", - ), - ), tags=["team:front"], ) # SyntheticsPrivateLocation | Details of the private location to create. @@ -265,7 +254,9 @@ with ApiClient(configuration) as api_client: steps=[ SyntheticsAPIStep( allow_failure=True, - assertions=[], + assertions=[ + SyntheticsAssertion(), + ], extracted_values=[ SyntheticsParsingOptions( field="content-type", @@ -300,7 +291,9 @@ with ApiClient(configuration) as api_client: ), dns_server="dns_server_example", dns_server_port=1, - headers=SyntheticsTestHeaders(SyntheticsTestHeaders), + headers=SyntheticsTestHeaders( + key="key_example", + ), host="host_example", method=HTTPMethod("GET"), no_saving_response_body=True, @@ -319,7 +312,6 @@ with ApiClient(configuration) as api_client: "locations_example", ], message="message_example", - monitor_id=1, name="name_example", options=SyntheticsTestOptions( accept_self_signed=True, @@ -343,7 +335,6 @@ with ApiClient(configuration) as api_client: ), tick_every=30, ), - public_id="public_id_example", status=SyntheticsTestPauseStatus("live"), subtype=SyntheticsTestDetailsSubType("http"), tags=[ @@ -469,7 +460,6 @@ with ApiClient(configuration) as api_client: "locations_example", ], message="", - monitor_id=1, name="name_example", options=SyntheticsTestOptions( accept_self_signed=True, @@ -493,7 +483,6 @@ with ApiClient(configuration) as api_client: ), tick_every=30, ), - public_id="public_id_example", status=SyntheticsTestPauseStatus("live"), steps=[ SyntheticsStep( @@ -769,7 +758,6 @@ with ApiClient(configuration) as api_client: variable_id = "variable_id_example" # str | The ID of the global variable. body = SyntheticsGlobalVariable( description="Example description", - id="id_example", name="MY_VARIABLE", parse_test_options=SyntheticsGlobalVariableParseTestOptions( field="content-type", @@ -1800,7 +1788,9 @@ with ApiClient(configuration) as api_client: steps=[ SyntheticsAPIStep( allow_failure=True, - assertions=[], + assertions=[ + SyntheticsAssertion(), + ], extracted_values=[ SyntheticsParsingOptions( field="content-type", @@ -1835,7 +1825,9 @@ with ApiClient(configuration) as api_client: ), dns_server="dns_server_example", dns_server_port=1, - headers=SyntheticsTestHeaders(SyntheticsTestHeaders), + headers=SyntheticsTestHeaders( + key="key_example", + ), host="host_example", method=HTTPMethod("GET"), no_saving_response_body=True, @@ -1854,7 +1846,6 @@ with ApiClient(configuration) as api_client: "locations_example", ], message="message_example", - monitor_id=1, name="name_example", options=SyntheticsTestOptions( accept_self_signed=True, @@ -1878,7 +1869,6 @@ with ApiClient(configuration) as api_client: ), tick_every=30, ), - public_id="public_id_example", status=SyntheticsTestPauseStatus("live"), subtype=SyntheticsTestDetailsSubType("http"), tags=[ @@ -2006,7 +1996,6 @@ with ApiClient(configuration) as api_client: "locations_example", ], message="", - monitor_id=1, name="name_example", options=SyntheticsTestOptions( accept_self_signed=True, @@ -2030,7 +2019,6 @@ with ApiClient(configuration) as api_client: ), tick_every=30, ), - public_id="public_id_example", status=SyntheticsTestPauseStatus("live"), steps=[ SyntheticsStep( @@ -2114,17 +2102,7 @@ with ApiClient(configuration) as api_client: location_id = "location_id_example" # str | The ID of the private location. body = SyntheticsPrivateLocation( description="Description of private location", - id="id_example", name="New private location", - secrets=SyntheticsPrivateLocationSecrets( - authentication=SyntheticsPrivateLocationSecretsAuthentication( - id="id_example", - key="key_example", - ), - config_decryption=SyntheticsPrivateLocationSecretsConfigDecryption( - key="key_example", - ), - ), tags=["team:front"], ) # SyntheticsPrivateLocation | Details of the private location to be updated. diff --git a/docs/v1/SyntheticsAssertionTarget.md b/docs/v1/SyntheticsAssertionTarget.md index cbe08b5c5b..c7df8ec6e8 100644 --- a/docs/v1/SyntheticsAssertionTarget.md +++ b/docs/v1/SyntheticsAssertionTarget.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **operator** | [**SyntheticsAssertionOperator**](SyntheticsAssertionOperator.md) | | **type** | [**SyntheticsAssertionType**](SyntheticsAssertionType.md) | | **_property** | **str** | The associated assertion property. | [optional] -**target** | **bool, date, datetime, dict, float, int, list, str** | Value used by the operator. | [optional] +**target** | **bool, date, datetime, dict, float, int, list, str, none_type** | Value used by the operator. | [optional] [[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) diff --git a/docs/v1/SyntheticsPrivateLocationCreationResponse.md b/docs/v1/SyntheticsPrivateLocationCreationResponse.md index bdae0b575a..69e809c358 100644 --- a/docs/v1/SyntheticsPrivateLocationCreationResponse.md +++ b/docs/v1/SyntheticsPrivateLocationCreationResponse.md @@ -5,7 +5,7 @@ Object that contains the new private location, the public key for result encrypt ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**config** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration. | [optional] +**config** | **dict** | Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration. | [optional] **private_location** | [**SyntheticsPrivateLocation**](SyntheticsPrivateLocation.md) | | [optional] **result_encryption** | [**SyntheticsPrivateLocationCreationResponseResultEncryption**](SyntheticsPrivateLocationCreationResponseResultEncryption.md) | | [optional] diff --git a/docs/v1/SyntheticsStep.md b/docs/v1/SyntheticsStep.md index dcfb8740db..f22bbb1ce4 100644 --- a/docs/v1/SyntheticsStep.md +++ b/docs/v1/SyntheticsStep.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **allow_failure** | **bool** | A boolean set to allow this step to fail. | [optional] **name** | **str** | The name of the step. | [optional] -**params** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | The parameters of the step. | [optional] +**params** | **dict** | The parameters of the step. | [optional] **timeout** | **int** | The time before declaring a step failed. | [optional] **type** | [**SyntheticsStepType**](SyntheticsStepType.md) | | [optional] diff --git a/docs/v1/SyntheticsStepDetail.md b/docs/v1/SyntheticsStepDetail.md index 72f5f52441..6f4d44f212 100644 --- a/docs/v1/SyntheticsStepDetail.md +++ b/docs/v1/SyntheticsStepDetail.md @@ -19,7 +19,7 @@ Name | Type | Description | Notes **time_to_interactive** | **float** | Time before starting the step. | [optional] **type** | [**SyntheticsStepType**](SyntheticsStepType.md) | | [optional] **url** | **str** | URL to perform the step against. | [optional] -**value** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | Value for the step. | [optional] +**value** | **dict** | Value for the step. | [optional] **vitals_metrics** | [**[SyntheticsCoreWebVitals]**](SyntheticsCoreWebVitals.md) | Array of Core Web Vitals metrics for the step. | [optional] **warnings** | [**[SyntheticsStepDetailWarning]**](SyntheticsStepDetailWarning.md) | Warning collected that didn't failed the step. | [optional] diff --git a/docs/v1/SyntheticsTestRequest.md b/docs/v1/SyntheticsTestRequest.md index 9bba1e132d..489d21fd64 100644 --- a/docs/v1/SyntheticsTestRequest.md +++ b/docs/v1/SyntheticsTestRequest.md @@ -17,7 +17,7 @@ Name | Type | Description | Notes **no_saving_response_body** | **bool** | Determines whether or not to save the response body. | [optional] **number_of_packets** | **int** | Number of pings to use per test. | [optional] **port** | **int** | Port to use when performing the test. | [optional] -**query** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | Query to use for the test. | [optional] +**query** | **dict** | Query to use for the test. | [optional] **should_track_hops** | **bool** | Turns on a traceroute probe to discover all gateways along the path to the host destination. | [optional] **timeout** | **float** | Timeout in seconds for the test. | [optional] **url** | **str** | URL to perform the test with. | [optional] diff --git a/docs/v1/UsersApi.md b/docs/v1/UsersApi.md index f3ba7620a3..7d4e18fbcf 100644 --- a/docs/v1/UsersApi.md +++ b/docs/v1/UsersApi.md @@ -42,9 +42,7 @@ with ApiClient(configuration) as api_client: disabled=False, email="test@datadoghq.com", handle="test@datadoghq.com", - icon="/path/to/matching/gravatar/icon", name="test user", - verified=True, ) # User | User object that needs to be created. # example passing only required values which don't have defaults set @@ -309,9 +307,7 @@ with ApiClient(configuration) as api_client: disabled=False, email="test@datadoghq.com", handle="test@datadoghq.com", - icon="/path/to/matching/gravatar/icon", name="test user", - verified=True, ) # User | Description of the update. # example passing only required values which don't have defaults set diff --git a/docs/v2/IncidentServicesApi.md b/docs/v2/IncidentServicesApi.md index f14dc7e808..15115b61c4 100644 --- a/docs/v2/IncidentServicesApi.md +++ b/docs/v2/IncidentServicesApi.md @@ -40,20 +40,6 @@ with ApiClient(configuration) as api_client: attributes=IncidentServiceCreateAttributes( name="an example service name", ), - relationships=IncidentServiceRelationships( - created_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - last_modified_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - ), type=IncidentServiceType("services"), ), ) # IncidentServiceCreateRequest | Incident Service Payload. @@ -349,20 +335,6 @@ with ApiClient(configuration) as api_client: name="an example service name", ), id="00000000-0000-0000-0000-000000000000", - relationships=IncidentServiceRelationships( - created_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - last_modified_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - ), type=IncidentServiceType("services"), ), ) # IncidentServiceUpdateRequest | Incident Service Payload. diff --git a/docs/v2/IncidentTeamsApi.md b/docs/v2/IncidentTeamsApi.md index c539fe17b9..ea1262a8e4 100644 --- a/docs/v2/IncidentTeamsApi.md +++ b/docs/v2/IncidentTeamsApi.md @@ -40,20 +40,6 @@ with ApiClient(configuration) as api_client: attributes=IncidentTeamCreateAttributes( name="team name", ), - relationships=IncidentTeamRelationships( - created_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - last_modified_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - ), type=IncidentTeamType("teams"), ), ) # IncidentTeamCreateRequest | Incident Team Payload. @@ -349,20 +335,6 @@ with ApiClient(configuration) as api_client: name="team name", ), id="00000000-0000-0000-0000-000000000000", - relationships=IncidentTeamRelationships( - created_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - last_modified_by=RelationshipToUser( - data=RelationshipToUserData( - id="00000000-0000-0000-0000-000000000000", - type=UsersType("users"), - ), - ), - ), type=IncidentTeamType("teams"), ), ) # IncidentTeamUpdateRequest | Incident Team Payload. diff --git a/docs/v2/RolesApi.md b/docs/v2/RolesApi.md index 000fb3816e..ff8b66a13f 100644 --- a/docs/v2/RolesApi.md +++ b/docs/v2/RolesApi.md @@ -188,8 +188,6 @@ with ApiClient(configuration) as api_client: body = RoleCreateRequest( data=RoleCreateData( attributes=RoleCreateAttributes( - created_at=dateutil_parser('1970-01-01T00:00:00.00Z'), - modified_at=dateutil_parser('1970-01-01T00:00:00.00Z'), name="developers", ), relationships=RoleRelationships( @@ -826,8 +824,6 @@ with ApiClient(configuration) as api_client: body = RoleUpdateRequest( data=RoleUpdateData( attributes=RoleUpdateAttributes( - created_at=dateutil_parser('1970-01-01T00:00:00.00Z'), - modified_at=dateutil_parser('1970-01-01T00:00:00.00Z'), name="name_example", ), id="00000000-0000-0000-0000-000000000000", diff --git a/src/datadog_api_client/v1/api/aws_integration_api.py b/src/datadog_api_client/v1/api/aws_integration_api.py index b12ee6cbb9..666fbdf26b 100644 --- a/src/datadog_api_client/v1/api/aws_integration_api.py +++ b/src/datadog_api_client/v1/api/aws_integration_api.py @@ -76,7 +76,7 @@ def __init__(self, api_client=None): self._create_aws_tag_filter_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws/filtering", "operation_id": "create_aws_tag_filter", @@ -148,7 +148,7 @@ def __init__(self, api_client=None): self._delete_aws_account_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws", "operation_id": "delete_aws_account", @@ -184,7 +184,7 @@ def __init__(self, api_client=None): self._delete_aws_tag_filter_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws/filtering", "operation_id": "delete_aws_tag_filter", @@ -333,7 +333,7 @@ def __init__(self, api_client=None): self._update_aws_account_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws", "operation_id": "update_aws_account", @@ -458,7 +458,7 @@ def create_aws_tag_filter(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -544,7 +544,7 @@ def delete_aws_account(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -587,7 +587,7 @@ def delete_aws_tag_filter(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -759,7 +759,7 @@ def update_aws_account(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api/aws_logs_integration_api.py b/src/datadog_api_client/v1/api/aws_logs_integration_api.py index 45dba397a0..15420db85e 100644 --- a/src/datadog_api_client/v1/api/aws_logs_integration_api.py +++ b/src/datadog_api_client/v1/api/aws_logs_integration_api.py @@ -110,7 +110,7 @@ def __init__(self, api_client=None): self._create_aws_lambda_arn_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws/logs", "operation_id": "create_aws_lambda_arn", @@ -146,7 +146,7 @@ def __init__(self, api_client=None): self._delete_aws_lambda_arn_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws/logs", "operation_id": "delete_aws_lambda_arn", @@ -182,7 +182,7 @@ def __init__(self, api_client=None): self._enable_aws_log_services_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/aws/logs/services", "operation_id": "enable_aws_log_services", @@ -387,7 +387,7 @@ def create_aws_lambda_arn(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -430,7 +430,7 @@ def delete_aws_lambda_arn(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -473,7 +473,7 @@ def enable_aws_log_services(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api/azure_integration_api.py b/src/datadog_api_client/v1/api/azure_integration_api.py index 9f66403102..c21f42b676 100644 --- a/src/datadog_api_client/v1/api/azure_integration_api.py +++ b/src/datadog_api_client/v1/api/azure_integration_api.py @@ -35,7 +35,7 @@ def __init__(self, api_client=None): self._create_azure_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/azure", "operation_id": "create_azure_integration", @@ -71,7 +71,7 @@ def __init__(self, api_client=None): self._delete_azure_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/azure", "operation_id": "delete_azure_integration", @@ -132,7 +132,7 @@ def __init__(self, api_client=None): self._update_azure_host_filters_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/azure/host_filters", "operation_id": "update_azure_host_filters", @@ -168,7 +168,7 @@ def __init__(self, api_client=None): self._update_azure_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/azure", "operation_id": "update_azure_integration", @@ -237,7 +237,7 @@ def create_azure_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -280,7 +280,7 @@ def delete_azure_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -363,7 +363,7 @@ def update_azure_host_filters(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -406,7 +406,7 @@ def update_azure_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api/gcp_integration_api.py b/src/datadog_api_client/v1/api/gcp_integration_api.py index f8045e1d71..636bf1d32b 100644 --- a/src/datadog_api_client/v1/api/gcp_integration_api.py +++ b/src/datadog_api_client/v1/api/gcp_integration_api.py @@ -35,7 +35,7 @@ def __init__(self, api_client=None): self._create_gcp_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/gcp", "operation_id": "create_gcp_integration", @@ -71,7 +71,7 @@ def __init__(self, api_client=None): self._delete_gcp_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/gcp", "operation_id": "delete_gcp_integration", @@ -132,7 +132,7 @@ def __init__(self, api_client=None): self._update_gcp_integration_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/integration/gcp", "operation_id": "update_gcp_integration", @@ -201,7 +201,7 @@ def create_gcp_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -244,7 +244,7 @@ def delete_gcp_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ @@ -327,7 +327,7 @@ def update_gcp_integration(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api/logs_api.py b/src/datadog_api_client/v1/api/logs_api.py index 7d97362130..5e8de7586d 100644 --- a/src/datadog_api_client/v1/api/logs_api.py +++ b/src/datadog_api_client/v1/api/logs_api.py @@ -75,7 +75,7 @@ def __init__(self, api_client=None): self._submit_log_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth"], "endpoint_path": "/v1/input", "operation_id": "submit_log", @@ -245,7 +245,7 @@ def submit_log(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api/monitors_api.py b/src/datadog_api_client/v1/api/monitors_api.py index 91de6ac755..916f86fa0b 100644 --- a/src/datadog_api_client/v1/api/monitors_api.py +++ b/src/datadog_api_client/v1/api/monitors_api.py @@ -425,7 +425,7 @@ def __init__(self, api_client=None): self._validate_monitor_endpoint = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + "response_type": (dict,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/monitor/validate", "operation_id": "validate_monitor", @@ -849,7 +849,7 @@ def validate_monitor(self, body, **kwargs): async_req (bool): execute request asynchronously Returns: - {str: (bool, date, datetime, dict, float, int, list, str, none_type)} + dict If the method is called asynchronously, returns the request thread. """ diff --git a/src/datadog_api_client/v1/api_client.py b/src/datadog_api_client/v1/api_client.py index 5cc232a67a..d8d21cb9d6 100644 --- a/src/datadog_api_client/v1/api_client.py +++ b/src/datadog_api_client/v1/api_client.py @@ -124,7 +124,7 @@ def __call_api( _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None, ): @@ -325,7 +325,7 @@ def call_api( _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None, ): @@ -689,7 +689,7 @@ def __init__(self, settings=None, params_map=None, root_map=None, headers_map=No "async_req": (bool,), "_host_index": (none_type, int), "_preload_content": (bool,), - "_request_timeout": (none_type, int, (int,), [int]), + "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), "_return_http_data_only": (bool,), "_check_input_type": (bool,), "_check_return_type": (bool,), diff --git a/src/datadog_api_client/v1/model/access_role.py b/src/datadog_api_client/v1/model/access_role.py index 82742dbe4d..62ef5e2b10 100644 --- a/src/datadog_api_client/v1/model/access_role.py +++ b/src/datadog_api_client/v1/model/access_role.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AccessRole(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -176,3 +180,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """AccessRole - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The access role of the user. Options are **st** (standard user), **adm** (admin user), or **ro** (read-only user).. if omitted defaults to "st", must be one of ["st", "adm", "ro", "ERROR", ] # noqa: E501 + + Keyword Args: + value (str): The access role of the user. Options are **st** (standard user), **adm** (admin user), or **ro** (read-only user).. if omitted defaults to "st", must be one of ["st", "adm", "ro", "ERROR", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "st" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/alert_graph_widget_definition.py b/src/datadog_api_client/v1/model/alert_graph_widget_definition.py index ae19c05e3a..54dc5fa50a 100644 --- a/src/datadog_api_client/v1/model/alert_graph_widget_definition.py +++ b/src/datadog_api_client/v1/model/alert_graph_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,98 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, alert_id, type, viz_type, *args, **kwargs): # noqa: E501 + """AlertGraphWidgetDefinition - a model defined in OpenAPI + + Args: + alert_id (str): ID of the alert to use in the widget. + type (AlertGraphWidgetDefinitionType): + viz_type (WidgetVizType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + time (WidgetTime): [optional] # noqa: E501 + title (str): The title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.alert_id = alert_id + self.type = type + self.viz_type = viz_type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -197,3 +289,8 @@ def __init__(self, alert_id, type, viz_type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/alert_graph_widget_definition_type.py b/src/datadog_api_client/v1/model/alert_graph_widget_definition_type.py index c7c24d3c6a..77d7914b7c 100644 --- a/src/datadog_api_client/v1/model/alert_graph_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/alert_graph_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AlertGraphWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """AlertGraphWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the alert graph widget.. if omitted defaults to "alert_graph", must be one of ["alert_graph", ] # noqa: E501 + + Keyword Args: + value (str): Type of the alert graph widget.. if omitted defaults to "alert_graph", must be one of ["alert_graph", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "alert_graph" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/alert_value_widget_definition.py b/src/datadog_api_client/v1/model/alert_value_widget_definition.py index c5a773dfe7..606c0de56f 100644 --- a/src/datadog_api_client/v1/model/alert_value_widget_definition.py +++ b/src/datadog_api_client/v1/model/alert_value_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,98 @@ def discriminator(): "unit": "unit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, alert_id, type, *args, **kwargs): # noqa: E501 + """AlertValueWidgetDefinition - a model defined in OpenAPI + + Args: + alert_id (str): ID of the alert to use in the widget. + type (AlertValueWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + precision (int): Number of decimal to show. If not defined, will use the raw value.. [optional] # noqa: E501 + text_align (WidgetTextAlign): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of value in the widget.. [optional] # noqa: E501 + unit (str): Unit to display with the value.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.alert_id = alert_id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -195,3 +287,8 @@ def __init__(self, alert_id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/alert_value_widget_definition_type.py b/src/datadog_api_client/v1/model/alert_value_widget_definition_type.py index 72da635403..3aa0f6a834 100644 --- a/src/datadog_api_client/v1/model/alert_value_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/alert_value_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AlertValueWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """AlertValueWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the alert value widget.. if omitted defaults to "alert_value", must be one of ["alert_value", ] # noqa: E501 + + Keyword Args: + value (str): Type of the alert value widget.. if omitted defaults to "alert_value", must be one of ["alert_value", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "alert_value" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/api_error_response.py b/src/datadog_api_client/v1/model/api_error_response.py index 71dd3d3b33..abfc7cbd86 100644 --- a/src/datadog_api_client/v1/model/api_error_response.py +++ b/src/datadog_api_client/v1/model/api_error_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class APIErrorResponse(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, errors, *args, **kwargs): # noqa: E501 + """APIErrorResponse - a model defined in OpenAPI + + Args: + errors ([str]): Array of errors returned by the API. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.errors = errors + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, errors, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/api_key.py b/src/datadog_api_client/v1/model/api_key.py index a9e944cfcb..a600ab2611 100644 --- a/src/datadog_api_client/v1/model/api_key.py +++ b/src/datadog_api_client/v1/model/api_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ApiKey(ModelNormal): @@ -87,8 +89,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "created_by", # noqa: E501 + "key", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApiKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (str): Date of creation of the API key.. [optional] # noqa: E501 + created_by (str): Datadog user handle that created the API key.. [optional] # noqa: E501 + key (str): API key.. [optional] # noqa: E501 + name (str): Name of your API key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/api_key_list_response.py b/src/datadog_api_client/v1/model/api_key_list_response.py index 3887546307..45ec8acb98 100644 --- a/src/datadog_api_client/v1/model/api_key_list_response.py +++ b/src/datadog_api_client/v1/model/api_key_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "api_keys": "api_keys", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApiKeyListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + api_keys ([ApiKey]): Array of API keys.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/api_key_response.py b/src/datadog_api_client/v1/model/api_key_response.py index acb9244efe..5b6ea79da3 100644 --- a/src/datadog_api_client/v1/model/api_key_response.py +++ b/src/datadog_api_client/v1/model/api_key_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "api_key": "api_key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApiKeyResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + api_key (ApiKey): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/apm_stats_query_column_type.py b/src/datadog_api_client/v1/model/apm_stats_query_column_type.py index c978d5d853..918776a8d9 100644 --- a/src/datadog_api_client/v1/model/apm_stats_query_column_type.py +++ b/src/datadog_api_client/v1/model/apm_stats_query_column_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "order": "order", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """ApmStatsQueryColumnType - a model defined in OpenAPI + + Args: + name (str): Column name. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + alias (str): A user-assigned alias for the column.. [optional] # noqa: E501 + cell_display_mode (TableWidgetCellDisplayMode): [optional] # noqa: E501 + order (WidgetSort): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/apm_stats_query_definition.py b/src/datadog_api_client/v1/model/apm_stats_query_definition.py index fc491e2398..3c96f95fa4 100644 --- a/src/datadog_api_client/v1/model/apm_stats_query_definition.py +++ b/src/datadog_api_client/v1/model/apm_stats_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,100 @@ def discriminator(): "resource": "resource", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, env, name, primary_tag, row_type, service, *args, **kwargs): # noqa: E501 + """ApmStatsQueryDefinition - a model defined in OpenAPI + + Args: + env (str): Environment name. + name (str): Operation name associated with service. + primary_tag (str): The organization's host group name and value. + row_type (ApmStatsQueryRowType): + service (str): Service name. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + columns ([ApmStatsQueryColumnType]): Column properties used by the front end for display.. [optional] # noqa: E501 + resource (str): Resource name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.env = env + self.name = name + self.primary_tag = primary_tag + self.row_type = row_type + self.service = service + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -195,3 +289,8 @@ def __init__(self, env, name, primary_tag, row_type, service, *args, **kwargs): # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/apm_stats_query_row_type.py b/src/datadog_api_client/v1/model/apm_stats_query_row_type.py index 78b6ea3db7..3abcd0e173 100644 --- a/src/datadog_api_client/v1/model/apm_stats_query_row_type.py +++ b/src/datadog_api_client/v1/model/apm_stats_query_row_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ApmStatsQueryRowType(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ApmStatsQueryRowType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The level of detail for the request.., must be one of ["service", "resource", "span", ] # noqa: E501 + + Keyword Args: + value (str): The level of detail for the request.., must be one of ["service", "resource", "span", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/application_key.py b/src/datadog_api_client/v1/model/application_key.py index 8ac858b840..aaeb483e8d 100644 --- a/src/datadog_api_client/v1/model/application_key.py +++ b/src/datadog_api_client/v1/model/application_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ApplicationKey(ModelNormal): @@ -85,8 +87,92 @@ def discriminator(): "owner": "owner", # noqa: E501 } + read_only_vars = { + "hash", # noqa: E501 + "owner", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hash (str): Hash of an application key.. [optional] # noqa: E501 + name (str): Name of an application key.. [optional] # noqa: E501 + owner (str): Owner of an application key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/application_key_list_response.py b/src/datadog_api_client/v1/model/application_key_list_response.py index 1fed671677..95e3c66347 100644 --- a/src/datadog_api_client/v1/model/application_key_list_response.py +++ b/src/datadog_api_client/v1/model/application_key_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "application_keys": "application_keys", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKeyListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + application_keys ([ApplicationKey]): Array of application keys.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/application_key_response.py b/src/datadog_api_client/v1/model/application_key_response.py index 5ac836843d..eb8b9d806f 100644 --- a/src/datadog_api_client/v1/model/application_key_response.py +++ b/src/datadog_api_client/v1/model/application_key_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "application_key": "application_key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKeyResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + application_key (ApplicationKey): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/authentication_validation_response.py b/src/datadog_api_client/v1/model/authentication_validation_response.py index 3d88a766cd..8f56ad4caa 100644 --- a/src/datadog_api_client/v1/model/authentication_validation_response.py +++ b/src/datadog_api_client/v1/model/authentication_validation_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AuthenticationValidationResponse(ModelNormal): @@ -76,8 +78,89 @@ def discriminator(): "valid": "valid", # noqa: E501 } + read_only_vars = { + "valid", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AuthenticationValidationResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + valid (bool): Return `true` if the authentication response is valid.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +244,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_account.py b/src/datadog_api_client/v1/model/aws_account.py index 1fc0b405f6..d8a22cdb53 100644 --- a/src/datadog_api_client/v1/model/aws_account.py +++ b/src/datadog_api_client/v1/model/aws_account.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSAccount(ModelNormal): @@ -90,8 +92,94 @@ def discriminator(): "secret_access_key": "secret_access_key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSAccount - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + access_key_id (str): Your AWS access key ID. Only required if your AWS account is a GovCloud or China account.. [optional] # noqa: E501 + account_id (str): Your AWS Account ID without dashes.. [optional] # noqa: E501 + account_specific_namespace_rules ({str: (bool,)}): An object, (in the form `{\"namespace1\":true/false, \"namespace2\":true/false}`), that enables or disables metric collection for specific AWS namespaces for this AWS account only.. [optional] # noqa: E501 + excluded_regions ([str]): An array of AWS regions to exclude from metrics collection.. [optional] # noqa: E501 + filter_tags ([str]): The array of EC2 tags (in the form `key:value`) defines a filter that Datadog uses when collecting metrics from EC2. Wildcards, such as `?` (for single characters) and `*` (for multiple characters) can also be used. Only hosts that match one of the defined tags will be imported into Datadog. The rest will be ignored. Host matching a given tag can also be excluded by adding `!` before the tag. For example, `env:production,instance-type:c1.*,!region:us-east-1`. [optional] # noqa: E501 + host_tags ([str]): Array of tags (in the form `key:value`) to add to all hosts and metrics reporting through this integration.. [optional] # noqa: E501 + role_name (str): Your Datadog role delegation name.. [optional] # noqa: E501 + secret_access_key (str): Your AWS secret access key. Only required if your AWS account is a GovCloud or China account.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +270,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_account_and_lambda_request.py b/src/datadog_api_client/v1/model/aws_account_and_lambda_request.py index a9af92baf7..fa404cc5fa 100644 --- a/src/datadog_api_client/v1/model/aws_account_and_lambda_request.py +++ b/src/datadog_api_client/v1/model/aws_account_and_lambda_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSAccountAndLambdaRequest(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "lambda_arn": "lambda_arn", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, account_id, lambda_arn, *args, **kwargs): # noqa: E501 + """AWSAccountAndLambdaRequest - a model defined in OpenAPI + + Args: + account_id (str): Your AWS Account ID without dashes. + lambda_arn (str): ARN of the Datadog Lambda created during the Datadog-Amazon Web services Log collection setup. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.account_id = account_id + self.lambda_arn = lambda_arn + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, account_id, lambda_arn, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_account_create_response.py b/src/datadog_api_client/v1/model/aws_account_create_response.py index 292bb20bfa..74f47b7e67 100644 --- a/src/datadog_api_client/v1/model/aws_account_create_response.py +++ b/src/datadog_api_client/v1/model/aws_account_create_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSAccountCreateResponse(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "external_id": "external_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSAccountCreateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + external_id (str): AWS external_id.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_account_delete_request.py b/src/datadog_api_client/v1/model/aws_account_delete_request.py index 19c4ba9728..febf8e03ea 100644 --- a/src/datadog_api_client/v1/model/aws_account_delete_request.py +++ b/src/datadog_api_client/v1/model/aws_account_delete_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSAccountDeleteRequest(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "role_name": "role_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSAccountDeleteRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + access_key_id (str): Your AWS access key ID. Only required if your AWS account is a GovCloud or China account.. [optional] # noqa: E501 + account_id (str): Your AWS Account ID without dashes.. [optional] # noqa: E501 + role_name (str): Your Datadog role delegation name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_account_list_response.py b/src/datadog_api_client/v1/model/aws_account_list_response.py index 7cb49bb981..8441ee8bb2 100644 --- a/src/datadog_api_client/v1/model/aws_account_list_response.py +++ b/src/datadog_api_client/v1/model/aws_account_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "accounts": "accounts", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSAccountListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + accounts ([AWSAccount]): List of enabled AWS accounts.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_async_error.py b/src/datadog_api_client/v1/model/aws_logs_async_error.py index da8d6cf9cc..719ac9c509 100644 --- a/src/datadog_api_client/v1/model/aws_logs_async_error.py +++ b/src/datadog_api_client/v1/model/aws_logs_async_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSLogsAsyncError(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSLogsAsyncError - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + code (str): Code properties. [optional] # noqa: E501 + message (str): Message content.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_async_response.py b/src/datadog_api_client/v1/model/aws_logs_async_response.py index 14dc9d6ff5..888eb4cd56 100644 --- a/src/datadog_api_client/v1/model/aws_logs_async_response.py +++ b/src/datadog_api_client/v1/model/aws_logs_async_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSLogsAsyncResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + errors ([AWSLogsAsyncError]): List of errors.. [optional] # noqa: E501 + status (str): Status of the properties.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_lambda.py b/src/datadog_api_client/v1/model/aws_logs_lambda.py index a97bdd252f..975ce2a6c1 100644 --- a/src/datadog_api_client/v1/model/aws_logs_lambda.py +++ b/src/datadog_api_client/v1/model/aws_logs_lambda.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSLogsLambda(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "arn": "arn", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSLogsLambda - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + arn (str): Available ARN IDs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_list_response.py b/src/datadog_api_client/v1/model/aws_logs_list_response.py index d80b819bf5..6a82f17bc7 100644 --- a/src/datadog_api_client/v1/model/aws_logs_list_response.py +++ b/src/datadog_api_client/v1/model/aws_logs_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,89 @@ def discriminator(): "services": "services", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSLogsListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + account_id (str): Your AWS Account ID without dashes.. [optional] # noqa: E501 + lambdas ([AWSLogsLambda]): List of ARNs configured in your Datadog account.. [optional] # noqa: E501 + services ([str]): Array of services IDs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_list_services_response.py b/src/datadog_api_client/v1/model/aws_logs_list_services_response.py index 0541688cf9..d8a1eddd32 100644 --- a/src/datadog_api_client/v1/model/aws_logs_list_services_response.py +++ b/src/datadog_api_client/v1/model/aws_logs_list_services_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSLogsListServicesResponse(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "label": "label", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSLogsListServicesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Key value in returned object.. [optional] # noqa: E501 + label (str): Name of service available for configuration with Datadog logs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_logs_services_request.py b/src/datadog_api_client/v1/model/aws_logs_services_request.py index 7c1cf2d573..bf284957b2 100644 --- a/src/datadog_api_client/v1/model/aws_logs_services_request.py +++ b/src/datadog_api_client/v1/model/aws_logs_services_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSLogsServicesRequest(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "services": "services", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, account_id, services, *args, **kwargs): # noqa: E501 + """AWSLogsServicesRequest - a model defined in OpenAPI + + Args: + account_id (str): Your AWS Account ID without dashes. + services ([str]): Array of services IDs set to enable automatic log collection. Discover the list of available services with the get list of AWS log ready services API endpoint. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.account_id = account_id + self.services = services + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, account_id, services, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_namespace.py b/src/datadog_api_client/v1/model/aws_namespace.py index 445b392be2..d0a974ed26 100644 --- a/src/datadog_api_client/v1/model/aws_namespace.py +++ b/src/datadog_api_client/v1/model/aws_namespace.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AWSNamespace(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """AWSNamespace - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The namespace associated with the tag filter entry.., must be one of ["elb", "application_elb", "sqs", "rds", "custom", "network_elb", "lambda", ] # noqa: E501 + + Keyword Args: + value (str): The namespace associated with the tag filter entry.., must be one of ["elb", "application_elb", "sqs", "rds", "custom", "network_elb", "lambda", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/aws_tag_filter.py b/src/datadog_api_client/v1/model/aws_tag_filter.py index 274af8e019..799895704b 100644 --- a/src/datadog_api_client/v1/model/aws_tag_filter.py +++ b/src/datadog_api_client/v1/model/aws_tag_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "tag_filter_str": "tag_filter_str", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSTagFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + namespace (AWSNamespace): [optional] # noqa: E501 + tag_filter_str (str): The tag filter string.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_tag_filter_create_request.py b/src/datadog_api_client/v1/model/aws_tag_filter_create_request.py index 390ac737d0..60f87ba1b9 100644 --- a/src/datadog_api_client/v1/model/aws_tag_filter_create_request.py +++ b/src/datadog_api_client/v1/model/aws_tag_filter_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,89 @@ def discriminator(): "tag_filter_str": "tag_filter_str", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSTagFilterCreateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + account_id (str): Your AWS Account ID without dashes.. [optional] # noqa: E501 + namespace (AWSNamespace): [optional] # noqa: E501 + tag_filter_str (str): The tag filter string.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_tag_filter_delete_request.py b/src/datadog_api_client/v1/model/aws_tag_filter_delete_request.py index ecd855c7cf..7f2db6afec 100644 --- a/src/datadog_api_client/v1/model/aws_tag_filter_delete_request.py +++ b/src/datadog_api_client/v1/model/aws_tag_filter_delete_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "namespace": "namespace", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSTagFilterDeleteRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + account_id (str): The unique identifier of your AWS account.. [optional] # noqa: E501 + namespace (AWSNamespace): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/aws_tag_filter_list_response.py b/src/datadog_api_client/v1/model/aws_tag_filter_list_response.py index fa7eb7e024..932a19cf1d 100644 --- a/src/datadog_api_client/v1/model/aws_tag_filter_list_response.py +++ b/src/datadog_api_client/v1/model/aws_tag_filter_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "filters": "filters", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AWSTagFilterListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filters ([AWSTagFilter]): An array of tag filters.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/azure_account.py b/src/datadog_api_client/v1/model/azure_account.py index 3627a56db6..48ccebf98b 100644 --- a/src/datadog_api_client/v1/model/azure_account.py +++ b/src/datadog_api_client/v1/model/azure_account.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class AzureAccount(ModelNormal): @@ -88,8 +90,93 @@ def discriminator(): "tenant_name": "tenant_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AzureAccount - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + client_id (str): Your Azure web application ID.. [optional] # noqa: E501 + client_secret (str): Your Azure web application secret key.. [optional] # noqa: E501 + errors ([str]): Errors in your configuration.. [optional] # noqa: E501 + host_filters (str): Limit the Azure instances that are pulled into Datadog by using tags. Only hosts that match one of the defined tags are imported into Datadog.. [optional] # noqa: E501 + new_client_id (str): Your New Azure web application ID.. [optional] # noqa: E501 + new_tenant_name (str): Your New Azure Active Directory ID.. [optional] # noqa: E501 + tenant_name (str): Your Azure Active Directory ID.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +266,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/azure_account_list_response.py b/src/datadog_api_client/v1/model/azure_account_list_response.py index 508a3eed4d..092d191009 100644 --- a/src/datadog_api_client/v1/model/azure_account_list_response.py +++ b/src/datadog_api_client/v1/model/azure_account_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """AzureAccountListResponse - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([AzureAccount]): Accounts configured for your organization.. # noqa: E501 + + Keyword Args: + value ([AzureAccount]): Accounts configured for your organization.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/cancel_downtimes_by_scope_request.py b/src/datadog_api_client/v1/model/cancel_downtimes_by_scope_request.py index 3b8582368b..7c19726ce8 100644 --- a/src/datadog_api_client/v1/model/cancel_downtimes_by_scope_request.py +++ b/src/datadog_api_client/v1/model/cancel_downtimes_by_scope_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class CancelDowntimesByScopeRequest(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "scope": "scope", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, scope, *args, **kwargs): # noqa: E501 + """CancelDowntimesByScopeRequest - a model defined in OpenAPI + + Args: + scope (str): The scope(s) to which the downtime applies. For example, `host:app2`. Provide multiple scopes as a comma-separated list like `env:dev,env:prod`. The resulting downtime applies to sources that matches ALL provided scopes (`env:dev` **AND** `env:prod`). + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.scope = scope + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, scope, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/canceled_downtimes_ids.py b/src/datadog_api_client/v1/model/canceled_downtimes_ids.py index a4ddbeeeac..24068e98cc 100644 --- a/src/datadog_api_client/v1/model/canceled_downtimes_ids.py +++ b/src/datadog_api_client/v1/model/canceled_downtimes_ids.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class CanceledDowntimesIds(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "cancelled_ids": "cancelled_ids", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """CanceledDowntimesIds - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cancelled_ids ([int]): ID of downtimes that were canceled.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/change_widget_definition.py b/src/datadog_api_client/v1/model/change_widget_definition.py index d153b9b427..14fb2254d1 100644 --- a/src/datadog_api_client/v1/model/change_widget_definition.py +++ b/src/datadog_api_client/v1/model/change_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -108,8 +110,97 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """ChangeWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([ChangeWidgetRequest]): Array of one request object to display in the widget. See the dedicated [Request JSON schema documentation](https://docs.datadoghq.com/dashboards/graphing_json/request_json) to learn how to build the `REQUEST_SCHEMA`. + type (ChangeWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +294,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/change_widget_definition_type.py b/src/datadog_api_client/v1/model/change_widget_definition_type.py index e68c3f4673..e5b8d1a7c6 100644 --- a/src/datadog_api_client/v1/model/change_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/change_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ChangeWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ChangeWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the change widget.. if omitted defaults to "change", must be one of ["change", ] # noqa: E501 + + Keyword Args: + value (str): Type of the change widget.. if omitted defaults to "change", must be one of ["change", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "change" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/change_widget_request.py b/src/datadog_api_client/v1/model/change_widget_request.py index c125b1673c..245a7c2e1e 100644 --- a/src/datadog_api_client/v1/model/change_widget_request.py +++ b/src/datadog_api_client/v1/model/change_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -121,8 +123,101 @@ def discriminator(): "show_present": "show_present", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ChangeWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + change_type (WidgetChangeType): [optional] # noqa: E501 + compare_to (WidgetCompareTo): [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + increase_good (bool): Whether to show increase as good.. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + order_by (WidgetOrderBy): [optional] # noqa: E501 + order_dir (WidgetSort): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Query definition.. [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + show_present (bool): Whether to show the present value.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -220,3 +315,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_can_delete_monitor_response.py b/src/datadog_api_client/v1/model/check_can_delete_monitor_response.py index bfbde67df7..76cd6f6502 100644 --- a/src/datadog_api_client/v1/model/check_can_delete_monitor_response.py +++ b/src/datadog_api_client/v1/model/check_can_delete_monitor_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,91 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """CheckCanDeleteMonitorResponse - a model defined in OpenAPI + + Args: + data (CheckCanDeleteMonitorResponseData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + errors ({str: ([str],)}): A mapping of Monitor ID to strings denoting where it's used.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +259,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_can_delete_monitor_response_data.py b/src/datadog_api_client/v1/model/check_can_delete_monitor_response_data.py index 600af7cf33..db2520d66f 100644 --- a/src/datadog_api_client/v1/model/check_can_delete_monitor_response_data.py +++ b/src/datadog_api_client/v1/model/check_can_delete_monitor_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class CheckCanDeleteMonitorResponseData(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "ok": "ok", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """CheckCanDeleteMonitorResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + ok ([int]): An array of of Monitor IDs that can be safely deleted.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_can_delete_slo_response.py b/src/datadog_api_client/v1/model/check_can_delete_slo_response.py index c854f5f91b..762b56933b 100644 --- a/src/datadog_api_client/v1/model/check_can_delete_slo_response.py +++ b/src/datadog_api_client/v1/model/check_can_delete_slo_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """CheckCanDeleteSLOResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (CheckCanDeleteSLOResponseData): [optional] # noqa: E501 + errors ({str: (str,)}): A mapping of SLO id to it's current usages.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_can_delete_slo_response_data.py b/src/datadog_api_client/v1/model/check_can_delete_slo_response_data.py index c95d0fe383..9f9eab08f4 100644 --- a/src/datadog_api_client/v1/model/check_can_delete_slo_response_data.py +++ b/src/datadog_api_client/v1/model/check_can_delete_slo_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class CheckCanDeleteSLOResponseData(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "ok": "ok", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """CheckCanDeleteSLOResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + ok ([str]): An array of of SLO IDs that can be safely deleted.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_status_widget_definition.py b/src/datadog_api_client/v1/model/check_status_widget_definition.py index c8c9dec36c..237ebdd7bc 100644 --- a/src/datadog_api_client/v1/model/check_status_widget_definition.py +++ b/src/datadog_api_client/v1/model/check_status_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,101 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, check, grouping, type, *args, **kwargs): # noqa: E501 + """CheckStatusWidgetDefinition - a model defined in OpenAPI + + Args: + check (str): Name of the check to use in the widget. + grouping (WidgetGrouping): + type (CheckStatusWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + group (str): Group reporting a single check.. [optional] # noqa: E501 + group_by ([str]): List of tag prefixes to group by in the case of a cluster check.. [optional] # noqa: E501 + tags ([str]): List of tags used to filter the groups reporting a cluster check.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.check = check + self.grouping = grouping + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -206,3 +301,8 @@ def __init__(self, check, grouping, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/check_status_widget_definition_type.py b/src/datadog_api_client/v1/model/check_status_widget_definition_type.py index 4719c03c3c..96bfb92a3a 100644 --- a/src/datadog_api_client/v1/model/check_status_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/check_status_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class CheckStatusWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """CheckStatusWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the check status widget.. if omitted defaults to "check_status", must be one of ["check_status", ] # noqa: E501 + + Keyword Args: + value (str): Type of the check status widget.. if omitted defaults to "check_status", must be one of ["check_status", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "check_status" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/content_encoding.py b/src/datadog_api_client/v1/model/content_encoding.py index fb91d6e2e2..5d3aa7b9c2 100644 --- a/src/datadog_api_client/v1/model/content_encoding.py +++ b/src/datadog_api_client/v1/model/content_encoding.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ContentEncoding(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ContentEncoding - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): HTTP header used to compress the media-type., must be one of ["gzip", "deflate", ] # noqa: E501 + + Keyword Args: + value (str): HTTP header used to compress the media-type., must be one of ["gzip", "deflate", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/creator.py b/src/datadog_api_client/v1/model/creator.py index 9f2c603f1e..0c43e5a87f 100644 --- a/src/datadog_api_client/v1/model/creator.py +++ b/src/datadog_api_client/v1/model/creator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class Creator(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Creator - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): Email of the creator.. [optional] # noqa: E501 + handle (str): Handle of the creator.. [optional] # noqa: E501 + name (str): Name of the creator.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard.py b/src/datadog_api_client/v1/model/dashboard.py index c522a79e4a..7810e2d560 100644 --- a/src/datadog_api_client/v1/model/dashboard.py +++ b/src/datadog_api_client/v1/model/dashboard.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -131,8 +133,112 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = { + "author_handle", # noqa: E501 + "created_at", # noqa: E501 + "id", # noqa: E501 + "modified_at", # noqa: E501 + "url", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, layout_type, title, widgets, *args, **kwargs): # noqa: E501 + """Dashboard - a model defined in OpenAPI + + Args: + layout_type (DashboardLayoutType): + title (str): Title of the dashboard. + widgets ([Widget]): List of widgets to display on the dashboard. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author_handle (str): Identifier of the dashboard author.. [optional] # noqa: E501 + created_at (datetime): Creation date of the dashboard.. [optional] # noqa: E501 + description (str, none_type): Description of the dashboard.. [optional] # noqa: E501 + id (str): ID of the dashboard.. [optional] # noqa: E501 + is_read_only (bool): Whether this dashboard is read-only. If True, only the author and admins can make changes to it.. [optional] if omitted the server will use the default value of False # noqa: E501 + modified_at (datetime): Modification date of the dashboard.. [optional] # noqa: E501 + notify_list ([str], none_type): List of handles of users to notify when changes are made to this dashboard.. [optional] # noqa: E501 + reflow_type (DashboardReflowType): [optional] # noqa: E501 + restricted_roles ([str]): A list of role identifiers. Only the author and users associated with at least one of these roles can edit this dashboard. Overrides the `is_read_only` property if both are present. **This feature is currently in beta.**. [optional] # noqa: E501 + template_variable_presets ([DashboardTemplateVariablePreset], none_type): Array of template variables saved views.. [optional] # noqa: E501 + template_variables ([DashboardTemplateVariable], none_type): List of template variables for this dashboard.. [optional] # noqa: E501 + url (str): The URL of the dashboard.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.layout_type = layout_type + self.title = title + self.widgets = widgets + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -235,3 +341,8 @@ def __init__(self, layout_type, title, widgets, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_bulk_action_data.py b/src/datadog_api_client/v1/model/dashboard_bulk_action_data.py index 0d5982afb7..dfdd043858 100644 --- a/src/datadog_api_client/v1/model/dashboard_bulk_action_data.py +++ b/src/datadog_api_client/v1/model/dashboard_bulk_action_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """DashboardBulkActionData - a model defined in OpenAPI + + Args: + id (str): Dashboard resource ID. + type (DashboardResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_bulk_action_data_list.py b/src/datadog_api_client/v1/model/dashboard_bulk_action_data_list.py index 6f25ae7b6b..22db396869 100644 --- a/src/datadog_api_client/v1/model/dashboard_bulk_action_data_list.py +++ b/src/datadog_api_client/v1/model/dashboard_bulk_action_data_list.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DashboardBulkActionDataList - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([DashboardBulkActionData]): List of dashboard bulk action request data objects.. # noqa: E501 + + Keyword Args: + value ([DashboardBulkActionData]): List of dashboard bulk action request data objects.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/dashboard_bulk_delete_request.py b/src/datadog_api_client/v1/model/dashboard_bulk_delete_request.py index 15a1c06666..220ff384a5 100644 --- a/src/datadog_api_client/v1/model/dashboard_bulk_delete_request.py +++ b/src/datadog_api_client/v1/model/dashboard_bulk_delete_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """DashboardBulkDeleteRequest - a model defined in OpenAPI + + Args: + data (DashboardBulkActionDataList): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_delete_response.py b/src/datadog_api_client/v1/model/dashboard_delete_response.py index 370a63f4d1..285d038825 100644 --- a/src/datadog_api_client/v1/model/dashboard_delete_response.py +++ b/src/datadog_api_client/v1/model/dashboard_delete_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardDeleteResponse(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "deleted_dashboard_id": "deleted_dashboard_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardDeleteResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_dashboard_id (str): ID of the deleted dashboard.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_layout_type.py b/src/datadog_api_client/v1/model/dashboard_layout_type.py index e80aff5051..1409494dac 100644 --- a/src/datadog_api_client/v1/model/dashboard_layout_type.py +++ b/src/datadog_api_client/v1/model/dashboard_layout_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardLayoutType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DashboardLayoutType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Layout type of the dashboard.., must be one of ["ordered", "free", ] # noqa: E501 + + Keyword Args: + value (str): Layout type of the dashboard.., must be one of ["ordered", "free", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/dashboard_list.py b/src/datadog_api_client/v1/model/dashboard_list.py index 00bbc2d5a8..7f41728ea5 100644 --- a/src/datadog_api_client/v1/model/dashboard_list.py +++ b/src/datadog_api_client/v1/model/dashboard_list.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,104 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "dashboard_count", # noqa: E501 + "id", # noqa: E501 + "is_favorite", # noqa: E501 + "modified", # noqa: E501 + "type", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """DashboardList - a model defined in OpenAPI + + Args: + name (str): The name of the dashboard list. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author (Creator): [optional] # noqa: E501 + created (datetime): Date of creation of the dashboard list.. [optional] # noqa: E501 + dashboard_count (int): The number of dashboards in the list.. [optional] # noqa: E501 + id (int): The ID of the dashboard list.. [optional] # noqa: E501 + is_favorite (bool): Whether or not the list is in the favorites.. [optional] # noqa: E501 + modified (datetime): Date of last edition of the dashboard list.. [optional] # noqa: E501 + type (str): The type of dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +290,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_list_delete_response.py b/src/datadog_api_client/v1/model/dashboard_list_delete_response.py index 5de953784a..4f0449ca99 100644 --- a/src/datadog_api_client/v1/model/dashboard_list_delete_response.py +++ b/src/datadog_api_client/v1/model/dashboard_list_delete_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardListDeleteResponse(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "deleted_dashboard_list_id": "deleted_dashboard_list_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListDeleteResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_dashboard_list_id (int): ID of the deleted dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_list_list_response.py b/src/datadog_api_client/v1/model/dashboard_list_list_response.py index 72b2138eda..fa2a0f6f56 100644 --- a/src/datadog_api_client/v1/model/dashboard_list_list_response.py +++ b/src/datadog_api_client/v1/model/dashboard_list_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboard_lists": "dashboard_lists", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboard_lists ([DashboardList]): List of all your dashboard lists.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_reflow_type.py b/src/datadog_api_client/v1/model/dashboard_reflow_type.py index a7c5ffec27..b529ce128f 100644 --- a/src/datadog_api_client/v1/model/dashboard_reflow_type.py +++ b/src/datadog_api_client/v1/model/dashboard_reflow_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardReflowType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DashboardReflowType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'. If set to 'fixed', the dashboard expects all widgets to have a layout, and if it's set to 'auto', widgets should not have layouts.., must be one of ["auto", "fixed", ] # noqa: E501 + + Keyword Args: + value (str): Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'. If set to 'fixed', the dashboard expects all widgets to have a layout, and if it's set to 'auto', widgets should not have layouts.., must be one of ["auto", "fixed", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/dashboard_resource_type.py b/src/datadog_api_client/v1/model/dashboard_resource_type.py index 7c0a0e23c4..077ef36772 100644 --- a/src/datadog_api_client/v1/model/dashboard_resource_type.py +++ b/src/datadog_api_client/v1/model/dashboard_resource_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardResourceType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DashboardResourceType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Dashboard resource type.. if omitted defaults to "dashboard", must be one of ["dashboard", ] # noqa: E501 + + Keyword Args: + value (str): Dashboard resource type.. if omitted defaults to "dashboard", must be one of ["dashboard", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "dashboard" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/dashboard_restore_request.py b/src/datadog_api_client/v1/model/dashboard_restore_request.py index c17d0d6e46..ba696b7ae8 100644 --- a/src/datadog_api_client/v1/model/dashboard_restore_request.py +++ b/src/datadog_api_client/v1/model/dashboard_restore_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """DashboardRestoreRequest - a model defined in OpenAPI + + Args: + data (DashboardBulkActionDataList): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_summary.py b/src/datadog_api_client/v1/model/dashboard_summary.py index 6fc29b9b70..5fd060d20b 100644 --- a/src/datadog_api_client/v1/model/dashboard_summary.py +++ b/src/datadog_api_client/v1/model/dashboard_summary.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboards": "dashboards", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardSummary - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboards ([DashboardSummaryDefinition]): List of dashboard definitions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_summary_definition.py b/src/datadog_api_client/v1/model/dashboard_summary_definition.py index d10e516dc5..feaaf48981 100644 --- a/src/datadog_api_client/v1/model/dashboard_summary_definition.py +++ b/src/datadog_api_client/v1/model/dashboard_summary_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,95 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardSummaryDefinition - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author_handle (str): Identifier of the dashboard author.. [optional] # noqa: E501 + created_at (datetime): Creation date of the dashboard.. [optional] # noqa: E501 + description (str): Description of the dashboard.. [optional] # noqa: E501 + id (str): Dashboard identifier.. [optional] # noqa: E501 + is_read_only (bool): Whether this dashboard is read-only. If True, only the author and admins can make changes to it.. [optional] # noqa: E501 + layout_type (DashboardLayoutType): [optional] # noqa: E501 + modified_at (datetime): Modification date of the dashboard.. [optional] # noqa: E501 + title (str): Title of the dashboard.. [optional] # noqa: E501 + url (str): URL of the dashboard.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +281,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_template_variable.py b/src/datadog_api_client/v1/model/dashboard_template_variable.py index a03a00a1eb..6aef604905 100644 --- a/src/datadog_api_client/v1/model/dashboard_template_variable.py +++ b/src/datadog_api_client/v1/model/dashboard_template_variable.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardTemplateVariable(ModelNormal): @@ -86,8 +88,92 @@ def discriminator(): "prefix": "prefix", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """DashboardTemplateVariable - a model defined in OpenAPI + + Args: + name (str): The name of the variable. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + default (str, none_type): The default value for the template variable on dashboard load.. [optional] # noqa: E501 + prefix (str, none_type): The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +262,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_template_variable_preset.py b/src/datadog_api_client/v1/model/dashboard_template_variable_preset.py index 1cae53e2f8..0edf172d84 100644 --- a/src/datadog_api_client/v1/model/dashboard_template_variable_preset.py +++ b/src/datadog_api_client/v1/model/dashboard_template_variable_preset.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "template_variables": "template_variables", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardTemplateVariablePreset - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): The name of the variable.. [optional] # noqa: E501 + template_variables ([DashboardTemplateVariablePresetValue]): List of variables.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/dashboard_template_variable_preset_value.py b/src/datadog_api_client/v1/model/dashboard_template_variable_preset_value.py index ac3c88b86c..b2406d11be 100644 --- a/src/datadog_api_client/v1/model/dashboard_template_variable_preset_value.py +++ b/src/datadog_api_client/v1/model/dashboard_template_variable_preset_value.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DashboardTemplateVariablePresetValue(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardTemplateVariablePresetValue - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): The name of the variable.. [optional] # noqa: E501 + value (str): The value of the template variable within the saved view.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/deleted_monitor.py b/src/datadog_api_client/v1/model/deleted_monitor.py index cbbad702ab..c800aedb2f 100644 --- a/src/datadog_api_client/v1/model/deleted_monitor.py +++ b/src/datadog_api_client/v1/model/deleted_monitor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DeletedMonitor(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "deleted_monitor_id": "deleted_monitor_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DeletedMonitor - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_monitor_id (int): ID of the deleted monitor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/distribution_widget_definition.py b/src/datadog_api_client/v1/model/distribution_widget_definition.py index ceeedcfcd7..42899f742b 100644 --- a/src/datadog_api_client/v1/model/distribution_widget_definition.py +++ b/src/datadog_api_client/v1/model/distribution_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -120,8 +122,101 @@ def discriminator(): "yaxis": "yaxis", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """DistributionWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([DistributionWidgetRequest]): Array of one request object to display in the widget. See the dedicated [Request JSON schema documentation](https://docs.datadoghq.com/dashboards/graphing_json/request_json) to learn how to build the `REQUEST_SCHEMA`. + type (DistributionWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + legend_size (str): (Deprecated) The widget legend was replaced by a tooltip and sidebar.. [optional] # noqa: E501 + markers ([WidgetMarker]): List of markers.. [optional] # noqa: E501 + show_legend (bool): (Deprecated) The widget legend was replaced by a tooltip and sidebar.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + xaxis (DistributionWidgetXAxis): [optional] # noqa: E501 + yaxis (DistributionWidgetYAxis): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -219,3 +314,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/distribution_widget_definition_type.py b/src/datadog_api_client/v1/model/distribution_widget_definition_type.py index 9d11b6a789..9f8971ead1 100644 --- a/src/datadog_api_client/v1/model/distribution_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/distribution_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DistributionWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DistributionWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the distribution widget.. if omitted defaults to "distribution", must be one of ["distribution", ] # noqa: E501 + + Keyword Args: + value (str): Type of the distribution widget.. if omitted defaults to "distribution", must be one of ["distribution", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "distribution" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/distribution_widget_request.py b/src/datadog_api_client/v1/model/distribution_widget_request.py index 4a67453f04..03a7bbbafb 100644 --- a/src/datadog_api_client/v1/model/distribution_widget_request.py +++ b/src/datadog_api_client/v1/model/distribution_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,96 @@ def discriminator(): "style": "style", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DistributionWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Widget query.. [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + style (WidgetStyle): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -199,3 +289,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/distribution_widget_x_axis.py b/src/datadog_api_client/v1/model/distribution_widget_x_axis.py index 6e856e2d4d..1df8643405 100644 --- a/src/datadog_api_client/v1/model/distribution_widget_x_axis.py +++ b/src/datadog_api_client/v1/model/distribution_widget_x_axis.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DistributionWidgetXAxis(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "scale": "scale", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DistributionWidgetXAxis - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_zero (bool): True includes zero.. [optional] # noqa: E501 + max (str): Specifies maximum value to show on the x-axis. It takes a number, percentile (p90 === 90th percentile), or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + min (str): Specifies minimum value to show on the x-axis. It takes a number, percentile (p90 === 90th percentile), or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + scale (str): Specifies the scale type. Possible values are `linear`.. [optional] if omitted the server will use the default value of "linear" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/distribution_widget_y_axis.py b/src/datadog_api_client/v1/model/distribution_widget_y_axis.py index 81a4aa42f4..b7f95e05d3 100644 --- a/src/datadog_api_client/v1/model/distribution_widget_y_axis.py +++ b/src/datadog_api_client/v1/model/distribution_widget_y_axis.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DistributionWidgetYAxis(ModelNormal): @@ -84,8 +86,91 @@ def discriminator(): "scale": "scale", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DistributionWidgetYAxis - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_zero (bool): True includes zero.. [optional] # noqa: E501 + label (str): The label of the axis to display on the graph.. [optional] # noqa: E501 + max (str): Specifies the maximum value to show on the y-axis. It takes a number, or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + min (str): Specifies minimum value to show on the y-axis. It takes a number, or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + scale (str): Specifies the scale type. Possible values are `linear` or `log`.. [optional] if omitted the server will use the default value of "linear" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/downtime.py b/src/datadog_api_client/v1/model/downtime.py index 51ac6f272e..3bb7f416d0 100644 --- a/src/datadog_api_client/v1/model/downtime.py +++ b/src/datadog_api_client/v1/model/downtime.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -142,8 +144,110 @@ def discriminator(): "updater_id": "updater_id", # noqa: E501 } + read_only_vars = { + "active", # noqa: E501 + "canceled", # noqa: E501 + "creator_id", # noqa: E501 + "downtime_type", # noqa: E501 + "id", # noqa: E501 + "updater_id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Downtime - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + active (bool): If a scheduled downtime currently exists.. [optional] # noqa: E501 + active_child (DowntimeChild): [optional] # noqa: E501 + canceled (int, none_type): If a scheduled downtime is canceled.. [optional] # noqa: E501 + creator_id (int): User ID of the downtime creator.. [optional] # noqa: E501 + disabled (bool): If a downtime has been disabled.. [optional] # noqa: E501 + downtime_type (int): `0` for a downtime applied on `*` or all, `1` when the downtime is only scoped to hosts, or `2` when the downtime is scoped to anything but hosts.. [optional] # noqa: E501 + end (int, none_type): POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.. [optional] # noqa: E501 + id (int): The downtime ID.. [optional] # noqa: E501 + message (str): A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same `@username` notation as events.. [optional] # noqa: E501 + monitor_id (int, none_type): A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.. [optional] # noqa: E501 + monitor_tags ([str]): A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, `service:postgres` **AND** `team:frontend`.. [optional] # noqa: E501 + parent_id (int, none_type): ID of the parent Downtime.. [optional] # noqa: E501 + recurrence (DowntimeRecurrence): [optional] # noqa: E501 + scope ([str]): The scope(s) to which the downtime applies. For example, `host:app2`. Provide multiple scopes as a comma-separated list like `env:dev,env:prod`. The resulting downtime applies to sources that matches ALL provided scopes (`env:dev` **AND** `env:prod`).. [optional] # noqa: E501 + start (int): POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.. [optional] # noqa: E501 + timezone (str): The timezone in which to display the downtime's start and end times in Datadog applications.. [optional] # noqa: E501 + updater_id (int, none_type): ID of the last user that updated the downtime.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -243,3 +347,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/downtime_child.py b/src/datadog_api_client/v1/model/downtime_child.py index c1c4e8f8d6..0b7810d498 100644 --- a/src/datadog_api_client/v1/model/downtime_child.py +++ b/src/datadog_api_client/v1/model/downtime_child.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -138,8 +140,109 @@ def discriminator(): "updater_id": "updater_id", # noqa: E501 } + read_only_vars = { + "active", # noqa: E501 + "canceled", # noqa: E501 + "creator_id", # noqa: E501 + "downtime_type", # noqa: E501 + "id", # noqa: E501 + "updater_id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DowntimeChild - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + active (bool): If a scheduled downtime currently exists.. [optional] # noqa: E501 + canceled (int, none_type): If a scheduled downtime is canceled.. [optional] # noqa: E501 + creator_id (int): User ID of the downtime creator.. [optional] # noqa: E501 + disabled (bool): If a downtime has been disabled.. [optional] # noqa: E501 + downtime_type (int): `0` for a downtime applied on `*` or all, `1` when the downtime is only scoped to hosts, or `2` when the downtime is scoped to anything but hosts.. [optional] # noqa: E501 + end (int, none_type): POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.. [optional] # noqa: E501 + id (int): The downtime ID.. [optional] # noqa: E501 + message (str): A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same `@username` notation as events.. [optional] # noqa: E501 + monitor_id (int, none_type): A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.. [optional] # noqa: E501 + monitor_tags ([str]): A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, `service:postgres` **AND** `team:frontend`.. [optional] # noqa: E501 + parent_id (int, none_type): ID of the parent Downtime.. [optional] # noqa: E501 + recurrence (DowntimeRecurrence): [optional] # noqa: E501 + scope ([str]): The scope(s) to which the downtime applies. For example, `host:app2`. Provide multiple scopes as a comma-separated list like `env:dev,env:prod`. The resulting downtime applies to sources that matches ALL provided scopes (`env:dev` **AND** `env:prod`).. [optional] # noqa: E501 + start (int): POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.. [optional] # noqa: E501 + timezone (str): The timezone in which to display the downtime's start and end times in Datadog applications.. [optional] # noqa: E501 + updater_id (int, none_type): ID of the last user that updated the downtime.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -238,3 +341,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/downtime_recurrence.py b/src/datadog_api_client/v1/model/downtime_recurrence.py index 8da3691fd4..2c4742e9d3 100644 --- a/src/datadog_api_client/v1/model/downtime_recurrence.py +++ b/src/datadog_api_client/v1/model/downtime_recurrence.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class DowntimeRecurrence(ModelNormal): @@ -99,8 +101,92 @@ def discriminator(): "week_days": "week_days", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DowntimeRecurrence - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + period (int): How often to repeat as an integer. For example, to repeat every 3 days, select a type of `days` and a period of `3`.. [optional] # noqa: E501 + rrule (str): The `RRULE` standard for defining recurring events (**requires to set \"type\" to rrule**) For example, to have a recurring event on the first day of each month, set the type to `rrule` and set the `FREQ` to `MONTHLY` and `BYMONTHDAY` to `1`. Most common `rrule` options from the [iCalendar Spec](https://tools.ietf.org/html/rfc5545) are supported. **Note**: Attributes specifying the duration in `RRULE` are not supported (for example, `DTSTART`, `DTEND`, `DURATION`). More examples available in this [downtime guide](https://docs.datadoghq.com/monitors/guide/supress-alert-with-downtimes/?tab=api). [optional] # noqa: E501 + type (str): The type of recurrence. Choose from `days`, `weeks`, `months`, `years`, `rrule`.. [optional] # noqa: E501 + until_date (int, none_type): The date at which the recurrence should end as a POSIX timestamp. `until_occurences` and `until_date` are mutually exclusive.. [optional] # noqa: E501 + until_occurrences (int, none_type): How many times the downtime is rescheduled. `until_occurences` and `until_date` are mutually exclusive.. [optional] # noqa: E501 + week_days ([str]): A list of week days to repeat on. Choose from `Mon`, `Tue`, `Wed`, `Thu`, `Fri`, `Sat` or `Sun`. Only applicable when type is weeks. First letter must be capitalized.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +275,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event.py b/src/datadog_api_client/v1/model/event.py index 727f46cf60..0810b44994 100644 --- a/src/datadog_api_client/v1/model/event.py +++ b/src/datadog_api_client/v1/model/event.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -114,8 +116,102 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + "payload", # noqa: E501 + "url", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Event - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + alert_type (EventAlertType): [optional] # noqa: E501 + date_happened (int): POSIX timestamp of the event. Must be sent as an integer (i.e. no quotes). Limited to events no older than 7 days.. [optional] # noqa: E501 + device_name (str): A device name.. [optional] # noqa: E501 + host (str): Host name to associate with the event. Any tags associated with the host are also applied to this event.. [optional] # noqa: E501 + id (int): Integer ID of the event.. [optional] # noqa: E501 + payload (str): Payload of the event.. [optional] # noqa: E501 + priority (EventPriority): [optional] # noqa: E501 + source_type_name (str): The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc. A complete list of source attribute values [available here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to the event.. [optional] # noqa: E501 + text (str): The body of the event. Limited to 4000 characters. The text supports markdown. To use markdown in the event text, start the text block with `%%% \\n` and end the text block with `\\n %%%`. Use `msg_text` with the Datadog Ruby library.. [optional] # noqa: E501 + title (str): The event title. Limited to 100 characters. Use `msg_title` with the Datadog Ruby library.. [optional] # noqa: E501 + url (str): URL of the event.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -210,3 +306,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_alert_type.py b/src/datadog_api_client/v1/model/event_alert_type.py index b86c84bd10..6b3bb51b86 100644 --- a/src/datadog_api_client/v1/model/event_alert_type.py +++ b/src/datadog_api_client/v1/model/event_alert_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class EventAlertType(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """EventAlertType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): If an alert event is enabled, set its type. For example, `error`, `warning`, `info`, `success`, `user_update`, `recommendation`, and `snapshot`.., must be one of ["error", "warning", "info", "success", "user_update", "recommendation", "snapshot", ] # noqa: E501 + + Keyword Args: + value (str): If an alert event is enabled, set its type. For example, `error`, `warning`, `info`, `success`, `user_update`, `recommendation`, and `snapshot`.., must be one of ["error", "warning", "info", "success", "user_update", "recommendation", "snapshot", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/event_create_request.py b/src/datadog_api_client/v1/model/event_create_request.py index 0c0791b326..749b222b04 100644 --- a/src/datadog_api_client/v1/model/event_create_request.py +++ b/src/datadog_api_client/v1/model/event_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -121,8 +123,108 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + "payload", # noqa: E501 + "url", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, text, title, *args, **kwargs): # noqa: E501 + """EventCreateRequest - a model defined in OpenAPI + + Args: + text (str): The body of the event. Limited to 4000 characters. The text supports markdown. To use markdown in the event text, start the text block with `%%% \\n` and end the text block with `\\n %%%`. Use `msg_text` with the Datadog Ruby library. + title (str): The event title. Limited to 100 characters. Use `msg_title` with the Datadog Ruby library. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregation_key (str): An arbitrary string to use for aggregation. Limited to 100 characters. If you specify a key, all events using that key are grouped together in the Event Stream.. [optional] # noqa: E501 + alert_type (EventAlertType): [optional] # noqa: E501 + date_happened (int): POSIX timestamp of the event. Must be sent as an integer (i.e. no quotes). Limited to events no older than 7 days.. [optional] # noqa: E501 + device_name (str): A device name.. [optional] # noqa: E501 + host (str): Host name to associate with the event. Any tags associated with the host are also applied to this event.. [optional] # noqa: E501 + id (int): Integer ID of the event.. [optional] # noqa: E501 + payload (str): Payload of the event.. [optional] # noqa: E501 + priority (EventPriority): [optional] # noqa: E501 + related_event_id (int): ID of the parent event. Must be sent as an integer (i.e. no quotes).. [optional] # noqa: E501 + source_type_name (str): The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc. A complete list of source attribute values [available here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to the event.. [optional] # noqa: E501 + url (str): URL of the event.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.text = text + self.title = title + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -223,3 +325,8 @@ def __init__(self, text, title, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_create_response.py b/src/datadog_api_client/v1/model/event_create_response.py index 650b5caba2..0503cab6a5 100644 --- a/src/datadog_api_client/v1/model/event_create_response.py +++ b/src/datadog_api_client/v1/model/event_create_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -118,8 +120,104 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + "payload", # noqa: E501 + "url", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """EventCreateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + alert_type (EventAlertType): [optional] # noqa: E501 + date_happened (int): POSIX timestamp of the event. Must be sent as an integer (i.e. no quotes). Limited to events no older than 7 days.. [optional] # noqa: E501 + device_name (str): A device name.. [optional] # noqa: E501 + host (str): Host name to associate with the event. Any tags associated with the host are also applied to this event.. [optional] # noqa: E501 + id (int): Integer ID of the event.. [optional] # noqa: E501 + payload (str): Payload of the event.. [optional] # noqa: E501 + priority (EventPriority): [optional] # noqa: E501 + related_event_id (int): ID of the parent event. Must be sent as an integer (i.e. no quotes).. [optional] # noqa: E501 + source_type_name (str): The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc. A complete list of source attribute values [available here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).. [optional] # noqa: E501 + status (str): A status.. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to the event.. [optional] # noqa: E501 + text (str): The body of the event. Limited to 4000 characters. The text supports markdown. Use `msg_text` with the Datadog Ruby library.. [optional] # noqa: E501 + title (str): The event title. Limited to 100 characters. Use `msg_title` with the Datadog Ruby library.. [optional] # noqa: E501 + url (str): URL of the event.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -216,3 +314,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_list_response.py b/src/datadog_api_client/v1/model/event_list_response.py index 89c0f02bdc..06ed626556 100644 --- a/src/datadog_api_client/v1/model/event_list_response.py +++ b/src/datadog_api_client/v1/model/event_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """EventListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + events ([Event]): An array of events.. [optional] # noqa: E501 + status (str): A status.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_priority.py b/src/datadog_api_client/v1/model/event_priority.py index c18240f518..03a40f8f48 100644 --- a/src/datadog_api_client/v1/model/event_priority.py +++ b/src/datadog_api_client/v1/model/event_priority.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class EventPriority(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """EventPriority - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The priority of the event. For example, `normal` or `low`.., must be one of ["normal", "low", ] # noqa: E501 + + Keyword Args: + value (str): The priority of the event. For example, `normal` or `low`.., must be one of ["normal", "low", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/event_query_definition.py b/src/datadog_api_client/v1/model/event_query_definition.py index 83c18fa6de..e2bb3be502 100644 --- a/src/datadog_api_client/v1/model/event_query_definition.py +++ b/src/datadog_api_client/v1/model/event_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class EventQueryDefinition(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "tags_execution": "tags_execution", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, search, tags_execution, *args, **kwargs): # noqa: E501 + """EventQueryDefinition - a model defined in OpenAPI + + Args: + search (str): The query being made on the event. + tags_execution (str): The execution method for multi-value filters. Can be either and or or. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.search = search + self.tags_execution = tags_execution + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, search, tags_execution, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_response.py b/src/datadog_api_client/v1/model/event_response.py index 73cc20e27f..cc7413b420 100644 --- a/src/datadog_api_client/v1/model/event_response.py +++ b/src/datadog_api_client/v1/model/event_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """EventResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + event (Event): [optional] # noqa: E501 + status (str): A status.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_stream_widget_definition.py b/src/datadog_api_client/v1/model/event_stream_widget_definition.py index 7f8aadd0d0..b6b0418df8 100644 --- a/src/datadog_api_client/v1/model/event_stream_widget_definition.py +++ b/src/datadog_api_client/v1/model/event_stream_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,98 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, type, *args, **kwargs): # noqa: E501 + """EventStreamWidgetDefinition - a model defined in OpenAPI + + Args: + query (str): Query to filter the event stream with. + type (EventStreamWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + event_size (WidgetEventSize): [optional] # noqa: E501 + tags_execution (str): The execution method for multi-value filters. Can be either and or or.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -199,3 +291,8 @@ def __init__(self, query, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_stream_widget_definition_type.py b/src/datadog_api_client/v1/model/event_stream_widget_definition_type.py index c929544785..6dbdfbccfe 100644 --- a/src/datadog_api_client/v1/model/event_stream_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/event_stream_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class EventStreamWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """EventStreamWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the event stream widget.. if omitted defaults to "event_stream", must be one of ["event_stream", ] # noqa: E501 + + Keyword Args: + value (str): Type of the event stream widget.. if omitted defaults to "event_stream", must be one of ["event_stream", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "event_stream" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/event_timeline_widget_definition.py b/src/datadog_api_client/v1/model/event_timeline_widget_definition.py index 0cfb6d6224..aa1c720ac5 100644 --- a/src/datadog_api_client/v1/model/event_timeline_widget_definition.py +++ b/src/datadog_api_client/v1/model/event_timeline_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,97 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, type, *args, **kwargs): # noqa: E501 + """EventTimelineWidgetDefinition - a model defined in OpenAPI + + Args: + query (str): Query to filter the event timeline with. + type (EventTimelineWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tags_execution (str): The execution method for multi-value filters. Can be either and or or.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -194,3 +285,8 @@ def __init__(self, query, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/event_timeline_widget_definition_type.py b/src/datadog_api_client/v1/model/event_timeline_widget_definition_type.py index b21dc34923..92ad1db007 100644 --- a/src/datadog_api_client/v1/model/event_timeline_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/event_timeline_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class EventTimelineWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """EventTimelineWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the event timeline widget.. if omitted defaults to "event_timeline", must be one of ["event_timeline", ] # noqa: E501 + + Keyword Args: + value (str): Type of the event timeline widget.. if omitted defaults to "event_timeline", must be one of ["event_timeline", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "event_timeline" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_aggregation.py b/src/datadog_api_client/v1/model/formula_and_function_event_aggregation.py index 4e91262e09..caab1f3992 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_aggregation.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_aggregation.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionEventAggregation(ModelSimple): @@ -85,6 +87,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -188,3 +192,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionEventAggregation - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Aggregation methods for event platform queries.., must be one of ["count", "cardinality", "median", "pc75", "pc90", "pc95", "pc98", "pc99", "sum", "min", "max", "avg", ] # noqa: E501 + + Keyword Args: + value (str): Aggregation methods for event platform queries.., must be one of ["count", "cardinality", "median", "pc75", "pc90", "pc95", "pc98", "pc99", "sum", "min", "max", "avg", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition.py b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition.py index 9c375d6a03..e8e2bfb9f3 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,97 @@ def discriminator(): "search": "search", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, compute, data_source, name, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionEventQueryDefinition - a model defined in OpenAPI + + Args: + compute (FormulaAndFunctionEventQueryDefinitionCompute): + data_source (FormulaAndFunctionEventsDataSource): + name (str): Name of the query for use in formulas. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + group_by ([FormulaAndFunctionEventQueryGroupBy]): Group by options.. [optional] # noqa: E501 + indexes ([str]): An array of index names to query in the stream. Omit or use `[]` to query all indexes at once.. [optional] # noqa: E501 + search (FormulaAndFunctionEventQueryDefinitionSearch): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.compute = compute + self.data_source = data_source + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +291,8 @@ def __init__(self, compute, data_source, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_compute.py b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_compute.py index 5c55d6160e..e27ffd1ae2 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_compute.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_compute.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "metric": "metric", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionEventQueryDefinitionCompute - a model defined in OpenAPI + + Args: + aggregation (FormulaAndFunctionEventAggregation): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + interval (int): A time interval in milliseconds.. [optional] # noqa: E501 + metric (str): Measurable attribute to compute.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation = aggregation + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, aggregation, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_search.py b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_search.py index 45c3e950c6..c843775c4b 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_search.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_query_definition_search.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionEventQueryDefinitionSearch(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionEventQueryDefinitionSearch - a model defined in OpenAPI + + Args: + query (str): Events search string. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by.py b/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by.py index 030ad8be34..b8fcd557bc 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,92 @@ def discriminator(): "sort": "sort", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, facet, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionEventQueryGroupBy - a model defined in OpenAPI + + Args: + facet (str): Event facet. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + limit (int): Number of groups to return.. [optional] # noqa: E501 + sort (FormulaAndFunctionEventQueryGroupBySort): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.facet = facet + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +265,8 @@ def __init__(self, facet, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by_sort.py b/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by_sort.py index e4f6533ddd..2f428f1da2 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by_sort.py +++ b/src/datadog_api_client/v1/model/formula_and_function_event_query_group_by_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,92 @@ def discriminator(): "order": "order", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionEventQueryGroupBySort - a model defined in OpenAPI + + Args: + aggregation (FormulaAndFunctionEventAggregation): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + metric (str): Metric used for sorting group by results.. [optional] # noqa: E501 + order (QuerySortOrder): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation = aggregation + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +265,8 @@ def __init__(self, aggregation, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_events_data_source.py b/src/datadog_api_client/v1/model/formula_and_function_events_data_source.py index 9750ace1d2..3c249cbcf5 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_events_data_source.py +++ b/src/datadog_api_client/v1/model/formula_and_function_events_data_source.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionEventsDataSource(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionEventsDataSource - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Data source for event platform-based queries.., must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", ] # noqa: E501 + + Keyword Args: + value (str): Data source for event platform-based queries.., must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_metric_aggregation.py b/src/datadog_api_client/v1/model/formula_and_function_metric_aggregation.py index 07a011a885..8458f74ff8 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_metric_aggregation.py +++ b/src/datadog_api_client/v1/model/formula_and_function_metric_aggregation.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionMetricAggregation(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionMetricAggregation - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The aggregation methods available for metrics queries.., must be one of ["avg", "min", "max", "sum", "last", "area", "l2norm", ] # noqa: E501 + + Keyword Args: + value (str): The aggregation methods available for metrics queries.., must be one of ["avg", "min", "max", "sum", "last", "area", "l2norm", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_metric_data_source.py b/src/datadog_api_client/v1/model/formula_and_function_metric_data_source.py index 87c54d6596..8bbfda49cc 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_metric_data_source.py +++ b/src/datadog_api_client/v1/model/formula_and_function_metric_data_source.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionMetricDataSource(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionMetricDataSource - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Data source for metrics queries.. if omitted defaults to "metrics", must be one of ["metrics", ] # noqa: E501 + + Keyword Args: + value (str): Data source for metrics queries.. if omitted defaults to "metrics", must be one of ["metrics", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "metrics" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_metric_query_definition.py b/src/datadog_api_client/v1/model/formula_and_function_metric_query_definition.py index e308ca62d5..f8988190d4 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_metric_query_definition.py +++ b/src/datadog_api_client/v1/model/formula_and_function_metric_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "aggregator": "aggregator", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data_source, name, query, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionMetricQueryDefinition - a model defined in OpenAPI + + Args: + data_source (FormulaAndFunctionMetricDataSource): + name (str): Name of the query for use in formulas. + query (str): Metrics query definition. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (FormulaAndFunctionMetricAggregation): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data_source = data_source + self.name = name + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, data_source, name, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_process_query_data_source.py b/src/datadog_api_client/v1/model/formula_and_function_process_query_data_source.py index 90ee0de99a..fe9905f181 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_process_query_data_source.py +++ b/src/datadog_api_client/v1/model/formula_and_function_process_query_data_source.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionProcessQueryDataSource(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionProcessQueryDataSource - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Data sources that rely on the process backend.., must be one of ["process", "container", ] # noqa: E501 + + Keyword Args: + value (str): Data sources that rely on the process backend.., must be one of ["process", "container", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/formula_and_function_process_query_definition.py b/src/datadog_api_client/v1/model/formula_and_function_process_query_definition.py index 7735d3f45f..7ddcdcde88 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_process_query_definition.py +++ b/src/datadog_api_client/v1/model/formula_and_function_process_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,100 @@ def discriminator(): "text_filter": "text_filter", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data_source, metric, name, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionProcessQueryDefinition - a model defined in OpenAPI + + Args: + data_source (FormulaAndFunctionProcessQueryDataSource): + metric (str): Process metric name. + name (str): Name of query for use in formulas. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (FormulaAndFunctionMetricAggregation): [optional] # noqa: E501 + is_normalized_cpu (bool): Whether to normalize the CPU percentages.. [optional] # noqa: E501 + limit (int): Number of hits to return.. [optional] # noqa: E501 + sort (QuerySortOrder): [optional] # noqa: E501 + tag_filters ([str]): An array of tags to filter by.. [optional] # noqa: E501 + text_filter (str): Text to use as filter.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data_source = data_source + self.metric = metric + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +297,8 @@ def __init__(self, data_source, metric, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/formula_and_function_query_definition.py b/src/datadog_api_client/v1/model/formula_and_function_query_definition.py index 10154f8062..bf965fd51c 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_query_definition.py +++ b/src/datadog_api_client/v1/model/formula_and_function_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -86,24 +88,7 @@ class FormulaAndFunctionQueryDefinition(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -125,6 +110,101 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """FormulaAndFunctionQueryDefinition - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (FormulaAndFunctionMetricAggregation): [optional] # noqa: E501 + group_by ([FormulaAndFunctionEventQueryGroupBy]): Group by options.. [optional] # noqa: E501 + indexes ([str]): An array of index names to query in the stream. Omit or use `[]` to query all indexes at once.. [optional] # noqa: E501 + search (FormulaAndFunctionEventQueryDefinitionSearch): [optional] # noqa: E501 + is_normalized_cpu (bool): Whether to normalize the CPU percentages.. [optional] # noqa: E501 + limit (int): Number of hits to return.. [optional] # noqa: E501 + sort (QuerySortOrder): [optional] # noqa: E501 + tag_filters ([str]): An array of tags to filter by.. [optional] # noqa: E501 + text_filter (str): Text to use as filter.. [optional] # noqa: E501 + data_source (FormulaAndFunctionProcessQueryDataSource): [optional] # noqa: E501 + name (str): Name of query for use in formulas.. [optional] # noqa: E501 + query (str): Metrics query definition.. [optional] # noqa: E501 + compute (FormulaAndFunctionEventQueryDefinitionCompute): [optional] # noqa: E501 + metric (str): Process metric name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -221,28 +301,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/formula_and_function_response_format.py b/src/datadog_api_client/v1/model/formula_and_function_response_format.py index a57ec05175..3631f7df6d 100644 --- a/src/datadog_api_client/v1/model/formula_and_function_response_format.py +++ b/src/datadog_api_client/v1/model/formula_and_function_response_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FormulaAndFunctionResponseFormat(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FormulaAndFunctionResponseFormat - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Timeseries or Scalar response. **This feature is currently in beta.**., must be one of ["timeseries", "scalar", ] # noqa: E501 + + Keyword Args: + value (str): Timeseries or Scalar response. **This feature is currently in beta.**., must be one of ["timeseries", "scalar", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/free_text_widget_definition.py b/src/datadog_api_client/v1/model/free_text_widget_definition.py index b01df9dd9a..81abb74197 100644 --- a/src/datadog_api_client/v1/model/free_text_widget_definition.py +++ b/src/datadog_api_client/v1/model/free_text_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,95 @@ def discriminator(): "text_align": "text_align", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, text, type, *args, **kwargs): # noqa: E501 + """FreeTextWidgetDefinition - a model defined in OpenAPI + + Args: + text (str): Text to display. + type (FreeTextWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + color (str): Color of the text.. [optional] # noqa: E501 + font_size (str): Size of the text.. [optional] # noqa: E501 + text_align (WidgetTextAlign): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.text = text + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +275,8 @@ def __init__(self, text, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/free_text_widget_definition_type.py b/src/datadog_api_client/v1/model/free_text_widget_definition_type.py index 66160db252..20c112204f 100644 --- a/src/datadog_api_client/v1/model/free_text_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/free_text_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class FreeTextWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """FreeTextWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the free text widget.. if omitted defaults to "free_text", must be one of ["free_text", ] # noqa: E501 + + Keyword Args: + value (str): Type of the free text widget.. if omitted defaults to "free_text", must be one of ["free_text", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "free_text" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/gcp_account.py b/src/datadog_api_client/v1/model/gcp_account.py index 6b6e76affc..79f409db7a 100644 --- a/src/datadog_api_client/v1/model/gcp_account.py +++ b/src/datadog_api_client/v1/model/gcp_account.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GCPAccount(ModelNormal): @@ -100,8 +102,99 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """GCPAccount - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + auth_provider_x509_cert_url (str): Should be `https://www.googleapis.com/oauth2/v1/certs`.. [optional] # noqa: E501 + auth_uri (str): Should be `https://accounts.google.com/o/oauth2/auth`.. [optional] # noqa: E501 + automute (bool): Silence monitors for expected GCE instance shutdowns.. [optional] # noqa: E501 + client_email (str): Your email found in your JSON service account key.. [optional] # noqa: E501 + client_id (str): Your ID found in your JSON service account key.. [optional] # noqa: E501 + client_x509_cert_url (str): Should be `https://www.googleapis.com/robot/v1/metadata/x509/` where `` is the email found in your JSON service account key.. [optional] # noqa: E501 + errors ([str]): An array of errors.. [optional] # noqa: E501 + host_filters (str): Limit the GCE instances that are pulled into Datadog by using tags. Only hosts that match one of the defined tags are imported into Datadog.. [optional] # noqa: E501 + private_key (str): Your private key name found in your JSON service account key.. [optional] # noqa: E501 + private_key_id (str): Your private key ID found in your JSON service account key.. [optional] # noqa: E501 + project_id (str): Your Google Cloud project ID found in your JSON service account key.. [optional] # noqa: E501 + token_uri (str): Should be `https://accounts.google.com/o/oauth2/token`.. [optional] # noqa: E501 + type (str): The value for service_account found in your JSON service account key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -197,3 +290,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/gcp_account_list_response.py b/src/datadog_api_client/v1/model/gcp_account_list_response.py index 3044b81f90..01853bf26d 100644 --- a/src/datadog_api_client/v1/model/gcp_account_list_response.py +++ b/src/datadog_api_client/v1/model/gcp_account_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """GCPAccountListResponse - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([GCPAccount]): Array of GCP account responses.. # noqa: E501 + + Keyword Args: + value ([GCPAccount]): Array of GCP account responses.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/geomap_widget_definition.py b/src/datadog_api_client/v1/model/geomap_widget_definition.py index 31153fe93e..6b7566deb6 100644 --- a/src/datadog_api_client/v1/model/geomap_widget_definition.py +++ b/src/datadog_api_client/v1/model/geomap_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -116,8 +118,101 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, style, type, view, *args, **kwargs): # noqa: E501 + """GeomapWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([GeomapWidgetRequest]): Array of one request object to display in the widget. The request must contain a `group-by` tag whose value is a country ISO code. See the [Request JSON schema documentation](https://docs.datadoghq.com/dashboards/graphing_json/request_json) for information about building the `REQUEST_SCHEMA`. + style (GeomapWidgetDefinitionStyle): + type (GeomapWidgetDefinitionType): + view (GeomapWidgetDefinitionView): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): A list of custom links.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): The title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): The size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.style = style + self.type = type + self.view = view + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -215,3 +310,8 @@ def __init__(self, requests, style, type, view, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/geomap_widget_definition_style.py b/src/datadog_api_client/v1/model/geomap_widget_definition_style.py index 8f089d3716..d1bbeaad76 100644 --- a/src/datadog_api_client/v1/model/geomap_widget_definition_style.py +++ b/src/datadog_api_client/v1/model/geomap_widget_definition_style.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GeomapWidgetDefinitionStyle(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "palette_flip": "palette_flip", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, palette, palette_flip, *args, **kwargs): # noqa: E501 + """GeomapWidgetDefinitionStyle - a model defined in OpenAPI + + Args: + palette (str): The color palette to apply to the widget. + palette_flip (bool): Whether to flip the palette tones. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.palette = palette + self.palette_flip = palette_flip + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, palette, palette_flip, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/geomap_widget_definition_type.py b/src/datadog_api_client/v1/model/geomap_widget_definition_type.py index fcc2ef1793..7d0fe11bbf 100644 --- a/src/datadog_api_client/v1/model/geomap_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/geomap_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GeomapWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """GeomapWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the geomap widget.. if omitted defaults to "geomap", must be one of ["geomap", ] # noqa: E501 + + Keyword Args: + value (str): Type of the geomap widget.. if omitted defaults to "geomap", must be one of ["geomap", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "geomap" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/geomap_widget_definition_view.py b/src/datadog_api_client/v1/model/geomap_widget_definition_view.py index c57e9dba0c..fed5ea0bfb 100644 --- a/src/datadog_api_client/v1/model/geomap_widget_definition_view.py +++ b/src/datadog_api_client/v1/model/geomap_widget_definition_view.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GeomapWidgetDefinitionView(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "focus": "focus", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, focus, *args, **kwargs): # noqa: E501 + """GeomapWidgetDefinitionView - a model defined in OpenAPI + + Args: + focus (str): The 2-letter ISO code of a country to focus the map on. Or `WORLD`. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.focus = focus + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, focus, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/geomap_widget_request.py b/src/datadog_api_client/v1/model/geomap_widget_request.py index 185c0cb396..a840eb4419 100644 --- a/src/datadog_api_client/v1/model/geomap_widget_request.py +++ b/src/datadog_api_client/v1/model/geomap_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,93 @@ def discriminator(): "security_query": "security_query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """GeomapWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + formulas ([WidgetFormula]): List of formulas that operate on queries. **This feature is currently in beta.**. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): The widget metrics query.. [optional] # noqa: E501 + queries ([FormulaAndFunctionQueryDefinition]): List of queries that can be returned directly or used in formulas. **This feature is currently in beta.**. [optional] # noqa: E501 + response_format (FormulaAndFunctionResponseFormat): [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +279,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/graph_snapshot.py b/src/datadog_api_client/v1/model/graph_snapshot.py index a6583a8ee5..1004c3087a 100644 --- a/src/datadog_api_client/v1/model/graph_snapshot.py +++ b/src/datadog_api_client/v1/model/graph_snapshot.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GraphSnapshot(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "snapshot_url": "snapshot_url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """GraphSnapshot - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_def (str): A JSON document defining the graph. `graph_def` can be used instead of `metric_query`. The JSON document uses the [grammar defined here](https://docs.datadoghq.com/graphing/graphing_json/#grammar) and should be formatted to a single line then URL encoded.. [optional] # noqa: E501 + metric_query (str): The metric query. One of `metric_query` or `graph_def` is required.. [optional] # noqa: E501 + snapshot_url (str): URL of your [graph snapshot](https://docs.datadoghq.com/metrics/explorer/#snapshot).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/group_widget_definition.py b/src/datadog_api_client/v1/model/group_widget_definition.py index 146f923431..f8bad239f6 100644 --- a/src/datadog_api_client/v1/model/group_widget_definition.py +++ b/src/datadog_api_client/v1/model/group_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,99 @@ def discriminator(): "title_align": "title_align", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, layout_type, type, widgets, *args, **kwargs): # noqa: E501 + """GroupWidgetDefinition - a model defined in OpenAPI + + Args: + layout_type (WidgetLayoutType): + type (GroupWidgetDefinitionType): + widgets ([Widget]): List of widget groups. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + background_color (str): Background color of the group title.. [optional] # noqa: E501 + banner_img (str): URL of image to display as a banner for the group.. [optional] # noqa: E501 + show_title (bool): Whether to show the title or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.layout_type = layout_type + self.type = type + self.widgets = widgets + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +293,8 @@ def __init__(self, layout_type, type, widgets, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/group_widget_definition_type.py b/src/datadog_api_client/v1/model/group_widget_definition_type.py index 993c762d11..64245f1304 100644 --- a/src/datadog_api_client/v1/model/group_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/group_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class GroupWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """GroupWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the group widget.. if omitted defaults to "group", must be one of ["group", ] # noqa: E501 + + Keyword Args: + value (str): Type of the group widget.. if omitted defaults to "group", must be one of ["group", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "group" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/heat_map_widget_definition.py b/src/datadog_api_client/v1/model/heat_map_widget_definition.py index 9ab6a44c91..4939d6ecce 100644 --- a/src/datadog_api_client/v1/model/heat_map_widget_definition.py +++ b/src/datadog_api_client/v1/model/heat_map_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -120,8 +122,101 @@ def discriminator(): "yaxis": "yaxis", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """HeatMapWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([HeatMapWidgetRequest]): List of widget types. + type (HeatMapWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + events ([WidgetEvent]): List of widget events.. [optional] # noqa: E501 + legend_size (str): Available legend sizes for a widget. Should be one of \"0\", \"2\", \"4\", \"8\", \"16\", or \"auto\".. [optional] # noqa: E501 + show_legend (bool): Whether or not to display the legend on this widget.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + yaxis (WidgetAxis): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -219,3 +314,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/heat_map_widget_definition_type.py b/src/datadog_api_client/v1/model/heat_map_widget_definition_type.py index 3a37f5765c..50e4b120f1 100644 --- a/src/datadog_api_client/v1/model/heat_map_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/heat_map_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HeatMapWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """HeatMapWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the heat map widget.. if omitted defaults to "heatmap", must be one of ["heatmap", ] # noqa: E501 + + Keyword Args: + value (str): Type of the heat map widget.. if omitted defaults to "heatmap", must be one of ["heatmap", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "heatmap" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/heat_map_widget_request.py b/src/datadog_api_client/v1/model/heat_map_widget_request.py index 03e783f7eb..cb3c531303 100644 --- a/src/datadog_api_client/v1/model/heat_map_widget_request.py +++ b/src/datadog_api_client/v1/model/heat_map_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,96 @@ def discriminator(): "style": "style", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HeatMapWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + event_query (EventQueryDefinition): [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Widget query.. [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + style (WidgetStyle): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -201,3 +291,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host.py b/src/datadog_api_client/v1/model/host.py index da7deab046..ae60da9361 100644 --- a/src/datadog_api_client/v1/model/host.py +++ b/src/datadog_api_client/v1/model/host.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,100 @@ def discriminator(): "up": "up", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Host - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aliases ([str]): Host aliases collected by Datadog.. [optional] # noqa: E501 + apps ([str]): The Datadog integrations reporting metrics for the host.. [optional] # noqa: E501 + aws_name (str): AWS name of your host.. [optional] # noqa: E501 + host_name (str): The host name.. [optional] # noqa: E501 + id (int): The host ID.. [optional] # noqa: E501 + is_muted (bool): If a host is muted or unmuted.. [optional] # noqa: E501 + last_reported_time (int): Last time the host reported a metric data point.. [optional] # noqa: E501 + meta (HostMeta): [optional] # noqa: E501 + metrics (HostMetrics): [optional] # noqa: E501 + mute_timeout (int): Timeout of the mute applied to your host.. [optional] # noqa: E501 + name (str): The host name.. [optional] # noqa: E501 + sources ([str]): Source or cloud provider associated with your host.. [optional] # noqa: E501 + tags_by_source ({str: ([str],)}): List of tags for each source (AWS, Datadog Agent, Chef..).. [optional] # noqa: E501 + up (bool): Displays UP when the expected metrics are received and displays `???` if no metrics are received.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -209,3 +303,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_list_response.py b/src/datadog_api_client/v1/model/host_list_response.py index 72b9d00637..676dfd3238 100644 --- a/src/datadog_api_client/v1/model/host_list_response.py +++ b/src/datadog_api_client/v1/model/host_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,89 @@ def discriminator(): "total_returned": "total_returned", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + host_list ([Host]): Array of hosts.. [optional] # noqa: E501 + total_matching (int): Number of host matching the query.. [optional] # noqa: E501 + total_returned (int): Number of host returned.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_map_request.py b/src/datadog_api_client/v1/model/host_map_request.py index 4fa25c34e4..b16c9c3095 100644 --- a/src/datadog_api_client/v1/model/host_map_request.py +++ b/src/datadog_api_client/v1/model/host_map_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,95 @@ def discriminator(): "security_query": "security_query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMapRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Query definition.. [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -194,3 +283,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_map_widget_definition.py b/src/datadog_api_client/v1/model/host_map_widget_definition.py index 01f5e47403..68b0c07417 100644 --- a/src/datadog_api_client/v1/model/host_map_widget_definition.py +++ b/src/datadog_api_client/v1/model/host_map_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -117,8 +119,103 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """HostMapWidgetDefinition - a model defined in OpenAPI + + Args: + requests (HostMapWidgetDefinitionRequests): + type (HostMapWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + group ([str]): List of tag prefixes to group by.. [optional] # noqa: E501 + no_group_hosts (bool): Whether to show the hosts that don’t fit in a group.. [optional] # noqa: E501 + no_metric_hosts (bool): Whether to show the hosts with no metrics.. [optional] # noqa: E501 + node_type (WidgetNodeType): [optional] # noqa: E501 + notes (str): Notes on the title.. [optional] # noqa: E501 + scope ([str]): List of tags used to filter the map.. [optional] # noqa: E501 + style (HostMapWidgetDefinitionStyle): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -218,3 +315,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_map_widget_definition_requests.py b/src/datadog_api_client/v1/model/host_map_widget_definition_requests.py index db50d9d3dd..2032fb1138 100644 --- a/src/datadog_api_client/v1/model/host_map_widget_definition_requests.py +++ b/src/datadog_api_client/v1/model/host_map_widget_definition_requests.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "size": "size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMapWidgetDefinitionRequests - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + fill (HostMapRequest): [optional] # noqa: E501 + size (HostMapRequest): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_map_widget_definition_style.py b/src/datadog_api_client/v1/model/host_map_widget_definition_style.py index de0ac36fd4..184edaa170 100644 --- a/src/datadog_api_client/v1/model/host_map_widget_definition_style.py +++ b/src/datadog_api_client/v1/model/host_map_widget_definition_style.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMapWidgetDefinitionStyle(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "palette_flip": "palette_flip", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMapWidgetDefinitionStyle - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + fill_max (str): Max value to use to color the map.. [optional] # noqa: E501 + fill_min (str): Min value to use to color the map.. [optional] # noqa: E501 + palette (str): Color palette to apply to the widget.. [optional] # noqa: E501 + palette_flip (bool): Whether to flip the palette tones.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_map_widget_definition_type.py b/src/datadog_api_client/v1/model/host_map_widget_definition_type.py index aa2907b810..c2a395684d 100644 --- a/src/datadog_api_client/v1/model/host_map_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/host_map_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMapWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """HostMapWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the host map widget.. if omitted defaults to "hostmap", must be one of ["hostmap", ] # noqa: E501 + + Keyword Args: + value (str): Type of the host map widget.. if omitted defaults to "hostmap", must be one of ["hostmap", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "hostmap" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/host_meta.py b/src/datadog_api_client/v1/model/host_meta.py index 1258c47827..2bd201c398 100644 --- a/src/datadog_api_client/v1/model/host_meta.py +++ b/src/datadog_api_client/v1/model/host_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMeta(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "nix_v": "nixV", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + nix_v ([str]): Array of Unix versions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_metrics.py b/src/datadog_api_client/v1/model/host_metrics.py index f015dc721f..760c867ad2 100644 --- a/src/datadog_api_client/v1/model/host_metrics.py +++ b/src/datadog_api_client/v1/model/host_metrics.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMetrics(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "load": "load", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMetrics - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cpu (float): The percent of CPU used (everything but idle).. [optional] # noqa: E501 + iowait (float): The percent of CPU spent waiting on the IO (not reported for all platforms).. [optional] # noqa: E501 + load (float): The system load over the last 15 minutes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_mute_response.py b/src/datadog_api_client/v1/model/host_mute_response.py index 0e3b0c884a..e0bdbc7d73 100644 --- a/src/datadog_api_client/v1/model/host_mute_response.py +++ b/src/datadog_api_client/v1/model/host_mute_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMuteResponse(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMuteResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + action (str): Action applied to the hosts.. [optional] # noqa: E501 + end (int): POSIX timestamp in seconds when the host is unmuted.. [optional] # noqa: E501 + hostname (str): The host name.. [optional] # noqa: E501 + message (str): Message associated with the mute.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_mute_settings.py b/src/datadog_api_client/v1/model/host_mute_settings.py index ebe9f2fcf1..2a8035405c 100644 --- a/src/datadog_api_client/v1/model/host_mute_settings.py +++ b/src/datadog_api_client/v1/model/host_mute_settings.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostMuteSettings(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "override": "override", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostMuteSettings - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + end (int): POSIX timestamp in seconds when the host is unmuted. If omitted, the host remains muted until explicitly unmuted.. [optional] # noqa: E501 + message (str): Message to associate with the muting of this host.. [optional] # noqa: E501 + override (bool): If true and the host is already muted, replaces existing host mute settings.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_tags.py b/src/datadog_api_client/v1/model/host_tags.py index fb6ed1a613..77429303e4 100644 --- a/src/datadog_api_client/v1/model/host_tags.py +++ b/src/datadog_api_client/v1/model/host_tags.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostTags(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostTags - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + host (str): Your host name.. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to the host.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/host_totals.py b/src/datadog_api_client/v1/model/host_totals.py index 737a3faaa3..7bbd60e7b2 100644 --- a/src/datadog_api_client/v1/model/host_totals.py +++ b/src/datadog_api_client/v1/model/host_totals.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HostTotals(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "total_up": "total_up", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HostTotals - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_active (int): Total number of active host (UP and ???) reporting to Datadog.. [optional] # noqa: E501 + total_up (int): Number of host that are UP and reporting to Datadog.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/http_log.py b/src/datadog_api_client/v1/model/http_log.py index 6f58eb9d92..8c8050c8bf 100644 --- a/src/datadog_api_client/v1/model/http_log.py +++ b/src/datadog_api_client/v1/model/http_log.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """HTTPLog - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([HTTPLogItem]): Structured log message.. # noqa: E501 + + Keyword Args: + value ([HTTPLogItem]): Structured log message.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/http_log_error.py b/src/datadog_api_client/v1/model/http_log_error.py index 7b5ba4f21e..c7d5d0a599 100644 --- a/src/datadog_api_client/v1/model/http_log_error.py +++ b/src/datadog_api_client/v1/model/http_log_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HTTPLogError(ModelNormal): @@ -82,8 +84,92 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, code, message, *args, **kwargs): # noqa: E501 + """HTTPLogError - a model defined in OpenAPI + + Args: + code (int): Error code. + message (str): Error message. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.code = code + self.message = message + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +258,8 @@ def __init__(self, code, message, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/http_log_item.py b/src/datadog_api_client/v1/model/http_log_item.py index 2925f126c5..c35e3bbeeb 100644 --- a/src/datadog_api_client/v1/model/http_log_item.py +++ b/src/datadog_api_client/v1/model/http_log_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HTTPLogItem(ModelNormal): @@ -84,8 +86,91 @@ def discriminator(): "service": "service", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """HTTPLogItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + ddsource (str): The integration name associated with your log: the technology from which the log originated. When it matches an integration name, Datadog automatically installs the corresponding parsers and facets. See [reserved attributes](https://docs.datadoghq.com/logs/log_collection/#reserved-attributes).. [optional] # noqa: E501 + ddtags (str): Tags associated with your logs.. [optional] # noqa: E501 + hostname (str): The name of the originating host of the log.. [optional] # noqa: E501 + message (str): The message [reserved attribute](https://docs.datadoghq.com/logs/log_collection/#reserved-attributes) of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry. That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.. [optional] # noqa: E501 + service (str): The name of the application or service generating the log events. It is used to switch from Logs to APM, so make sure you define the same value when you use both products. See [reserved attributes](https://docs.datadoghq.com/logs/log_collection/#reserved-attributes).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/http_method.py b/src/datadog_api_client/v1/model/http_method.py index c5c451fbfc..d5b0ad95cd 100644 --- a/src/datadog_api_client/v1/model/http_method.py +++ b/src/datadog_api_client/v1/model/http_method.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class HTTPMethod(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """HTTPMethod - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The HTTP method.., must be one of ["GET", "POST", "PATCH", "PUT", "DELETE", "HEAD", "OPTIONS", ] # noqa: E501 + + Keyword Args: + value (str): The HTTP method.., must be one of ["GET", "POST", "PATCH", "PUT", "DELETE", "HEAD", "OPTIONS", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/i_frame_widget_definition.py b/src/datadog_api_client/v1/model/i_frame_widget_definition.py index 6cff8f3176..fb65cd718b 100644 --- a/src/datadog_api_client/v1/model/i_frame_widget_definition.py +++ b/src/datadog_api_client/v1/model/i_frame_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, url, *args, **kwargs): # noqa: E501 + """IFrameWidgetDefinition - a model defined in OpenAPI + + Args: + type (IFrameWidgetDefinitionType): + url (str): URL of the iframe. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + self.url = url + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, type, url, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/i_frame_widget_definition_type.py b/src/datadog_api_client/v1/model/i_frame_widget_definition_type.py index 26b45c868d..007944f619 100644 --- a/src/datadog_api_client/v1/model/i_frame_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/i_frame_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IFrameWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IFrameWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the iframe widget.. if omitted defaults to "iframe", must be one of ["iframe", ] # noqa: E501 + + Keyword Args: + value (str): Type of the iframe widget.. if omitted defaults to "iframe", must be one of ["iframe", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "iframe" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/idp_form_data.py b/src/datadog_api_client/v1/model/idp_form_data.py index e0fed3612b..ff5ae83746 100644 --- a/src/datadog_api_client/v1/model/idp_form_data.py +++ b/src/datadog_api_client/v1/model/idp_form_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IdpFormData(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "idp_file": "idp_file", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, idp_file, *args, **kwargs): # noqa: E501 + """IdpFormData - a model defined in OpenAPI + + Args: + idp_file (file_type): The path to the XML metadata file you wish to upload. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.idp_file = idp_file + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, idp_file, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/idp_response.py b/src/datadog_api_client/v1/model/idp_response.py index 306374cb9b..8d983e5b6f 100644 --- a/src/datadog_api_client/v1/model/idp_response.py +++ b/src/datadog_api_client/v1/model/idp_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IdpResponse(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, message, *args, **kwargs): # noqa: E501 + """IdpResponse - a model defined in OpenAPI + + Args: + message (str): Identity provider response. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.message = message + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, message, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/image_widget_definition.py b/src/datadog_api_client/v1/model/image_widget_definition.py index 308f493e4a..d40839bebc 100644 --- a/src/datadog_api_client/v1/model/image_widget_definition.py +++ b/src/datadog_api_client/v1/model/image_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,99 @@ def discriminator(): "vertical_align": "vertical_align", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, url, *args, **kwargs): # noqa: E501 + """ImageWidgetDefinition - a model defined in OpenAPI + + Args: + type (ImageWidgetDefinitionType): + url (str): URL of the image. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + has_background (bool): Whether to display a background or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + has_border (bool): Whether to display a border or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + horizontal_align (WidgetHorizontalAlign): [optional] # noqa: E501 + margin (WidgetMargin): [optional] # noqa: E501 + sizing (WidgetImageSizing): [optional] # noqa: E501 + url_dark_theme (str): URL of the image in dark mode.. [optional] # noqa: E501 + vertical_align (WidgetVerticalAlign): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + self.url = url + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -204,3 +297,8 @@ def __init__(self, type, url, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/image_widget_definition_type.py b/src/datadog_api_client/v1/model/image_widget_definition_type.py index 72f2e5f892..87f75ea427 100644 --- a/src/datadog_api_client/v1/model/image_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/image_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ImageWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ImageWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the image widget.. if omitted defaults to "image", must be one of ["image", ] # noqa: E501 + + Keyword Args: + value (str): Type of the image widget.. if omitted defaults to "image", must be one of ["image", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "image" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/intake_payload_accepted.py b/src/datadog_api_client/v1/model/intake_payload_accepted.py index 41cb1f731e..f274f26718 100644 --- a/src/datadog_api_client/v1/model/intake_payload_accepted.py +++ b/src/datadog_api_client/v1/model/intake_payload_accepted.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IntakePayloadAccepted(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IntakePayloadAccepted - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (str): The status of the intake payload.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_agents.py b/src/datadog_api_client/v1/model/ip_prefixes_agents.py index 35e475ac4a..ca3fbd85e0 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_agents.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_agents.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesAgents(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesAgents - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_api.py b/src/datadog_api_client/v1/model/ip_prefixes_api.py index 5e8d7e6e16..7ac1b86bc9 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_api.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_api.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesAPI(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesAPI - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_apm.py b/src/datadog_api_client/v1/model/ip_prefixes_apm.py index cca9d0b97e..d5d560ef1a 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_apm.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_apm.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesAPM(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesAPM - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_logs.py b/src/datadog_api_client/v1/model/ip_prefixes_logs.py index ba55c88634..2e29da12b1 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_logs.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_logs.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesLogs(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesLogs - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_process.py b/src/datadog_api_client/v1/model/ip_prefixes_process.py index 0f963dd4e4..602f968629 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_process.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_process.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesProcess(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesProcess - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_synthetics.py b/src/datadog_api_client/v1/model/ip_prefixes_synthetics.py index d72aae478c..f9c6a547a1 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_synthetics.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_synthetics.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesSynthetics(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "prefixes_ipv6_by_location": "prefixes_ipv6_by_location", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesSynthetics - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv4_by_location ({str: ([str],)}): List of IPv4 prefixes by location.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + prefixes_ipv6_by_location ({str: ([str],)}): List of IPv6 prefixes by location.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_prefixes_webhooks.py b/src/datadog_api_client/v1/model/ip_prefixes_webhooks.py index 8bae9751a7..38ecb24c92 100644 --- a/src/datadog_api_client/v1/model/ip_prefixes_webhooks.py +++ b/src/datadog_api_client/v1/model/ip_prefixes_webhooks.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class IPPrefixesWebhooks(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "prefixes_ipv6": "prefixes_ipv6", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPPrefixesWebhooks - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + prefixes_ipv4 ([str]): List of IPv4 prefixes.. [optional] # noqa: E501 + prefixes_ipv6 ([str]): List of IPv6 prefixes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/ip_ranges.py b/src/datadog_api_client/v1/model/ip_ranges.py index 013f668a45..9bb144dffb 100644 --- a/src/datadog_api_client/v1/model/ip_ranges.py +++ b/src/datadog_api_client/v1/model/ip_ranges.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,95 @@ def discriminator(): "webhooks": "webhooks", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IPRanges - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agents (IPPrefixesAgents): [optional] # noqa: E501 + api (IPPrefixesAPI): [optional] # noqa: E501 + apm (IPPrefixesAPM): [optional] # noqa: E501 + logs (IPPrefixesLogs): [optional] # noqa: E501 + modified (str): Date when last updated, in the form `YYYY-MM-DD-hh-mm-ss`.. [optional] # noqa: E501 + process (IPPrefixesProcess): [optional] # noqa: E501 + synthetics (IPPrefixesSynthetics): [optional] # noqa: E501 + version (int): Version of the IP list.. [optional] # noqa: E501 + webhooks (IPPrefixesWebhooks): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -204,3 +293,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/list_stream_column.py b/src/datadog_api_client/v1/model/list_stream_column.py index f2a278416c..6f2f84b8a8 100644 --- a/src/datadog_api_client/v1/model/list_stream_column.py +++ b/src/datadog_api_client/v1/model/list_stream_column.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "width": "width", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, field, width, *args, **kwargs): # noqa: E501 + """ListStreamColumn - a model defined in OpenAPI + + Args: + field (str): Widget column field. + width (ListStreamColumnWidth): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.field = field + self.width = width + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, field, width, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/list_stream_column_width.py b/src/datadog_api_client/v1/model/list_stream_column_width.py index 6b5ddf4b37..09a52690b3 100644 --- a/src/datadog_api_client/v1/model/list_stream_column_width.py +++ b/src/datadog_api_client/v1/model/list_stream_column_width.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ListStreamColumnWidth(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ListStreamColumnWidth - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Widget column width.., must be one of ["auto", "compact", "full", ] # noqa: E501 + + Keyword Args: + value (str): Widget column width.., must be one of ["auto", "compact", "full", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/list_stream_query.py b/src/datadog_api_client/v1/model/list_stream_query.py index 25b23e823f..c9ab3c2baa 100644 --- a/src/datadog_api_client/v1/model/list_stream_query.py +++ b/src/datadog_api_client/v1/model/list_stream_query.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,93 @@ def discriminator(): "indexes": "indexes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data_source, query_string, *args, **kwargs): # noqa: E501 + """ListStreamQuery - a model defined in OpenAPI + + Args: + data_source (ListStreamSource): + query_string (str): Widget query. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + indexes ([str]): List of indexes.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data_source = data_source + self.query_string = query_string + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +265,8 @@ def __init__(self, data_source, query_string, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/list_stream_response_format.py b/src/datadog_api_client/v1/model/list_stream_response_format.py index 029646102a..8a6a0c716d 100644 --- a/src/datadog_api_client/v1/model/list_stream_response_format.py +++ b/src/datadog_api_client/v1/model/list_stream_response_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ListStreamResponseFormat(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ListStreamResponseFormat - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Widget response format.. if omitted defaults to "event_list", must be one of ["event_list", ] # noqa: E501 + + Keyword Args: + value (str): Widget response format.. if omitted defaults to "event_list", must be one of ["event_list", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "event_list" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/list_stream_source.py b/src/datadog_api_client/v1/model/list_stream_source.py index 88114b6bbd..4e96aed12e 100644 --- a/src/datadog_api_client/v1/model/list_stream_source.py +++ b/src/datadog_api_client/v1/model/list_stream_source.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ListStreamSource(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ListStreamSource - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Source from which to query items to display in the stream.. if omitted defaults to "issue_stream", must be one of ["issue_stream", "logs_stream", ] # noqa: E501 + + Keyword Args: + value (str): Source from which to query items to display in the stream.. if omitted defaults to "issue_stream", must be one of ["issue_stream", "logs_stream", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "issue_stream" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/list_stream_widget_definition.py b/src/datadog_api_client/v1/model/list_stream_widget_definition.py index 258d4914a7..dfb3516d58 100644 --- a/src/datadog_api_client/v1/model/list_stream_widget_definition.py +++ b/src/datadog_api_client/v1/model/list_stream_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -108,8 +110,98 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """ListStreamWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([ListStreamWidgetRequest]): Request payload used to query items. + type (ListStreamWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + legend_size (str): Available legend sizes for a widget. Should be one of \"0\", \"2\", \"4\", \"8\", \"16\", or \"auto\".. [optional] # noqa: E501 + show_legend (bool): Whether or not to display the legend on this widget.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -204,3 +296,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/list_stream_widget_definition_type.py b/src/datadog_api_client/v1/model/list_stream_widget_definition_type.py index bb66b071d5..492f50e749 100644 --- a/src/datadog_api_client/v1/model/list_stream_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/list_stream_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ListStreamWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ListStreamWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the list stream widget.. if omitted defaults to "list_stream", must be one of ["list_stream", ] # noqa: E501 + + Keyword Args: + value (str): Type of the list stream widget.. if omitted defaults to "list_stream", must be one of ["list_stream", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "list_stream" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/list_stream_widget_request.py b/src/datadog_api_client/v1/model/list_stream_widget_request.py index 80f074baa9..500ee84b12 100644 --- a/src/datadog_api_client/v1/model/list_stream_widget_request.py +++ b/src/datadog_api_client/v1/model/list_stream_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,94 @@ def discriminator(): "response_format": "response_format", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, columns, query, response_format, *args, **kwargs): # noqa: E501 + """ListStreamWidgetRequest - a model defined in OpenAPI + + Args: + columns ([ListStreamColumn]): Widget columns. + query (ListStreamQuery): + response_format (ListStreamResponseFormat): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.columns = columns + self.query = query + self.response_format = response_format + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +271,8 @@ def __init__(self, columns, query, response_format, *args, **kwargs): # noqa: E # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log.py b/src/datadog_api_client/v1/model/log.py index d80b6be649..541f01c826 100644 --- a/src/datadog_api_client/v1/model/log.py +++ b/src/datadog_api_client/v1/model/log.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "id": "id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Log - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + content (LogContent): [optional] # noqa: E501 + id (str): Unique ID of the Log.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_content.py b/src/datadog_api_client/v1/model/log_content.py index 1789aae86e..442ac033ec 100644 --- a/src/datadog_api_client/v1/model/log_content.py +++ b/src/datadog_api_client/v1/model/log_content.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogContent(ModelNormal): @@ -86,8 +88,92 @@ def discriminator(): "timestamp": "timestamp", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogContent - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): JSON object of attributes from your log.. [optional] # noqa: E501 + host (str): Name of the machine from where the logs are being sent.. [optional] # noqa: E501 + message (str): The message [reserved attribute](https://docs.datadoghq.com/logs/log_collection/#reserved-attributes) of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry. That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.. [optional] # noqa: E501 + service (str): The name of the application or service generating the log events. It is used to switch from Logs to APM, so make sure you define the same value when you use both products.. [optional] # noqa: E501 + tags ([bool, date, datetime, dict, float, int, list, str, none_type]): Array of tags associated with your log.. [optional] # noqa: E501 + timestamp (datetime): Timestamp of your log.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +262,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_query_definition.py b/src/datadog_api_client/v1/model/log_query_definition.py index 056a16d183..6a0c183b39 100644 --- a/src/datadog_api_client/v1/model/log_query_definition.py +++ b/src/datadog_api_client/v1/model/log_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,91 @@ def discriminator(): "search": "search", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogQueryDefinition - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + compute (LogsQueryCompute): [optional] # noqa: E501 + group_by ([LogQueryDefinitionGroupBy]): List of tag prefixes to group by in the case of a cluster check.. [optional] # noqa: E501 + index (str): A coma separated-list of index names. Use \"*\" query all indexes at once. [Multiple Indexes](https://docs.datadoghq.com/logs/indexes/#multiple-indexes). [optional] # noqa: E501 + multi_compute ([LogsQueryCompute]): This field is mutually exclusive with `compute`.. [optional] # noqa: E501 + search (LogQueryDefinitionSearch): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +269,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_query_definition_group_by.py b/src/datadog_api_client/v1/model/log_query_definition_group_by.py index 1f5eae6226..612340202b 100644 --- a/src/datadog_api_client/v1/model/log_query_definition_group_by.py +++ b/src/datadog_api_client/v1/model/log_query_definition_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "sort": "sort", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, facet, *args, **kwargs): # noqa: E501 + """LogQueryDefinitionGroupBy - a model defined in OpenAPI + + Args: + facet (str): Facet name. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + limit (int): Maximum number of items in the group.. [optional] # noqa: E501 + sort (LogQueryDefinitionGroupBySort): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.facet = facet + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, facet, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_query_definition_group_by_sort.py b/src/datadog_api_client/v1/model/log_query_definition_group_by_sort.py index ef56caef5f..a44bba7c19 100644 --- a/src/datadog_api_client/v1/model/log_query_definition_group_by_sort.py +++ b/src/datadog_api_client/v1/model/log_query_definition_group_by_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,93 @@ def discriminator(): "facet": "facet", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation, order, *args, **kwargs): # noqa: E501 + """LogQueryDefinitionGroupBySort - a model defined in OpenAPI + + Args: + aggregation (str): The aggregation method. + order (WidgetSort): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + facet (str): Facet name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation = aggregation + self.order = order + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +265,8 @@ def __init__(self, aggregation, order, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_query_definition_search.py b/src/datadog_api_client/v1/model/log_query_definition_search.py index 5593104220..fab1579e0c 100644 --- a/src/datadog_api_client/v1/model/log_query_definition_search.py +++ b/src/datadog_api_client/v1/model/log_query_definition_search.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogQueryDefinitionSearch(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, *args, **kwargs): # noqa: E501 + """LogQueryDefinitionSearch - a model defined in OpenAPI + + Args: + query (str): Search value to apply. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_stream_widget_definition.py b/src/datadog_api_client/v1/model/log_stream_widget_definition.py index 2027520d7d..66278d4418 100644 --- a/src/datadog_api_client/v1/model/log_stream_widget_definition.py +++ b/src/datadog_api_client/v1/model/log_stream_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -115,8 +117,102 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogStreamWidgetDefinition - a model defined in OpenAPI + + Args: + type (LogStreamWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + columns ([str]): Which columns to display on the widget.. [optional] # noqa: E501 + indexes ([str]): An array of index names to query in the stream. Use [] to query all indexes at once.. [optional] # noqa: E501 + logset (str): ID of the log set to use.. [optional] # noqa: E501 + message_display (WidgetMessageDisplay): [optional] # noqa: E501 + query (str): Query to filter the log stream with.. [optional] # noqa: E501 + show_date_column (bool): Whether to show the date column or not. [optional] # noqa: E501 + show_message_column (bool): Whether to show the message column or not. [optional] # noqa: E501 + sort (WidgetFieldSort): [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -215,3 +311,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/log_stream_widget_definition_type.py b/src/datadog_api_client/v1/model/log_stream_widget_definition_type.py index f5e01d0ac2..cad7cd1971 100644 --- a/src/datadog_api_client/v1/model/log_stream_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/log_stream_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogStreamWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogStreamWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the log stream widget.. if omitted defaults to "log_stream", must be one of ["log_stream", ] # noqa: E501 + + Keyword Args: + value (str): Type of the log stream widget.. if omitted defaults to "log_stream", must be one of ["log_stream", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "log_stream" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_api_error.py b/src/datadog_api_client/v1/model/logs_api_error.py index fdb3ad4a22..be3537f965 100644 --- a/src/datadog_api_client/v1/model/logs_api_error.py +++ b/src/datadog_api_client/v1/model/logs_api_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsAPIError(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAPIError - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + code (str): Code identifying the error. [optional] # noqa: E501 + details ([LogsAPIError]): Additional error details. [optional] # noqa: E501 + message (str): Error message. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_api_error_response.py b/src/datadog_api_client/v1/model/logs_api_error_response.py index a5118a6d60..5e4ce70e38 100644 --- a/src/datadog_api_client/v1/model/logs_api_error_response.py +++ b/src/datadog_api_client/v1/model/logs_api_error_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "error": "error", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAPIErrorResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (LogsAPIError): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_arithmetic_processor.py b/src/datadog_api_client/v1/model/logs_arithmetic_processor.py index 906807daff..484a193464 100644 --- a/src/datadog_api_client/v1/model/logs_arithmetic_processor.py +++ b/src/datadog_api_client/v1/model/logs_arithmetic_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,97 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, expression, target, type, *args, **kwargs): # noqa: E501 + """LogsArithmeticProcessor - a model defined in OpenAPI + + Args: + expression (str): Arithmetic operation between one or more log attributes. + target (str): Name of the attribute that contains the result of the arithmetic operation. + type (LogsArithmeticProcessorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + is_replace_missing (bool): If `true`, it replaces all missing attributes of expression by `0`, `false` skip the operation if an attribute is missing.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.expression = expression + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +279,8 @@ def __init__(self, expression, target, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_arithmetic_processor_type.py b/src/datadog_api_client/v1/model/logs_arithmetic_processor_type.py index 686538cac5..6a54226001 100644 --- a/src/datadog_api_client/v1/model/logs_arithmetic_processor_type.py +++ b/src/datadog_api_client/v1/model/logs_arithmetic_processor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsArithmeticProcessorType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArithmeticProcessorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs arithmetic processor.. if omitted defaults to "arithmetic-processor", must be one of ["arithmetic-processor", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs arithmetic processor.. if omitted defaults to "arithmetic-processor", must be one of ["arithmetic-processor", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "arithmetic-processor" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_attribute_remapper.py b/src/datadog_api_client/v1/model/logs_attribute_remapper.py index e496b14863..13df5cec19 100644 --- a/src/datadog_api_client/v1/model/logs_attribute_remapper.py +++ b/src/datadog_api_client/v1/model/logs_attribute_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,101 @@ def discriminator(): "target_type": "target_type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, sources, target, type, *args, **kwargs): # noqa: E501 + """LogsAttributeRemapper - a model defined in OpenAPI + + Args: + sources ([str]): Array of source attributes. + target (str): Final attribute or tag name to remap the sources to. + type (LogsAttributeRemapperType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + override_on_conflict (bool): Override or not the target element if already set,. [optional] if omitted the server will use the default value of False # noqa: E501 + preserve_source (bool): Remove or preserve the remapped source element.. [optional] if omitted the server will use the default value of False # noqa: E501 + source_type (str): Defines if the sources are from log `attribute` or `tag`.. [optional] if omitted the server will use the default value of "attribute" # noqa: E501 + target_format (TargetFormatType): [optional] # noqa: E501 + target_type (str): Defines if the final attribute or tag name is from log `attribute` or `tag`.. [optional] if omitted the server will use the default value of "attribute" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -202,3 +297,8 @@ def __init__(self, sources, target, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_attribute_remapper_type.py b/src/datadog_api_client/v1/model/logs_attribute_remapper_type.py index 2149bc13cc..34b44b2c4c 100644 --- a/src/datadog_api_client/v1/model/logs_attribute_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_attribute_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsAttributeRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsAttributeRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs attribute remapper.. if omitted defaults to "attribute-remapper", must be one of ["attribute-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs attribute remapper.. if omitted defaults to "attribute-remapper", must be one of ["attribute-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "attribute-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_by_retention.py b/src/datadog_api_client/v1/model/logs_by_retention.py index 951306e11d..db90424319 100644 --- a/src/datadog_api_client/v1/model/logs_by_retention.py +++ b/src/datadog_api_client/v1/model/logs_by_retention.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "usage_by_month": "usage_by_month", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsByRetention - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + orgs (LogsByRetentionOrgs): [optional] # noqa: E501 + usage ([LogsRetentionAggSumUsage]): Aggregated index logs usage for each retention period with usage.. [optional] # noqa: E501 + usage_by_month (LogsByRetentionMonthlyUsage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_by_retention_monthly_usage.py b/src/datadog_api_client/v1/model/logs_by_retention_monthly_usage.py index db3ec973ff..f3b53ddf84 100644 --- a/src/datadog_api_client/v1/model/logs_by_retention_monthly_usage.py +++ b/src/datadog_api_client/v1/model/logs_by_retention_monthly_usage.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsByRetentionMonthlyUsage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + date (str): The month for the usage.. [optional] # noqa: E501 + usage ([LogsRetentionSumUsage]): Indexed logs usage for each active retention for the month.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_by_retention_org_usage.py b/src/datadog_api_client/v1/model/logs_by_retention_org_usage.py index 57d5eb8a1b..3be405431b 100644 --- a/src/datadog_api_client/v1/model/logs_by_retention_org_usage.py +++ b/src/datadog_api_client/v1/model/logs_by_retention_org_usage.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsByRetentionOrgUsage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([LogsRetentionSumUsage]): Indexed logs usage for each active retention for the organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_by_retention_orgs.py b/src/datadog_api_client/v1/model/logs_by_retention_orgs.py index ac621b5e22..22c0857a69 100644 --- a/src/datadog_api_client/v1/model/logs_by_retention_orgs.py +++ b/src/datadog_api_client/v1/model/logs_by_retention_orgs.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsByRetentionOrgs - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([LogsByRetentionOrgUsage]): Indexed logs usage summary for each organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_category_processor.py b/src/datadog_api_client/v1/model/logs_category_processor.py index c87bccc88c..934ffb1b74 100644 --- a/src/datadog_api_client/v1/model/logs_category_processor.py +++ b/src/datadog_api_client/v1/model/logs_category_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,96 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, categories, target, type, *args, **kwargs): # noqa: E501 + """LogsCategoryProcessor - a model defined in OpenAPI + + Args: + categories ([LogsCategoryProcessorCategory]): Array of filters to match or not a log and their corresponding `name`to assign a custom value to the log. + target (str): Name of the target attribute which value is defined by the matching category. + type (LogsCategoryProcessorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.categories = categories + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,3 +277,8 @@ def __init__(self, categories, target, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_category_processor_category.py b/src/datadog_api_client/v1/model/logs_category_processor_category.py index 2fc07135fa..e6167e2db5 100644 --- a/src/datadog_api_client/v1/model/logs_category_processor_category.py +++ b/src/datadog_api_client/v1/model/logs_category_processor_category.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsCategoryProcessorCategory - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsFilter): [optional] # noqa: E501 + name (str): Value to assign to the target attribute.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_category_processor_type.py b/src/datadog_api_client/v1/model/logs_category_processor_type.py index ad590eb9d6..8b168fcbfd 100644 --- a/src/datadog_api_client/v1/model/logs_category_processor_type.py +++ b/src/datadog_api_client/v1/model/logs_category_processor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsCategoryProcessorType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsCategoryProcessorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs category processor.. if omitted defaults to "category-processor", must be one of ["category-processor", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs category processor.. if omitted defaults to "category-processor", must be one of ["category-processor", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "category-processor" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_date_remapper.py b/src/datadog_api_client/v1/model/logs_date_remapper.py index 9b320f832b..2760aa3d1c 100644 --- a/src/datadog_api_client/v1/model/logs_date_remapper.py +++ b/src/datadog_api_client/v1/model/logs_date_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, sources, type, *args, **kwargs): # noqa: E501 + """LogsDateRemapper - a model defined in OpenAPI + + Args: + sources ([str]): Array of source attributes. + type (LogsDateRemapperType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, sources, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_date_remapper_type.py b/src/datadog_api_client/v1/model/logs_date_remapper_type.py index 7878c7ea1a..d282d8399b 100644 --- a/src/datadog_api_client/v1/model/logs_date_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_date_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsDateRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsDateRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs date remapper.. if omitted defaults to "date-remapper", must be one of ["date-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs date remapper.. if omitted defaults to "date-remapper", must be one of ["date-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "date-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_exclusion.py b/src/datadog_api_client/v1/model/logs_exclusion.py index 40c7891d30..26650a38d3 100644 --- a/src/datadog_api_client/v1/model/logs_exclusion.py +++ b/src/datadog_api_client/v1/model/logs_exclusion.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "is_enabled": "is_enabled", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """LogsExclusion - a model defined in OpenAPI + + Args: + name (str): Name of the index exclusion filter. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsExclusionFilter): [optional] # noqa: E501 + is_enabled (bool): Whether or not the exclusion filter is active.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_exclusion_filter.py b/src/datadog_api_client/v1/model/logs_exclusion_filter.py index 5e58498b23..db4d53c041 100644 --- a/src/datadog_api_client/v1/model/logs_exclusion_filter.py +++ b/src/datadog_api_client/v1/model/logs_exclusion_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsExclusionFilter(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, sample_rate, *args, **kwargs): # noqa: E501 + """LogsExclusionFilter - a model defined in OpenAPI + + Args: + sample_rate (float): Sample rate to apply to logs going through this exclusion filter, a value of 1 will exclude all logs matching the query. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + query (str): Default query is `*`, meaning all logs flowing in the index would be excluded. Scope down exclusion filter to only a subset of logs with a log query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sample_rate = sample_rate + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +252,8 @@ def __init__(self, sample_rate, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_filter.py b/src/datadog_api_client/v1/model/logs_filter.py index 47f5dfc2fe..bd6993b4ef 100644 --- a/src/datadog_api_client/v1/model/logs_filter.py +++ b/src/datadog_api_client/v1/model/logs_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsFilter(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + query (str): The filter query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_geo_ip_parser.py b/src/datadog_api_client/v1/model/logs_geo_ip_parser.py index d9b641ede1..c4a5055d13 100644 --- a/src/datadog_api_client/v1/model/logs_geo_ip_parser.py +++ b/src/datadog_api_client/v1/model/logs_geo_ip_parser.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,98 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsGeoIPParser - a model defined in OpenAPI + + Args: + type (LogsGeoIPParserType): + + Keyword Args: + sources ([str]): Array of source attributes.. defaults to ["network.client.ip"] # noqa: E501 + target (str): Name of the parent attribute that contains all the extracted details from the `sources`.. defaults to "network.client.geoip" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + sources = kwargs.get("sources", ["network.client.ip"]) + target = kwargs.get("target", "network.client.geoip") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,3 +279,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_geo_ip_parser_type.py b/src/datadog_api_client/v1/model/logs_geo_ip_parser_type.py index fd7e8b5817..2ba8ce5ecb 100644 --- a/src/datadog_api_client/v1/model/logs_geo_ip_parser_type.py +++ b/src/datadog_api_client/v1/model/logs_geo_ip_parser_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsGeoIPParserType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsGeoIPParserType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of GeoIP parser.. if omitted defaults to "geo-ip-parser", must be one of ["geo-ip-parser", ] # noqa: E501 + + Keyword Args: + value (str): Type of GeoIP parser.. if omitted defaults to "geo-ip-parser", must be one of ["geo-ip-parser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "geo-ip-parser" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_grok_parser.py b/src/datadog_api_client/v1/model/logs_grok_parser.py index 93fe145f03..e7df40b2e5 100644 --- a/src/datadog_api_client/v1/model/logs_grok_parser.py +++ b/src/datadog_api_client/v1/model/logs_grok_parser.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,98 @@ def discriminator(): "samples": "samples", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, grok, type, *args, **kwargs): # noqa: E501 + """LogsGrokParser - a model defined in OpenAPI + + Args: + grok (LogsGrokParserRules): + type (LogsGrokParserType): + + Keyword Args: + source (str): Name of the log attribute to parse.. defaults to "message" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + samples ([str]): List of sample logs to test this grok parser.. [optional] # noqa: E501 + """ + + source = kwargs.get("source", "message") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.grok = grok + self.source = source + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -195,3 +287,8 @@ def __init__(self, grok, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_grok_parser_rules.py b/src/datadog_api_client/v1/model/logs_grok_parser_rules.py index 8cb3a8915e..0fbc8987b3 100644 --- a/src/datadog_api_client/v1/model/logs_grok_parser_rules.py +++ b/src/datadog_api_client/v1/model/logs_grok_parser_rules.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsGrokParserRules(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "support_rules": "support_rules", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, match_rules, *args, **kwargs): # noqa: E501 + """LogsGrokParserRules - a model defined in OpenAPI + + Args: + match_rules (str): List of match rules for the grok parser, separated by a new line. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + support_rules (str): List of support rules for the grok parser, separated by a new line.. [optional] if omitted the server will use the default value of "" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.match_rules = match_rules + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +252,8 @@ def __init__(self, match_rules, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_grok_parser_type.py b/src/datadog_api_client/v1/model/logs_grok_parser_type.py index cd28336fad..ef5bcd2400 100644 --- a/src/datadog_api_client/v1/model/logs_grok_parser_type.py +++ b/src/datadog_api_client/v1/model/logs_grok_parser_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsGrokParserType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsGrokParserType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs grok parser.. if omitted defaults to "grok-parser", must be one of ["grok-parser", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs grok parser.. if omitted defaults to "grok-parser", must be one of ["grok-parser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "grok-parser" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_index.py b/src/datadog_api_client/v1/model/logs_index.py index da4db54dea..5e0021840f 100644 --- a/src/datadog_api_client/v1/model/logs_index.py +++ b/src/datadog_api_client/v1/model/logs_index.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,98 @@ def discriminator(): "num_retention_days": "num_retention_days", # noqa: E501 } + read_only_vars = { + "is_rate_limited", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, filter, name, *args, **kwargs): # noqa: E501 + """LogsIndex - a model defined in OpenAPI + + Args: + filter (LogsFilter): + name (str): The name of the index. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + daily_limit (int): The number of log events you can send in this index per day before you are rate-limited.. [optional] # noqa: E501 + exclusion_filters ([LogsExclusion]): An array of exclusion objects. The logs are tested against the query of each filter, following the order of the array. Only the first matching active exclusion matters, others (if any) are ignored.. [optional] # noqa: E501 + is_rate_limited (bool): A boolean stating if the index is rate limited, meaning more logs than the daily limit have been sent. Rate limit is reset every-day at 2pm UTC.. [optional] # noqa: E501 + num_retention_days (int): The number of days before logs are deleted from this index. Available values depend on retention plans specified in your organization's contract/subscriptions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.filter = filter + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +281,8 @@ def __init__(self, filter, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_index_list_response.py b/src/datadog_api_client/v1/model/logs_index_list_response.py index 016b3f278a..03f6eb1c1b 100644 --- a/src/datadog_api_client/v1/model/logs_index_list_response.py +++ b/src/datadog_api_client/v1/model/logs_index_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "indexes": "indexes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsIndexListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + indexes ([LogsIndex]): Array of Log index configurations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_index_update_request.py b/src/datadog_api_client/v1/model/logs_index_update_request.py index 586909ffa5..b8d602fcdb 100644 --- a/src/datadog_api_client/v1/model/logs_index_update_request.py +++ b/src/datadog_api_client/v1/model/logs_index_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,94 @@ def discriminator(): "num_retention_days": "num_retention_days", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, filter, *args, **kwargs): # noqa: E501 + """LogsIndexUpdateRequest - a model defined in OpenAPI + + Args: + filter (LogsFilter): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + daily_limit (int): The number of log events you can send in this index per day before you are rate-limited.. [optional] # noqa: E501 + disable_daily_limit (bool): If true, sets the `daily_limit` value to null and the index is not limited on a daily basis (any specified `daily_limit` value in the request is ignored). If false or omitted, the index's current `daily_limit` is maintained.. [optional] # noqa: E501 + exclusion_filters ([LogsExclusion]): An array of exclusion objects. The logs are tested against the query of each filter, following the order of the array. Only the first matching active exclusion matters, others (if any) are ignored.. [optional] # noqa: E501 + num_retention_days (int): The number of days before logs are deleted from this index. Available values depend on retention plans specified in your organization's contract/subscriptions. **Note:** Changing the retention for an index adjusts the length of retention for all logs already in this index. It may also affect billing.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.filter = filter + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +273,8 @@ def __init__(self, filter, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_indexes_order.py b/src/datadog_api_client/v1/model/logs_indexes_order.py index c34740d195..6cb814a893 100644 --- a/src/datadog_api_client/v1/model/logs_indexes_order.py +++ b/src/datadog_api_client/v1/model/logs_indexes_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsIndexesOrder(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "index_names": "index_names", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, index_names, *args, **kwargs): # noqa: E501 + """LogsIndexesOrder - a model defined in OpenAPI + + Args: + index_names ([str]): Array of strings identifying by their name(s) the index(es) of your organization. Logs are tested against the query filter of each index one by one, following the order of the array. Logs are eventually stored in the first matching index. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.index_names = index_names + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, index_names, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_list_request.py b/src/datadog_api_client/v1/model/logs_list_request.py index a28b216488..b9dfa6c55f 100644 --- a/src/datadog_api_client/v1/model/logs_list_request.py +++ b/src/datadog_api_client/v1/model/logs_list_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,95 @@ def discriminator(): "start_at": "startAt", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, time, *args, **kwargs): # noqa: E501 + """LogsListRequest - a model defined in OpenAPI + + Args: + time (LogsListRequestTime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + index (str): The log index on which the request is performed. For multi-index organizations, the default is all live indexes. Historical indexes of rehydrated logs must be specified.. [optional] # noqa: E501 + limit (int): Number of logs return in the response.. [optional] # noqa: E501 + query (str): The search query - following the log search syntax.. [optional] # noqa: E501 + sort (LogsSort): [optional] # noqa: E501 + start_at (str): Hash identifier of the first log to return in the list, available in a log `id` attribute. This parameter is used for the pagination feature. **Note**: This parameter is ignored if the corresponding log is out of the scope of the specified time window.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.time = time + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +281,8 @@ def __init__(self, time, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_list_request_time.py b/src/datadog_api_client/v1/model/logs_list_request_time.py index 886c4ed960..42c0e3dcba 100644 --- a/src/datadog_api_client/v1/model/logs_list_request_time.py +++ b/src/datadog_api_client/v1/model/logs_list_request_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsListRequestTime(ModelNormal): @@ -80,8 +82,93 @@ def discriminator(): "timezone": "timezone", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, _from, to, *args, **kwargs): # noqa: E501 + """LogsListRequestTime - a model defined in OpenAPI + + Args: + _from (datetime): Minimum timestamp for requested logs. + to (datetime): Maximum timestamp for requested logs. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + timezone (str): Timezone can be specified both as an offset (e.g. \"UTC+03:00\") or a regional zone (e.g. \"Europe/Paris\").. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self._from = _from + self.to = to + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +258,8 @@ def __init__(self, _from, to, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_list_response.py b/src/datadog_api_client/v1/model/logs_list_response.py index 71192fe9ae..0c51eade39 100644 --- a/src/datadog_api_client/v1/model/logs_list_response.py +++ b/src/datadog_api_client/v1/model/logs_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,89 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + logs ([Log]): Array of logs matching the request and the `nextLogId` if sent.. [optional] # noqa: E501 + next_log_id (str): Hash identifier of the next log to return in the list. This parameter is used for the pagination feature.. [optional] # noqa: E501 + status (str): Status of the response.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_lookup_processor.py b/src/datadog_api_client/v1/model/logs_lookup_processor.py index 488ec0d957..819a5a85de 100644 --- a/src/datadog_api_client/v1/model/logs_lookup_processor.py +++ b/src/datadog_api_client/v1/model/logs_lookup_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,99 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, lookup_table, source, target, type, *args, **kwargs): # noqa: E501 + """LogsLookupProcessor - a model defined in OpenAPI + + Args: + lookup_table ([str]): Mapping table of values for the source attribute and their associated target attribute values, formatted as `[\"source_key1,target_value1\", \"source_key2,target_value2\"]` + source (str): Source attribute used to perform the lookup. + target (str): Name of the attribute that contains the corresponding value in the mapping list or the `default_lookup` if not found in the mapping list. + type (LogsLookupProcessorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + default_lookup (str): Value to set the target attribute if the source value is not found in the list.. [optional] # noqa: E501 + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.lookup_table = lookup_table + self.source = source + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +285,8 @@ def __init__(self, lookup_table, source, target, type, *args, **kwargs): # noqa # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_lookup_processor_type.py b/src/datadog_api_client/v1/model/logs_lookup_processor_type.py index 5dcae73ee2..6f842474b3 100644 --- a/src/datadog_api_client/v1/model/logs_lookup_processor_type.py +++ b/src/datadog_api_client/v1/model/logs_lookup_processor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsLookupProcessorType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsLookupProcessorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs lookup processor.. if omitted defaults to "lookup-processor", must be one of ["lookup-processor", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs lookup processor.. if omitted defaults to "lookup-processor", must be one of ["lookup-processor", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "lookup-processor" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_message_remapper.py b/src/datadog_api_client/v1/model/logs_message_remapper.py index f74fc6299b..7f9602e72f 100644 --- a/src/datadog_api_client/v1/model/logs_message_remapper.py +++ b/src/datadog_api_client/v1/model/logs_message_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,95 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsMessageRemapper - a model defined in OpenAPI + + Args: + type (LogsMessageRemapperType): + + Keyword Args: + sources ([str]): Array of source attributes.. defaults to ["msg"] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + sources = kwargs.get("sources", ["msg"]) + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_message_remapper_type.py b/src/datadog_api_client/v1/model/logs_message_remapper_type.py index 059b8cf4df..034c4d8323 100644 --- a/src/datadog_api_client/v1/model/logs_message_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_message_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsMessageRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsMessageRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs message remapper.. if omitted defaults to "message-remapper", must be one of ["message-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs message remapper.. if omitted defaults to "message-remapper", must be one of ["message-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "message-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_pipeline.py b/src/datadog_api_client/v1/model/logs_pipeline.py index 40bddacc42..68affe78a8 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline.py +++ b/src/datadog_api_client/v1/model/logs_pipeline.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,100 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + "is_read_only", # noqa: E501 + "type", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """LogsPipeline - a model defined in OpenAPI + + Args: + name (str): Name of the pipeline. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsFilter): [optional] # noqa: E501 + id (str): ID of the pipeline.. [optional] # noqa: E501 + is_enabled (bool): Whether or not the pipeline is enabled.. [optional] # noqa: E501 + is_read_only (bool): Whether or not the pipeline can be edited.. [optional] # noqa: E501 + processors ([LogsProcessor]): Ordered list of processors in this pipeline.. [optional] # noqa: E501 + type (str): Type of pipeline.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -191,3 +285,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_pipeline_list.py b/src/datadog_api_client/v1/model/logs_pipeline_list.py index c5536b4003..9fe009768e 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline_list.py +++ b/src/datadog_api_client/v1/model/logs_pipeline_list.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsPipelineList - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([LogsPipeline]): Array of pipeline ID strings.. # noqa: E501 + + Keyword Args: + value ([LogsPipeline]): Array of pipeline ID strings.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_pipeline_processor.py b/src/datadog_api_client/v1/model/logs_pipeline_processor.py index 7dbbd32faa..431d3edee7 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline_processor.py +++ b/src/datadog_api_client/v1/model/logs_pipeline_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,94 @@ def discriminator(): "processors": "processors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsPipelineProcessor - a model defined in OpenAPI + + Args: + type (LogsPipelineProcessorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsFilter): [optional] # noqa: E501 + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + processors ([LogsProcessor]): Ordered list of processors in this pipeline.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,3 +275,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_pipeline_processor_type.py b/src/datadog_api_client/v1/model/logs_pipeline_processor_type.py index 4ef4b93453..7473e45f16 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline_processor_type.py +++ b/src/datadog_api_client/v1/model/logs_pipeline_processor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsPipelineProcessorType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsPipelineProcessorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs pipeline processor.. if omitted defaults to "pipeline", must be one of ["pipeline", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs pipeline processor.. if omitted defaults to "pipeline", must be one of ["pipeline", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "pipeline" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_pipelines_order.py b/src/datadog_api_client/v1/model/logs_pipelines_order.py index 38b6c138f5..b673a07565 100644 --- a/src/datadog_api_client/v1/model/logs_pipelines_order.py +++ b/src/datadog_api_client/v1/model/logs_pipelines_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsPipelinesOrder(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "pipeline_ids": "pipeline_ids", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, pipeline_ids, *args, **kwargs): # noqa: E501 + """LogsPipelinesOrder - a model defined in OpenAPI + + Args: + pipeline_ids ([str]): Ordered Array of `` strings, the order of pipeline IDs in the array define the overall Pipelines order for Datadog. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.pipeline_ids = pipeline_ids + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, pipeline_ids, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_processor.py b/src/datadog_api_client/v1/model/logs_processor.py index 281ce2b9bc..5ee1a69b0d 100644 --- a/src/datadog_api_client/v1/model/logs_processor.py +++ b/src/datadog_api_client/v1/model/logs_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -98,24 +100,7 @@ class LogsProcessor(ModelComposed): }, } - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -137,6 +122,110 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsProcessor - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + samples ([str]): List of sample logs to test this grok parser.. [optional] # noqa: E501 + override_on_conflict (bool): Override or not the target element if already set,. [optional] if omitted the server will use the default value of False # noqa: E501 + preserve_source (bool): Remove or preserve the remapped source element.. [optional] if omitted the server will use the default value of False # noqa: E501 + source_type (str): Defines if the sources are from log `attribute` or `tag`.. [optional] if omitted the server will use the default value of "attribute" # noqa: E501 + target_format (TargetFormatType): [optional] # noqa: E501 + target_type (str): Defines if the final attribute or tag name is from log `attribute` or `tag`.. [optional] if omitted the server will use the default value of "attribute" # noqa: E501 + normalize_ending_slashes (bool, none_type): Normalize the ending slashes or not.. [optional] if omitted the server will use the default value of False # noqa: E501 + is_encoded (bool): Define if the source attribute is URL encoded or not.. [optional] if omitted the server will use the default value of False # noqa: E501 + is_replace_missing (bool): If true, it replaces all missing attributes of `template` by an empty string. If `false` (default), skips the operation for missing attributes.. [optional] if omitted the server will use the default value of False # noqa: E501 + filter (LogsFilter): [optional] # noqa: E501 + processors ([LogsProcessor]): Ordered list of processors in this pipeline.. [optional] # noqa: E501 + default_lookup (str): Value to set the target attribute if the source value is not found in the list.. [optional] # noqa: E501 + grok (LogsGrokParserRules): [optional] # noqa: E501 + source (str): Source attribute used to perform the lookup.. [optional] # noqa: E501 + type (LogsTraceRemapperType): [optional] # noqa: E501 + sources ([str]): Array of source attributes.. [optional] if omitted the server will use the default value of ["dd.trace_id"] # noqa: E501 + target (str): Name of the attribute that contains the corresponding value in the mapping list or the `default_lookup` if not found in the mapping list.. [optional] # noqa: E501 + categories ([LogsCategoryProcessorCategory]): Array of filters to match or not a log and their corresponding `name`to assign a custom value to the log.. [optional] # noqa: E501 + expression (str): Arithmetic operation between one or more log attributes.. [optional] # noqa: E501 + template (str): A formula with one or more attributes and raw text.. [optional] # noqa: E501 + lookup_table ([str]): Mapping table of values for the source attribute and their associated target attribute values, formatted as `[\"source_key1,target_value1\", \"source_key2,target_value2\"]`. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -242,28 +331,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/logs_query_compute.py b/src/datadog_api_client/v1/model/logs_query_compute.py index cc1f2d028a..2c83a2717a 100644 --- a/src/datadog_api_client/v1/model/logs_query_compute.py +++ b/src/datadog_api_client/v1/model/logs_query_compute.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsQueryCompute(ModelNormal): @@ -80,8 +82,92 @@ def discriminator(): "interval": "interval", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation, *args, **kwargs): # noqa: E501 + """LogsQueryCompute - a model defined in OpenAPI + + Args: + aggregation (str): The aggregation method. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + facet (str): Facet name.. [optional] # noqa: E501 + interval (int): Define a time interval in seconds.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation = aggregation + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +256,8 @@ def __init__(self, aggregation, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_retention_agg_sum_usage.py b/src/datadog_api_client/v1/model/logs_retention_agg_sum_usage.py index fd1ab573ed..4f33d16dd8 100644 --- a/src/datadog_api_client/v1/model/logs_retention_agg_sum_usage.py +++ b/src/datadog_api_client/v1/model/logs_retention_agg_sum_usage.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsRetentionAggSumUsage(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "retention": "retention", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsRetentionAggSumUsage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + logs_indexed_logs_usage_agg_sum (int): Total indexed logs for this retention period.. [optional] # noqa: E501 + logs_live_indexed_logs_usage_agg_sum (int): Live indexed logs for this retention period.. [optional] # noqa: E501 + logs_rehydrated_indexed_logs_usage_agg_sum (int): Rehydrated indexed logs for this retention period.. [optional] # noqa: E501 + retention (str): The retention period in days or \"custom\" for all custom retention periods.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_retention_sum_usage.py b/src/datadog_api_client/v1/model/logs_retention_sum_usage.py index b9a8dd540d..1ca91d7161 100644 --- a/src/datadog_api_client/v1/model/logs_retention_sum_usage.py +++ b/src/datadog_api_client/v1/model/logs_retention_sum_usage.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsRetentionSumUsage(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "retention": "retention", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsRetentionSumUsage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + logs_indexed_logs_usage_sum (int): Total indexed logs for this retention period.. [optional] # noqa: E501 + logs_live_indexed_logs_usage_sum (int): Live indexed logs for this retention period.. [optional] # noqa: E501 + logs_rehydrated_indexed_logs_usage_sum (int): Rehydrated indexed logs for this retention period.. [optional] # noqa: E501 + retention (str): The retention period in days or \"custom\" for all custom retention periods.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_service_remapper.py b/src/datadog_api_client/v1/model/logs_service_remapper.py index 2640631ced..7315f21085 100644 --- a/src/datadog_api_client/v1/model/logs_service_remapper.py +++ b/src/datadog_api_client/v1/model/logs_service_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, sources, type, *args, **kwargs): # noqa: E501 + """LogsServiceRemapper - a model defined in OpenAPI + + Args: + sources ([str]): Array of source attributes. + type (LogsServiceRemapperType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, sources, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_service_remapper_type.py b/src/datadog_api_client/v1/model/logs_service_remapper_type.py index f979d6cbc8..b01d9925fb 100644 --- a/src/datadog_api_client/v1/model/logs_service_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_service_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsServiceRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsServiceRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs service remapper.. if omitted defaults to "service-remapper", must be one of ["service-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs service remapper.. if omitted defaults to "service-remapper", must be one of ["service-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "service-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_sort.py b/src/datadog_api_client/v1/model/logs_sort.py index efad78dbfc..ca9e03b295 100644 --- a/src/datadog_api_client/v1/model/logs_sort.py +++ b/src/datadog_api_client/v1/model/logs_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsSort(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Time-ascending `asc` or time-descending `desc`results.., must be one of ["asc", "desc", ] # noqa: E501 + + Keyword Args: + value (str): Time-ascending `asc` or time-descending `desc`results.., must be one of ["asc", "desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_status_remapper.py b/src/datadog_api_client/v1/model/logs_status_remapper.py index 91013c2221..cb93ae91f3 100644 --- a/src/datadog_api_client/v1/model/logs_status_remapper.py +++ b/src/datadog_api_client/v1/model/logs_status_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, sources, type, *args, **kwargs): # noqa: E501 + """LogsStatusRemapper - a model defined in OpenAPI + + Args: + sources ([str]): Array of source attributes. + type (LogsStatusRemapperType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, sources, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_status_remapper_type.py b/src/datadog_api_client/v1/model/logs_status_remapper_type.py index 5cf6019312..8b1ad1dd26 100644 --- a/src/datadog_api_client/v1/model/logs_status_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_status_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsStatusRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsStatusRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs status remapper.. if omitted defaults to "status-remapper", must be one of ["status-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs status remapper.. if omitted defaults to "status-remapper", must be one of ["status-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "status-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_string_builder_processor.py b/src/datadog_api_client/v1/model/logs_string_builder_processor.py index 86e10e9bc2..2c1f08d0e2 100644 --- a/src/datadog_api_client/v1/model/logs_string_builder_processor.py +++ b/src/datadog_api_client/v1/model/logs_string_builder_processor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,97 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, target, template, type, *args, **kwargs): # noqa: E501 + """LogsStringBuilderProcessor - a model defined in OpenAPI + + Args: + target (str): The name of the attribute that contains the result of the template. + template (str): A formula with one or more attributes and raw text. + type (LogsStringBuilderProcessorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + is_replace_missing (bool): If true, it replaces all missing attributes of `template` by an empty string. If `false` (default), skips the operation for missing attributes.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.target = target + self.template = template + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +279,8 @@ def __init__(self, target, template, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_string_builder_processor_type.py b/src/datadog_api_client/v1/model/logs_string_builder_processor_type.py index ea8567ebb3..60361376cd 100644 --- a/src/datadog_api_client/v1/model/logs_string_builder_processor_type.py +++ b/src/datadog_api_client/v1/model/logs_string_builder_processor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsStringBuilderProcessorType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsStringBuilderProcessorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs string builder processor.. if omitted defaults to "string-builder-processor", must be one of ["string-builder-processor", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs string builder processor.. if omitted defaults to "string-builder-processor", must be one of ["string-builder-processor", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "string-builder-processor" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_trace_remapper.py b/src/datadog_api_client/v1/model/logs_trace_remapper.py index 7a156bf4d1..2fd0485f7b 100644 --- a/src/datadog_api_client/v1/model/logs_trace_remapper.py +++ b/src/datadog_api_client/v1/model/logs_trace_remapper.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,93 @@ def discriminator(): "sources": "sources", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsTraceRemapper - a model defined in OpenAPI + + Args: + type (LogsTraceRemapperType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + sources ([str]): Array of source attributes.. [optional] if omitted the server will use the default value of ["dd.trace_id"] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -180,3 +267,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_trace_remapper_type.py b/src/datadog_api_client/v1/model/logs_trace_remapper_type.py index 0a6f5705f8..c1c2a3c144 100644 --- a/src/datadog_api_client/v1/model/logs_trace_remapper_type.py +++ b/src/datadog_api_client/v1/model/logs_trace_remapper_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsTraceRemapperType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsTraceRemapperType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs trace remapper.. if omitted defaults to "trace-id-remapper", must be one of ["trace-id-remapper", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs trace remapper.. if omitted defaults to "trace-id-remapper", must be one of ["trace-id-remapper", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "trace-id-remapper" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_url_parser.py b/src/datadog_api_client/v1/model/logs_url_parser.py index 64d899e227..d8b7f805b6 100644 --- a/src/datadog_api_client/v1/model/logs_url_parser.py +++ b/src/datadog_api_client/v1/model/logs_url_parser.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -96,8 +98,99 @@ def discriminator(): "normalize_ending_slashes": "normalize_ending_slashes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsURLParser - a model defined in OpenAPI + + Args: + type (LogsURLParserType): + + Keyword Args: + sources ([str]): Array of source attributes.. defaults to ["http.url"] # noqa: E501 + target (str): Name of the parent attribute that contains all the extracted details from the `sources`.. defaults to "http.url_details" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + normalize_ending_slashes (bool, none_type): Normalize the ending slashes or not.. [optional] if omitted the server will use the default value of False # noqa: E501 + """ + + sources = kwargs.get("sources", ["http.url"]) + target = kwargs.get("target", "http.url_details") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -193,3 +286,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_url_parser_type.py b/src/datadog_api_client/v1/model/logs_url_parser_type.py index 20c619ed1a..10f6f54037 100644 --- a/src/datadog_api_client/v1/model/logs_url_parser_type.py +++ b/src/datadog_api_client/v1/model/logs_url_parser_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsURLParserType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsURLParserType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs URL parser.. if omitted defaults to "url-parser", must be one of ["url-parser", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs URL parser.. if omitted defaults to "url-parser", must be one of ["url-parser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "url-parser" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/logs_user_agent_parser.py b/src/datadog_api_client/v1/model/logs_user_agent_parser.py index 31e6f32528..177ccddd89 100644 --- a/src/datadog_api_client/v1/model/logs_user_agent_parser.py +++ b/src/datadog_api_client/v1/model/logs_user_agent_parser.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,99 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """LogsUserAgentParser - a model defined in OpenAPI + + Args: + type (LogsUserAgentParserType): + + Keyword Args: + sources ([str]): Array of source attributes.. defaults to ["http.useragent"] # noqa: E501 + target (str): Name of the parent attribute that contains all the extracted details from the `sources`.. defaults to "http.useragent_details" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_enabled (bool): Whether or not the processor is enabled.. [optional] if omitted the server will use the default value of False # noqa: E501 + is_encoded (bool): Define if the source attribute is URL encoded or not.. [optional] if omitted the server will use the default value of False # noqa: E501 + name (str): Name of the processor.. [optional] # noqa: E501 + """ + + sources = kwargs.get("sources", ["http.useragent"]) + target = kwargs.get("target", "http.useragent_details") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.sources = sources + self.target = target + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -190,3 +283,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/logs_user_agent_parser_type.py b/src/datadog_api_client/v1/model/logs_user_agent_parser_type.py index a6e249c32c..2af8050309 100644 --- a/src/datadog_api_client/v1/model/logs_user_agent_parser_type.py +++ b/src/datadog_api_client/v1/model/logs_user_agent_parser_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class LogsUserAgentParserType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsUserAgentParserType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of logs User-Agent parser.. if omitted defaults to "user-agent-parser", must be one of ["user-agent-parser", ] # noqa: E501 + + Keyword Args: + value (str): Type of logs User-Agent parser.. if omitted defaults to "user-agent-parser", must be one of ["user-agent-parser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "user-agent-parser" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/metric_metadata.py b/src/datadog_api_client/v1/model/metric_metadata.py index 3e746863b4..3e3431812e 100644 --- a/src/datadog_api_client/v1/model/metric_metadata.py +++ b/src/datadog_api_client/v1/model/metric_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MetricMetadata(ModelNormal): @@ -88,8 +90,95 @@ def discriminator(): "unit": "unit", # noqa: E501 } + read_only_vars = { + "integration", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + description (str): Metric description.. [optional] # noqa: E501 + integration (str): Name of the integration that sent the metric if applicable.. [optional] # noqa: E501 + per_unit (str): Per unit of the metric such as `second` in `bytes per second`.. [optional] # noqa: E501 + short_name (str): A more human-readable and abbreviated version of the metric name.. [optional] # noqa: E501 + statsd_interval (int): StatsD flush interval of the metric in seconds if applicable.. [optional] # noqa: E501 + type (str): Metric type such as `gauge` or `rate`.. [optional] # noqa: E501 + unit (str): Primary unit of the metric such as `byte` or `operation`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +268,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metric_search_response.py b/src/datadog_api_client/v1/model/metric_search_response.py index 2f86228e5e..df49a19a0d 100644 --- a/src/datadog_api_client/v1/model/metric_search_response.py +++ b/src/datadog_api_client/v1/model/metric_search_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "results": "results", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricSearchResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + results (MetricSearchResponseResults): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metric_search_response_results.py b/src/datadog_api_client/v1/model/metric_search_response_results.py index 73789edd64..08f61c386a 100644 --- a/src/datadog_api_client/v1/model/metric_search_response_results.py +++ b/src/datadog_api_client/v1/model/metric_search_response_results.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MetricSearchResponseResults(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "metrics": "metrics", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricSearchResponseResults - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + metrics ([str]): List of metrics that match the search query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metrics_list_response.py b/src/datadog_api_client/v1/model/metrics_list_response.py index d250c58327..76c20a287b 100644 --- a/src/datadog_api_client/v1/model/metrics_list_response.py +++ b/src/datadog_api_client/v1/model/metrics_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MetricsListResponse(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "metrics": "metrics", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _from (str): Time when the metrics were active, seconds since the Unix epoch.. [optional] # noqa: E501 + metrics ([str]): List of metric names.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metrics_payload.py b/src/datadog_api_client/v1/model/metrics_payload.py index 9c91097c17..edd93fe9e3 100644 --- a/src/datadog_api_client/v1/model/metrics_payload.py +++ b/src/datadog_api_client/v1/model/metrics_payload.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "series": "series", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, series, *args, **kwargs): # noqa: E501 + """MetricsPayload - a model defined in OpenAPI + + Args: + series ([Series]): A list of time series to submit to Datadog. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.series = series + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, series, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metrics_query_metadata.py b/src/datadog_api_client/v1/model/metrics_query_metadata.py index 90c2fdb20e..742d5c52c9 100644 --- a/src/datadog_api_client/v1/model/metrics_query_metadata.py +++ b/src/datadog_api_client/v1/model/metrics_query_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -114,8 +116,113 @@ def discriminator(): "unit": "unit", # noqa: E501 } + read_only_vars = { + "aggr", # noqa: E501 + "display_name", # noqa: E501 + "end", # noqa: E501 + "expression", # noqa: E501 + "interval", # noqa: E501 + "length", # noqa: E501 + "metric", # noqa: E501 + "pointlist", # noqa: E501 + "query_index", # noqa: E501 + "scope", # noqa: E501 + "start", # noqa: E501 + "tag_set", # noqa: E501 + "unit", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsQueryMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggr (str): Aggregation type.. [optional] # noqa: E501 + display_name (str): Display name of the metric.. [optional] # noqa: E501 + end (int): End of the time window, milliseconds since Unix epoch.. [optional] # noqa: E501 + expression (str): Metric expression.. [optional] # noqa: E501 + interval (int): Number of seconds between data samples.. [optional] # noqa: E501 + length (int): Number of data samples.. [optional] # noqa: E501 + metric (str): Metric name.. [optional] # noqa: E501 + pointlist ([Point]): List of points of the time series.. [optional] # noqa: E501 + query_index (int): The index of the series' query within the request.. [optional] # noqa: E501 + scope (str): Metric scope, comma separated list of tags.. [optional] # noqa: E501 + start (int): Start of the time window, milliseconds since Unix epoch.. [optional] # noqa: E501 + tag_set ([str]): Unique tags identifying this series.. [optional] # noqa: E501 + unit ([MetricsQueryUnit]): Detailed information about the metric unit. First element describes the \"primary unit\" (for example, `bytes` in `bytes per second`), second describes the \"per unit\" (for example, `second` in `bytes per second`).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -211,3 +318,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metrics_query_response.py b/src/datadog_api_client/v1/model/metrics_query_response.py index 882a83098a..4644c9d885 100644 --- a/src/datadog_api_client/v1/model/metrics_query_response.py +++ b/src/datadog_api_client/v1/model/metrics_query_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,105 @@ def discriminator(): "to_date": "to_date", # noqa: E501 } + read_only_vars = { + "error", # noqa: E501 + "from_date", # noqa: E501 + "group_by", # noqa: E501 + "message", # noqa: E501 + "query", # noqa: E501 + "res_type", # noqa: E501 + "series", # noqa: E501 + "status", # noqa: E501 + "to_date", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsQueryResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): Message indicating the errors if status is not `ok`.. [optional] # noqa: E501 + from_date (int): Start of requested time window, milliseconds since Unix epoch.. [optional] # noqa: E501 + group_by ([str]): List of tag keys on which to group.. [optional] # noqa: E501 + message (str): Message indicating `success` if status is `ok`.. [optional] # noqa: E501 + query (str): Query string. [optional] # noqa: E501 + res_type (str): Type of response.. [optional] # noqa: E501 + series ([MetricsQueryMetadata]): List of timeseries queried.. [optional] # noqa: E501 + status (str): Status of the query.. [optional] # noqa: E501 + to_date (int): End of requested time window, milliseconds since Unix epoch.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +291,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/metrics_query_unit.py b/src/datadog_api_client/v1/model/metrics_query_unit.py index eca77f9f32..28afeb98c4 100644 --- a/src/datadog_api_client/v1/model/metrics_query_unit.py +++ b/src/datadog_api_client/v1/model/metrics_query_unit.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MetricsQueryUnit(ModelNormal): @@ -84,8 +86,97 @@ def discriminator(): "short_name": "short_name", # noqa: E501 } + read_only_vars = { + "family", # noqa: E501 + "name", # noqa: E501 + "plural", # noqa: E501 + "scale_factor", # noqa: E501 + "short_name", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsQueryUnit - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + family (str): Unit family, allows for conversion between units of the same family, for scaling.. [optional] # noqa: E501 + name (str): Unit name. [optional] # noqa: E501 + plural (str): Plural form of the unit name.. [optional] # noqa: E501 + scale_factor (float): Factor for scaling between units of the same family.. [optional] # noqa: E501 + short_name (str): Abbreviation of the unit.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +264,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor.py b/src/datadog_api_client/v1/model/monitor.py index 439184ceb8..4077202086 100644 --- a/src/datadog_api_client/v1/model/monitor.py +++ b/src/datadog_api_client/v1/model/monitor.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -129,8 +131,112 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "deleted", # noqa: E501 + "id", # noqa: E501 + "modified", # noqa: E501 + "multi", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, type, *args, **kwargs): # noqa: E501 + """Monitor - a model defined in OpenAPI + + Args: + query (str): The monitor query. + type (MonitorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Timestamp of the monitor creation.. [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + deleted (datetime, none_type): Whether or not the monitor is deleted. (Always `null`). [optional] # noqa: E501 + id (int): ID of this monitor.. [optional] # noqa: E501 + message (str): A message to include with notifications for this monitor.. [optional] # noqa: E501 + modified (datetime): Last timestamp when the monitor was edited.. [optional] # noqa: E501 + multi (bool): Whether or not the monitor is broken down on different groups.. [optional] # noqa: E501 + name (str): The monitor name.. [optional] # noqa: E501 + options (MonitorOptions): [optional] # noqa: E501 + overall_state (MonitorOverallStates): [optional] # noqa: E501 + priority (int): Integer from 1 (high) to 5 (low) indicating alert severity.. [optional] # noqa: E501 + restricted_roles ([str]): A list of role identifiers that can be pulled from the Roles API. Cannot be used with `locked` option.. [optional] # noqa: E501 + state (MonitorState): [optional] # noqa: E501 + tags ([str]): Tags associated to your monitor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -233,3 +339,8 @@ def __init__(self, query, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_device_id.py b/src/datadog_api_client/v1/model/monitor_device_id.py index 2cbba7c2b8..ddb79e4ffc 100644 --- a/src/datadog_api_client/v1/model/monitor_device_id.py +++ b/src/datadog_api_client/v1/model/monitor_device_id.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorDeviceID(ModelSimple): @@ -82,6 +84,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -185,3 +189,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MonitorDeviceID - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): ID of the device the Synthetics monitor is running on. Same as `SyntheticsDeviceID`.., must be one of ["laptop_large", "tablet", "mobile_small", "chrome.laptop_large", "chrome.tablet", "chrome.mobile_small", "firefox.laptop_large", "firefox.tablet", "firefox.mobile_small", ] # noqa: E501 + + Keyword Args: + value (str): ID of the device the Synthetics monitor is running on. Same as `SyntheticsDeviceID`.., must be one of ["laptop_large", "tablet", "mobile_small", "chrome.laptop_large", "chrome.tablet", "chrome.mobile_small", "firefox.laptop_large", "firefox.tablet", "firefox.mobile_small", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/monitor_group_search_response.py b/src/datadog_api_client/v1/model/monitor_group_search_response.py index d8b9a86442..65b66aa838 100644 --- a/src/datadog_api_client/v1/model/monitor_group_search_response.py +++ b/src/datadog_api_client/v1/model/monitor_group_search_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,91 @@ def discriminator(): "metadata": "metadata", # noqa: E501 } + read_only_vars = { + "groups", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorGroupSearchResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + counts (MonitorGroupSearchResponseCounts): [optional] # noqa: E501 + groups ([MonitorGroupSearchResult]): The list of found monitor groups.. [optional] # noqa: E501 + metadata (MonitorSearchResponseMetadata): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_group_search_response_counts.py b/src/datadog_api_client/v1/model/monitor_group_search_response_counts.py index f5cc8faae2..2b408b8deb 100644 --- a/src/datadog_api_client/v1/model/monitor_group_search_response_counts.py +++ b/src/datadog_api_client/v1/model/monitor_group_search_response_counts.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorGroupSearchResponseCounts - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (MonitorSearchCount): [optional] # noqa: E501 + type (MonitorSearchCount): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_group_search_result.py b/src/datadog_api_client/v1/model/monitor_group_search_result.py index 0de79da17f..2417dbafb9 100644 --- a/src/datadog_api_client/v1/model/monitor_group_search_result.py +++ b/src/datadog_api_client/v1/model/monitor_group_search_result.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -98,8 +100,100 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = { + "group", # noqa: E501 + "group_tags", # noqa: E501 + "last_nodata_ts", # noqa: E501 + "last_triggered_ts", # noqa: E501 + "monitor_id", # noqa: E501 + "monitor_name", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorGroupSearchResult - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + group (str): The name of the group.. [optional] # noqa: E501 + group_tags ([str]): The list of tags of the monitor group.. [optional] # noqa: E501 + last_nodata_ts (int): Latest timestamp the monitor group was in NO_DATA state.. [optional] # noqa: E501 + last_triggered_ts (int, none_type): Latest timestamp the monitor group triggered.. [optional] # noqa: E501 + monitor_id (int): The ID of the monitor.. [optional] # noqa: E501 + monitor_name (str): The name of the monitor.. [optional] # noqa: E501 + status (MonitorOverallStates): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +283,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_options.py b/src/datadog_api_client/v1/model/monitor_options.py index d3ba41c687..56fe896476 100644 --- a/src/datadog_api_client/v1/model/monitor_options.py +++ b/src/datadog_api_client/v1/model/monitor_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -158,8 +160,109 @@ def discriminator(): "timeout_h": "timeout_h", # noqa: E501 } + read_only_vars = { + "device_ids", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregation (MonitorOptionsAggregation): [optional] # noqa: E501 + device_ids ([MonitorDeviceID]): IDs of the device the Synthetics monitor is running on.. [optional] # noqa: E501 + enable_logs_sample (bool): Whether or not to send a log sample when the log monitor triggers.. [optional] # noqa: E501 + escalation_message (str): We recommend using the [is_renotify](https://docs.datadoghq.com/monitors/notifications/?tab=is_alert#renotify), block in the original message instead. A message to include with a re-notification. Supports the `@username` notification we allow elsewhere. Not applicable if `renotify_interval` is `None`.. [optional] if omitted the server will use the default value of "none" # noqa: E501 + evaluation_delay (int, none_type): Time (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to `300` (5min), the timeframe is set to `last_5m` and the time is 7:00, the monitor evaluates data from 6:50 to 6:55. This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.. [optional] # noqa: E501 + groupby_simple_monitor (bool): Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold.. [optional] # noqa: E501 + include_tags (bool): A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. **Examples** - If `True`, `[Triggered on {host:h1}] Monitor Title` - If `False`, `[Triggered] Monitor Title`. [optional] if omitted the server will use the default value of True # noqa: E501 + locked (bool): Whether or not the monitor is locked (only editable by creator and admins).. [optional] # noqa: E501 + min_failure_duration (int, none_type): How long the test should be in failure before alerting (integer, number of seconds, max 7200).. [optional] if omitted the server will use the default value of 0 # noqa: E501 + min_location_failed (int, none_type): The minimum number of locations in failure at the same time during at least one moment in the `min_failure_duration` period (`min_location_failed` and `min_failure_duration` are part of the advanced alerting rules - integer, >= 1).. [optional] if omitted the server will use the default value of 1 # noqa: E501 + new_host_delay (int, none_type): Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer.. [optional] if omitted the server will use the default value of 300 # noqa: E501 + no_data_timeframe (int, none_type): The number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for metric alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for metric alerts, and 24 hours is used for service checks.. [optional] # noqa: E501 + notify_audit (bool): A Boolean indicating whether tagged users is notified on changes to this monitor.. [optional] if omitted the server will use the default value of False # noqa: E501 + notify_no_data (bool): A Boolean indicating whether this monitor notifies when data stops reporting.. [optional] if omitted the server will use the default value of False # noqa: E501 + renotify_interval (int, none_type): The number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.. [optional] # noqa: E501 + require_full_window (bool): A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. We highly recommend you set this to `false` for sparse metrics, otherwise some evaluations are skipped. Default is false.. [optional] # noqa: E501 + silenced ({str: (int, none_type)}): Information about the downtime applied to the monitor.. [optional] # noqa: E501 + synthetics_check_id (str, none_type): ID of the corresponding Synthetic check.. [optional] # noqa: E501 + threshold_windows (MonitorThresholdWindowOptions): [optional] # noqa: E501 + thresholds (MonitorThresholds): [optional] # noqa: E501 + timeout_h (int, none_type): The number of hours of the monitor not reporting data before it automatically resolves from a triggered state.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -263,3 +366,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_options_aggregation.py b/src/datadog_api_client/v1/model/monitor_options_aggregation.py index bb0cb09e38..d5c8189a66 100644 --- a/src/datadog_api_client/v1/model/monitor_options_aggregation.py +++ b/src/datadog_api_client/v1/model/monitor_options_aggregation.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorOptionsAggregation(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorOptionsAggregation - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + group_by (str): Group to break down the monitor on.. [optional] # noqa: E501 + metric (str): Metric name used in the monitor.. [optional] # noqa: E501 + type (str): Metric type used in the monitor.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_overall_states.py b/src/datadog_api_client/v1/model/monitor_overall_states.py index ba8f7b56a7..04b77c8ab3 100644 --- a/src/datadog_api_client/v1/model/monitor_overall_states.py +++ b/src/datadog_api_client/v1/model/monitor_overall_states.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorOverallStates(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MonitorOverallStates - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The different states your monitor can be in.., must be one of ["Alert", "Ignored", "No Data", "OK", "Skipped", "Unknown", "Warn", ] # noqa: E501 + + Keyword Args: + value (str): The different states your monitor can be in.., must be one of ["Alert", "Ignored", "No Data", "OK", "Skipped", "Unknown", "Warn", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/monitor_search_count.py b/src/datadog_api_client/v1/model/monitor_search_count.py index e0f5030733..3e2ccebea7 100644 --- a/src/datadog_api_client/v1/model/monitor_search_count.py +++ b/src/datadog_api_client/v1/model/monitor_search_count.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorSearchCount(ModelSimple): @@ -61,7 +63,7 @@ def openapi_types(): and the value is attribute type. """ return { - "value": ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}],), + "value": ([dict],), } @cached_property @@ -70,6 +72,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -90,10 +94,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - args[0] ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}]): Search facets.. # noqa: E501 + args[0] ([dict]): Search facets.. # noqa: E501 Keyword Args: - value ([{str: (bool, date, datetime, dict, float, int, list, str, none_type)}]): Search facets.. # noqa: E501 + value ([dict]): Search facets.. # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -156,9 +160,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MonitorSearchCount - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([dict]): Search facets.. # noqa: E501 + + Keyword Args: + value ([dict]): Search facets.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -184,3 +271,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/monitor_search_response.py b/src/datadog_api_client/v1/model/monitor_search_response.py index c2abbeec9b..53cf3b635d 100644 --- a/src/datadog_api_client/v1/model/monitor_search_response.py +++ b/src/datadog_api_client/v1/model/monitor_search_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,91 @@ def discriminator(): "monitors": "monitors", # noqa: E501 } + read_only_vars = { + "monitors", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorSearchResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + counts (MonitorSearchResponseCounts): [optional] # noqa: E501 + metadata (MonitorSearchResponseMetadata): [optional] # noqa: E501 + monitors ([MonitorSearchResult]): The list of found monitors.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_search_response_counts.py b/src/datadog_api_client/v1/model/monitor_search_response_counts.py index 6f737e5fce..fee43d359b 100644 --- a/src/datadog_api_client/v1/model/monitor_search_response_counts.py +++ b/src/datadog_api_client/v1/model/monitor_search_response_counts.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorSearchResponseCounts - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + muted (MonitorSearchCount): [optional] # noqa: E501 + status (MonitorSearchCount): [optional] # noqa: E501 + tag (MonitorSearchCount): [optional] # noqa: E501 + type (MonitorSearchCount): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_search_response_metadata.py b/src/datadog_api_client/v1/model/monitor_search_response_metadata.py index ce359be22c..2bce8d9405 100644 --- a/src/datadog_api_client/v1/model/monitor_search_response_metadata.py +++ b/src/datadog_api_client/v1/model/monitor_search_response_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorSearchResponseMetadata(ModelNormal): @@ -82,8 +84,95 @@ def discriminator(): "total_count": "total_count", # noqa: E501 } + read_only_vars = { + "page", # noqa: E501 + "page_count", # noqa: E501 + "per_page", # noqa: E501 + "total_count", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorSearchResponseMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (int): The page to start paginating from.. [optional] # noqa: E501 + page_count (int): The number of pages.. [optional] # noqa: E501 + per_page (int): The number of monitors to return per page.. [optional] # noqa: E501 + total_count (int): The total number of monitors.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_search_result.py b/src/datadog_api_client/v1/model/monitor_search_result.py index e8620501ca..4bfe6ebb9f 100644 --- a/src/datadog_api_client/v1/model/monitor_search_result.py +++ b/src/datadog_api_client/v1/model/monitor_search_result.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -114,8 +116,107 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "classification", # noqa: E501 + "id", # noqa: E501 + "last_triggered_ts", # noqa: E501 + "metrics", # noqa: E501 + "name", # noqa: E501 + "notifications", # noqa: E501 + "org_id", # noqa: E501 + "tags", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorSearchResult - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + classification (str): Classification of the monitor.. [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + id (int): ID of the monitor.. [optional] # noqa: E501 + last_triggered_ts (int, none_type): Latest timestamp the monitor triggered.. [optional] # noqa: E501 + metrics ([str]): Metrics used by the monitor.. [optional] # noqa: E501 + name (str): The monitor name.. [optional] # noqa: E501 + notifications ([MonitorSearchResultNotification]): The notification triggered by the monitor.. [optional] # noqa: E501 + org_id (int): The ID of the organization.. [optional] # noqa: E501 + scopes ([str]): The scope(s) to which the downtime applies, e.g. `host:app2`. Provide multiple scopes as a comma-separated list, e.g. `env:dev,env:prod`. The resulting downtime applies to sources that matches ALL provided scopes (i.e. `env:dev AND env:prod`), NOT any of them.. [optional] # noqa: E501 + status (MonitorOverallStates): [optional] # noqa: E501 + tags ([str]): Tags associated with the monitor.. [optional] # noqa: E501 + type (MonitorType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -210,3 +311,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_search_result_notification.py b/src/datadog_api_client/v1/model/monitor_search_result_notification.py index 9078541a62..f170244f5a 100644 --- a/src/datadog_api_client/v1/model/monitor_search_result_notification.py +++ b/src/datadog_api_client/v1/model/monitor_search_result_notification.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorSearchResultNotification(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "handle", # noqa: E501 + "name", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorSearchResultNotification - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + handle (str): The email address that received the notification.. [optional] # noqa: E501 + name (str): The username receiving the notification. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_state.py b/src/datadog_api_client/v1/model/monitor_state.py index d09ad6c1ee..255cb929b7 100644 --- a/src/datadog_api_client/v1/model/monitor_state.py +++ b/src/datadog_api_client/v1/model/monitor_state.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "groups": "groups", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorState - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + groups ({str: (MonitorStateGroup,)}): Dictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_state_group.py b/src/datadog_api_client/v1/model/monitor_state_group.py index b55943bf1e..f680650158 100644 --- a/src/datadog_api_client/v1/model/monitor_state_group.py +++ b/src/datadog_api_client/v1/model/monitor_state_group.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,92 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorStateGroup - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + last_nodata_ts (int): Latest timestamp the monitor was in NO_DATA state.. [optional] # noqa: E501 + last_notified_ts (int): Latest timestamp of the notification sent for this monitor group.. [optional] # noqa: E501 + last_resolved_ts (int): Latest timestamp the monitor group was resolved.. [optional] # noqa: E501 + last_triggered_ts (int): Latest timestamp the monitor group triggered.. [optional] # noqa: E501 + name (str): The name of the monitor.. [optional] # noqa: E501 + status (MonitorOverallStates): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +269,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_summary_widget_definition.py b/src/datadog_api_client/v1/model/monitor_summary_widget_definition.py index 3dbc946774..c79e21c72b 100644 --- a/src/datadog_api_client/v1/model/monitor_summary_widget_definition.py +++ b/src/datadog_api_client/v1/model/monitor_summary_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -117,8 +119,103 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, type, *args, **kwargs): # noqa: E501 + """MonitorSummaryWidgetDefinition - a model defined in OpenAPI + + Args: + query (str): Query to filter the monitors with. + type (MonitorSummaryWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + color_preference (WidgetColorPreference): [optional] # noqa: E501 + count (int): The number of monitors to display.. [optional] # noqa: E501 + display_format (WidgetMonitorSummaryDisplayFormat): [optional] # noqa: E501 + hide_zero_counts (bool): Whether to show counts of 0 or not.. [optional] # noqa: E501 + show_last_triggered (bool): Whether to show the time that has elapsed since the monitor/group triggered.. [optional] # noqa: E501 + sort (WidgetMonitorSummarySort): [optional] # noqa: E501 + start (int): The start of the list. Typically 0.. [optional] # noqa: E501 + summary_type (WidgetSummaryType): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -218,3 +315,8 @@ def __init__(self, query, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_summary_widget_definition_type.py b/src/datadog_api_client/v1/model/monitor_summary_widget_definition_type.py index b35e17f940..f1985f5554 100644 --- a/src/datadog_api_client/v1/model/monitor_summary_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/monitor_summary_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorSummaryWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MonitorSummaryWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the monitor summary widget.. if omitted defaults to "manage_status", must be one of ["manage_status", ] # noqa: E501 + + Keyword Args: + value (str): Type of the monitor summary widget.. if omitted defaults to "manage_status", must be one of ["manage_status", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "manage_status" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/monitor_threshold_window_options.py b/src/datadog_api_client/v1/model/monitor_threshold_window_options.py index 02e3dd15f4..a55eedac17 100644 --- a/src/datadog_api_client/v1/model/monitor_threshold_window_options.py +++ b/src/datadog_api_client/v1/model/monitor_threshold_window_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorThresholdWindowOptions(ModelNormal): @@ -84,8 +86,88 @@ def discriminator(): "trigger_window": "trigger_window", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorThresholdWindowOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + recovery_window (str, none_type): Describes how long an anomalous metric must be normal before the alert recovers.. [optional] # noqa: E501 + trigger_window (str, none_type): Describes how long a metric must be anomalous before an alert triggers.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +252,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_thresholds.py b/src/datadog_api_client/v1/model/monitor_thresholds.py index b938ae3190..fe1fd6381f 100644 --- a/src/datadog_api_client/v1/model/monitor_thresholds.py +++ b/src/datadog_api_client/v1/model/monitor_thresholds.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorThresholds(ModelNormal): @@ -101,8 +103,92 @@ def discriminator(): "warning_recovery": "warning_recovery", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorThresholds - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + critical (float): The monitor `CRITICAL` threshold.. [optional] # noqa: E501 + critical_recovery (float, none_type): The monitor `CRITICAL` recovery threshold.. [optional] # noqa: E501 + ok (float, none_type): The monitor `OK` threshold.. [optional] # noqa: E501 + unknown (float, none_type): The monitor UNKNOWN threshold.. [optional] # noqa: E501 + warning (float, none_type): The monitor `WARNING` threshold.. [optional] # noqa: E501 + warning_recovery (float, none_type): The monitor `WARNING` recovery threshold.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -191,3 +277,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/monitor_type.py b/src/datadog_api_client/v1/model/monitor_type.py index 9b44896de8..2c8e650ed7 100644 --- a/src/datadog_api_client/v1/model/monitor_type.py +++ b/src/datadog_api_client/v1/model/monitor_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class MonitorType(ModelSimple): @@ -85,6 +87,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -188,3 +192,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MonitorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of the monitor. For more information about `type`, see the [monitor options](https://docs.datadoghq.com/monitors/guide/monitor_api_options/) docs.., must be one of ["composite", "event alert", "log alert", "metric alert", "process alert", "query alert", "rum alert", "service check", "synthetics alert", "trace-analytics alert", "slo alert", "event-v2 alert", ] # noqa: E501 + + Keyword Args: + value (str): The type of the monitor. For more information about `type`, see the [monitor options](https://docs.datadoghq.com/monitors/guide/monitor_api_options/) docs.., must be one of ["composite", "event alert", "log alert", "metric alert", "process alert", "query alert", "rum alert", "service check", "synthetics alert", "trace-analytics alert", "slo alert", "event-v2 alert", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/monitor_update_request.py b/src/datadog_api_client/v1/model/monitor_update_request.py index 5929d314a2..db0dd2ae91 100644 --- a/src/datadog_api_client/v1/model/monitor_update_request.py +++ b/src/datadog_api_client/v1/model/monitor_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -129,8 +131,108 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "deleted", # noqa: E501 + "id", # noqa: E501 + "modified", # noqa: E501 + "multi", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MonitorUpdateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Timestamp of the monitor creation.. [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + deleted (datetime, none_type): Whether or not the monitor is deleted. (Always `null`). [optional] # noqa: E501 + id (int): ID of this monitor.. [optional] # noqa: E501 + message (str): A message to include with notifications for this monitor.. [optional] # noqa: E501 + modified (datetime): Last timestamp when the monitor was edited.. [optional] # noqa: E501 + multi (bool): Whether or not the monitor is broken down on different groups.. [optional] # noqa: E501 + name (str): The monitor name.. [optional] # noqa: E501 + options (MonitorOptions): [optional] # noqa: E501 + overall_state (MonitorOverallStates): [optional] # noqa: E501 + priority (int): Integer from 1 (high) to 5 (low) indicating alert severity.. [optional] # noqa: E501 + query (str): The monitor query.. [optional] # noqa: E501 + restricted_roles ([str]): A list of role identifiers that can be pulled from the Roles API. Cannot be used with `locked` option.. [optional] # noqa: E501 + state (MonitorState): [optional] # noqa: E501 + tags ([str]): Tags associated to your monitor.. [optional] # noqa: E501 + type (MonitorType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -229,3 +331,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/note_widget_definition.py b/src/datadog_api_client/v1/model/note_widget_definition.py index 2556836c09..b01d72547f 100644 --- a/src/datadog_api_client/v1/model/note_widget_definition.py +++ b/src/datadog_api_client/v1/model/note_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,100 @@ def discriminator(): "vertical_align": "vertical_align", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, content, type, *args, **kwargs): # noqa: E501 + """NoteWidgetDefinition - a model defined in OpenAPI + + Args: + content (str): Content of the note. + type (NoteWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + background_color (str): Background color of the note.. [optional] # noqa: E501 + font_size (str): Size of the text.. [optional] # noqa: E501 + has_padding (bool): Whether to add padding or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + show_tick (bool): Whether to show a tick or not.. [optional] # noqa: E501 + text_align (WidgetTextAlign): [optional] # noqa: E501 + tick_edge (WidgetTickEdge): [optional] # noqa: E501 + tick_pos (str): Where to position the tick on an edge.. [optional] # noqa: E501 + vertical_align (WidgetVerticalAlign): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.content = content + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -205,3 +299,8 @@ def __init__(self, content, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/note_widget_definition_type.py b/src/datadog_api_client/v1/model/note_widget_definition_type.py index 52a7281754..12b6b7fe8b 100644 --- a/src/datadog_api_client/v1/model/note_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/note_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NoteWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NoteWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the note widget.. if omitted defaults to "note", must be one of ["note", ] # noqa: E501 + + Keyword Args: + value (str): Type of the note widget.. if omitted defaults to "note", must be one of ["note", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "note" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_absolute_time.py b/src/datadog_api_client/v1/model/notebook_absolute_time.py index 3acce2612c..2e13528d9c 100644 --- a/src/datadog_api_client/v1/model/notebook_absolute_time.py +++ b/src/datadog_api_client/v1/model/notebook_absolute_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookAbsoluteTime(ModelNormal): @@ -80,8 +82,93 @@ def discriminator(): "live": "live", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, end, start, *args, **kwargs): # noqa: E501 + """NotebookAbsoluteTime - a model defined in OpenAPI + + Args: + end (datetime): The end time. + start (datetime): The start time. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + live (bool): Indicates whether the timeframe should be shifted to end at the current time.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.end = end + self.start = start + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +258,8 @@ def __init__(self, end, start, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_author.py b/src/datadog_api_client/v1/model/notebook_author.py index a32e846e40..e55e16d39c 100644 --- a/src/datadog_api_client/v1/model/notebook_author.py +++ b/src/datadog_api_client/v1/model/notebook_author.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookAuthor(ModelNormal): @@ -92,8 +94,95 @@ def discriminator(): "verified": "verified", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookAuthor - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the user.. [optional] # noqa: E501 + disabled (bool): Whether the user is disabled.. [optional] # noqa: E501 + email (str): Email of the user.. [optional] # noqa: E501 + handle (str): Handle of the user.. [optional] # noqa: E501 + icon (str): URL of the user's icon.. [optional] # noqa: E501 + name (str): Name of the user.. [optional] # noqa: E501 + status (str): Status of the user.. [optional] # noqa: E501 + title (str): Title of the user.. [optional] # noqa: E501 + verified (bool): Whether the user is verified.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +274,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_cell_create_request.py b/src/datadog_api_client/v1/model/notebook_cell_create_request.py index 9639649511..2f06227b93 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_create_request.py +++ b/src/datadog_api_client/v1/model/notebook_cell_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """NotebookCellCreateRequest - a model defined in OpenAPI + + Args: + attributes (NotebookCellCreateRequestAttributes): + type (NotebookCellResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_cell_create_request_attributes.py b/src/datadog_api_client/v1/model/notebook_cell_create_request_attributes.py index b949a1521b..023df2fcd0 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_create_request_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_cell_create_request_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -74,24 +76,7 @@ class NotebookCellCreateRequestAttributes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -113,6 +98,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookCellCreateRequestAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + definition (LogStreamWidgetDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -199,28 +269,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_cell_resource_type.py b/src/datadog_api_client/v1/model/notebook_cell_resource_type.py index d4bbc9334b..cecf82055d 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_resource_type.py +++ b/src/datadog_api_client/v1/model/notebook_cell_resource_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookCellResourceType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NotebookCellResourceType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Notebook Cell resource.. if omitted defaults to "notebook_cells", must be one of ["notebook_cells", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Notebook Cell resource.. if omitted defaults to "notebook_cells", must be one of ["notebook_cells", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "notebook_cells" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_cell_response.py b/src/datadog_api_client/v1/model/notebook_cell_response.py index 9870b7e9e1..d8c2d4ae73 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_response.py +++ b/src/datadog_api_client/v1/model/notebook_cell_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """NotebookCellResponse - a model defined in OpenAPI + + Args: + attributes (NotebookCellResponseAttributes): + id (str): Notebook cell ID. + type (NotebookCellResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_cell_response_attributes.py b/src/datadog_api_client/v1/model/notebook_cell_response_attributes.py index 1a4bb178a7..92f977c090 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_response_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_cell_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -74,24 +76,7 @@ class NotebookCellResponseAttributes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -113,6 +98,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookCellResponseAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + definition (LogStreamWidgetDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -199,28 +269,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_cell_time.py b/src/datadog_api_client/v1/model/notebook_cell_time.py index b363752373..24d5bb765e 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_time.py +++ b/src/datadog_api_client/v1/model/notebook_cell_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -60,24 +62,7 @@ class NotebookCellTime(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = True @@ -99,6 +84,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookCellTime - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + live (bool): Indicates whether the timeframe should be shifted to end at the current time.. [optional] # noqa: E501 + live_span (WidgetLiveSpan): [optional] # noqa: E501 + end (datetime): The end time.. [optional] # noqa: E501 + start (datetime): The start time.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -185,28 +255,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_cell_update_request.py b/src/datadog_api_client/v1/model/notebook_cell_update_request.py index ffe8cd4d65..bc9b02a992 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_update_request.py +++ b/src/datadog_api_client/v1/model/notebook_cell_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """NotebookCellUpdateRequest - a model defined in OpenAPI + + Args: + attributes (NotebookCellUpdateRequestAttributes): + id (str): Notebook cell ID. + type (NotebookCellResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_cell_update_request_attributes.py b/src/datadog_api_client/v1/model/notebook_cell_update_request_attributes.py index eff5e7694a..3e0721f1c0 100644 --- a/src/datadog_api_client/v1/model/notebook_cell_update_request_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_cell_update_request_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -74,24 +76,7 @@ class NotebookCellUpdateRequestAttributes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -113,6 +98,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookCellUpdateRequestAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + definition (LogStreamWidgetDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -199,28 +269,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_create_data.py b/src/datadog_api_client/v1/model/notebook_create_data.py index 1ba8a7c9e3..c95783bab9 100644 --- a/src/datadog_api_client/v1/model/notebook_create_data.py +++ b/src/datadog_api_client/v1/model/notebook_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """NotebookCreateData - a model defined in OpenAPI + + Args: + attributes (NotebookCreateDataAttributes): + type (NotebookResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_create_data_attributes.py b/src/datadog_api_client/v1/model/notebook_create_data_attributes.py index a91e9f2189..084d851d71 100644 --- a/src/datadog_api_client/v1/model/notebook_create_data_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_create_data_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -98,8 +100,95 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, cells, name, time, *args, **kwargs): # noqa: E501 + """NotebookCreateDataAttributes - a model defined in OpenAPI + + Args: + cells ([NotebookCellCreateRequest]): List of cells to display in the notebook. + name (str): The name of the notebook. + time (NotebookGlobalTime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (NotebookStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.cells = cells + self.name = name + self.time = time + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -191,3 +280,8 @@ def __init__(self, cells, name, time, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_create_request.py b/src/datadog_api_client/v1/model/notebook_create_request.py index bf9453d109..b98cf57c59 100644 --- a/src/datadog_api_client/v1/model/notebook_create_request.py +++ b/src/datadog_api_client/v1/model/notebook_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """NotebookCreateRequest - a model defined in OpenAPI + + Args: + data (NotebookCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_distribution_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_distribution_cell_attributes.py index b622b3790c..d688a0604b 100644 --- a/src/datadog_api_client/v1/model/notebook_distribution_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_distribution_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,93 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookDistributionCellAttributes - a model defined in OpenAPI + + Args: + definition (DistributionWidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +273,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_global_time.py b/src/datadog_api_client/v1/model/notebook_global_time.py index 3ef493b7d5..8dd1c855a0 100644 --- a/src/datadog_api_client/v1/model/notebook_global_time.py +++ b/src/datadog_api_client/v1/model/notebook_global_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -60,24 +62,7 @@ class NotebookGlobalTime(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -99,6 +84,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookGlobalTime - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + live (bool): Indicates whether the timeframe should be shifted to end at the current time.. [optional] # noqa: E501 + live_span (WidgetLiveSpan): [optional] # noqa: E501 + end (datetime): The end time.. [optional] # noqa: E501 + start (datetime): The start time.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -185,28 +255,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_graph_size.py b/src/datadog_api_client/v1/model/notebook_graph_size.py index 8c0c8343de..f70081aaac 100644 --- a/src/datadog_api_client/v1/model/notebook_graph_size.py +++ b/src/datadog_api_client/v1/model/notebook_graph_size.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookGraphSize(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NotebookGraphSize - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The size of the graph.., must be one of ["xs", "s", "m", "l", "xl", ] # noqa: E501 + + Keyword Args: + value (str): The size of the graph.., must be one of ["xs", "s", "m", "l", "xl", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_heat_map_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_heat_map_cell_attributes.py index 127796ca24..ddcba5eed7 100644 --- a/src/datadog_api_client/v1/model/notebook_heat_map_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_heat_map_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,93 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookHeatMapCellAttributes - a model defined in OpenAPI + + Args: + definition (HeatMapWidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +273,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_log_stream_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_log_stream_cell_attributes.py index c26a76dff4..3151321f48 100644 --- a/src/datadog_api_client/v1/model/notebook_log_stream_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_log_stream_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookLogStreamCellAttributes - a model defined in OpenAPI + + Args: + definition (LogStreamWidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_markdown_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_markdown_cell_attributes.py index c852c260e6..82f0061326 100644 --- a/src/datadog_api_client/v1/model/notebook_markdown_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_markdown_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "definition": "definition", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookMarkdownCellAttributes - a model defined in OpenAPI + + Args: + definition (NotebookMarkdownCellDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_markdown_cell_definition.py b/src/datadog_api_client/v1/model/notebook_markdown_cell_definition.py index c128883714..9ebb6d419a 100644 --- a/src/datadog_api_client/v1/model/notebook_markdown_cell_definition.py +++ b/src/datadog_api_client/v1/model/notebook_markdown_cell_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, text, type, *args, **kwargs): # noqa: E501 + """NotebookMarkdownCellDefinition - a model defined in OpenAPI + + Args: + text (str): The markdown content. + type (NotebookMarkdownCellDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.text = text + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, text, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_markdown_cell_definition_type.py b/src/datadog_api_client/v1/model/notebook_markdown_cell_definition_type.py index 128400d7a7..dc74bc52c7 100644 --- a/src/datadog_api_client/v1/model/notebook_markdown_cell_definition_type.py +++ b/src/datadog_api_client/v1/model/notebook_markdown_cell_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookMarkdownCellDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NotebookMarkdownCellDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the markdown cell.. if omitted defaults to "markdown", must be one of ["markdown", ] # noqa: E501 + + Keyword Args: + value (str): Type of the markdown cell.. if omitted defaults to "markdown", must be one of ["markdown", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "markdown" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_relative_time.py b/src/datadog_api_client/v1/model/notebook_relative_time.py index ab9af7d601..6b67bb9f69 100644 --- a/src/datadog_api_client/v1/model/notebook_relative_time.py +++ b/src/datadog_api_client/v1/model/notebook_relative_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "live_span": "live_span", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, live_span, *args, **kwargs): # noqa: E501 + """NotebookRelativeTime - a model defined in OpenAPI + + Args: + live_span (WidgetLiveSpan): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.live_span = live_span + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, live_span, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_resource_type.py b/src/datadog_api_client/v1/model/notebook_resource_type.py index 54121119fe..fcfa80b4dc 100644 --- a/src/datadog_api_client/v1/model/notebook_resource_type.py +++ b/src/datadog_api_client/v1/model/notebook_resource_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookResourceType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NotebookResourceType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Notebook resource.. if omitted defaults to "notebooks", must be one of ["notebooks", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Notebook resource.. if omitted defaults to "notebooks", must be one of ["notebooks", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "notebooks" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_response.py b/src/datadog_api_client/v1/model/notebook_response.py index d21adfeb15..2e3a5b941b 100644 --- a/src/datadog_api_client/v1/model/notebook_response.py +++ b/src/datadog_api_client/v1/model/notebook_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (NotebookResponseData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_response_data.py b/src/datadog_api_client/v1/model/notebook_response_data.py index 5fc029537e..40265e3d19 100644 --- a/src/datadog_api_client/v1/model/notebook_response_data.py +++ b/src/datadog_api_client/v1/model/notebook_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,96 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """NotebookResponseData - a model defined in OpenAPI + + Args: + attributes (NotebookResponseDataAttributes): + id (int): Unique notebook ID, assigned when you create the notebook. + type (NotebookResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -103,12 +193,11 @@ def discriminator(): ) @convert_js_args_to_python_args - def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 + def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 """NotebookResponseData - a model defined in OpenAPI Args: attributes (NotebookResponseDataAttributes): - id (int): Unique notebook ID, assigned when you create the notebook. type (NotebookResourceType): Keyword Args: @@ -169,7 +258,6 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.attributes = attributes - self.id = id self.type = type for var_name, var_value in kwargs.items(): if ( @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_response_data_attributes.py b/src/datadog_api_client/v1/model/notebook_response_data_attributes.py index 0998c04462..83f12ec676 100644 --- a/src/datadog_api_client/v1/model/notebook_response_data_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_response_data_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -106,8 +108,101 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "modified", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, cells, name, time, *args, **kwargs): # noqa: E501 + """NotebookResponseDataAttributes - a model defined in OpenAPI + + Args: + cells ([NotebookCellResponse]): List of cells to display in the notebook. + name (str): The name of the notebook. + time (NotebookGlobalTime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author (NotebookAuthor): [optional] # noqa: E501 + created (datetime): UTC time stamp for when the notebook was created.. [optional] # noqa: E501 + modified (datetime): UTC time stamp for when the notebook was last modified.. [optional] # noqa: E501 + status (NotebookStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.cells = cells + self.name = name + self.time = time + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -202,3 +297,8 @@ def __init__(self, cells, name, time, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_split_by.py b/src/datadog_api_client/v1/model/notebook_split_by.py index 5b9df1e68b..7dd9591dcc 100644 --- a/src/datadog_api_client/v1/model/notebook_split_by.py +++ b/src/datadog_api_client/v1/model/notebook_split_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookSplitBy(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, keys, tags, *args, **kwargs): # noqa: E501 + """NotebookSplitBy - a model defined in OpenAPI + + Args: + keys ([str]): Keys to split on. + tags ([str]): Tags to split on. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.keys = keys + self.tags = tags + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, keys, tags, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_status.py b/src/datadog_api_client/v1/model/notebook_status.py index f434165134..0246dc1124 100644 --- a/src/datadog_api_client/v1/model/notebook_status.py +++ b/src/datadog_api_client/v1/model/notebook_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebookStatus(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """NotebookStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Publication status of the notebook. For now, always \"published\".. if omitted defaults to "published", must be one of ["published", ] # noqa: E501 + + Keyword Args: + value (str): Publication status of the notebook. For now, always \"published\".. if omitted defaults to "published", must be one of ["published", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "published" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/notebook_timeseries_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_timeseries_cell_attributes.py index ead6ed403e..f8916cd87e 100644 --- a/src/datadog_api_client/v1/model/notebook_timeseries_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_timeseries_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,93 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookTimeseriesCellAttributes - a model defined in OpenAPI + + Args: + definition (TimeseriesWidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +273,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_toplist_cell_attributes.py b/src/datadog_api_client/v1/model/notebook_toplist_cell_attributes.py index d63a0717f7..4c787b8dac 100644 --- a/src/datadog_api_client/v1/model/notebook_toplist_cell_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_toplist_cell_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,93 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """NotebookToplistCellAttributes - a model defined in OpenAPI + + Args: + definition (ToplistWidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + graph_size (NotebookGraphSize): [optional] # noqa: E501 + split_by (NotebookSplitBy): [optional] # noqa: E501 + time (NotebookCellTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +273,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_update_cell.py b/src/datadog_api_client/v1/model/notebook_update_cell.py index 1c2efae827..d4ffa44072 100644 --- a/src/datadog_api_client/v1/model/notebook_update_cell.py +++ b/src/datadog_api_client/v1/model/notebook_update_cell.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class NotebookUpdateCell(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,90 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebookUpdateCell - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (NotebookCellUpdateRequestAttributes): [optional] # noqa: E501 + type (NotebookCellResourceType): [optional] # noqa: E501 + id (str): Notebook cell ID.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -186,28 +255,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/notebook_update_data.py b/src/datadog_api_client/v1/model/notebook_update_data.py index 869adf38e1..84210fdb4e 100644 --- a/src/datadog_api_client/v1/model/notebook_update_data.py +++ b/src/datadog_api_client/v1/model/notebook_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """NotebookUpdateData - a model defined in OpenAPI + + Args: + attributes (NotebookUpdateDataAttributes): + type (NotebookResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_update_data_attributes.py b/src/datadog_api_client/v1/model/notebook_update_data_attributes.py index 343ce3578b..54f20f1aa6 100644 --- a/src/datadog_api_client/v1/model/notebook_update_data_attributes.py +++ b/src/datadog_api_client/v1/model/notebook_update_data_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -98,8 +100,95 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, cells, name, time, *args, **kwargs): # noqa: E501 + """NotebookUpdateDataAttributes - a model defined in OpenAPI + + Args: + cells ([NotebookUpdateCell]): List of cells to display in the notebook. + name (str): The name of the notebook. + time (NotebookGlobalTime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (NotebookStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.cells = cells + self.name = name + self.time = time + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -191,3 +280,8 @@ def __init__(self, cells, name, time, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebook_update_request.py b/src/datadog_api_client/v1/model/notebook_update_request.py index aeb2b5a4db..04ea697394 100644 --- a/src/datadog_api_client/v1/model/notebook_update_request.py +++ b/src/datadog_api_client/v1/model/notebook_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """NotebookUpdateRequest - a model defined in OpenAPI + + Args: + data (NotebookUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebooks_response.py b/src/datadog_api_client/v1/model/notebooks_response.py index ddf3ddce96..2185013c3b 100644 --- a/src/datadog_api_client/v1/model/notebooks_response.py +++ b/src/datadog_api_client/v1/model/notebooks_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebooksResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([NotebooksResponseData]): List of notebook definitions.. [optional] # noqa: E501 + meta (NotebooksResponseMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebooks_response_data.py b/src/datadog_api_client/v1/model/notebooks_response_data.py index a35e37f6e3..41fe5f6618 100644 --- a/src/datadog_api_client/v1/model/notebooks_response_data.py +++ b/src/datadog_api_client/v1/model/notebooks_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,96 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """NotebooksResponseData - a model defined in OpenAPI + + Args: + attributes (NotebooksResponseDataAttributes): + id (int): Unique notebook ID, assigned when you create the notebook. + type (NotebookResourceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -103,12 +193,11 @@ def discriminator(): ) @convert_js_args_to_python_args - def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 + def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 """NotebooksResponseData - a model defined in OpenAPI Args: attributes (NotebooksResponseDataAttributes): - id (int): Unique notebook ID, assigned when you create the notebook. type (NotebookResourceType): Keyword Args: @@ -169,7 +258,6 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.attributes = attributes - self.id = id self.type = type for var_name, var_value in kwargs.items(): if ( @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebooks_response_data_attributes.py b/src/datadog_api_client/v1/model/notebooks_response_data_attributes.py index 2b1b420044..e3bac5faf1 100644 --- a/src/datadog_api_client/v1/model/notebooks_response_data_attributes.py +++ b/src/datadog_api_client/v1/model/notebooks_response_data_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -106,8 +108,99 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "modified", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """NotebooksResponseDataAttributes - a model defined in OpenAPI + + Args: + name (str): The name of the notebook. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author (NotebookAuthor): [optional] # noqa: E501 + cells ([NotebookCellResponse]): List of cells to display in the notebook.. [optional] # noqa: E501 + created (datetime): UTC time stamp for when the notebook was created.. [optional] # noqa: E501 + modified (datetime): UTC time stamp for when the notebook was last modified.. [optional] # noqa: E501 + status (NotebookStatus): [optional] # noqa: E501 + time (NotebookGlobalTime): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +293,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebooks_response_meta.py b/src/datadog_api_client/v1/model/notebooks_response_meta.py index a0bd659970..205eef09f5 100644 --- a/src/datadog_api_client/v1/model/notebooks_response_meta.py +++ b/src/datadog_api_client/v1/model/notebooks_response_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebooksResponseMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (NotebooksResponsePage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/notebooks_response_page.py b/src/datadog_api_client/v1/model/notebooks_response_page.py index 85c2805266..3304c05843 100644 --- a/src/datadog_api_client/v1/model/notebooks_response_page.py +++ b/src/datadog_api_client/v1/model/notebooks_response_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class NotebooksResponsePage(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "total_filtered_count": "total_filtered_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """NotebooksResponsePage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): The total number of notebooks that would be returned if the request was not filtered by `start` and `count` parameters.. [optional] # noqa: E501 + total_filtered_count (int): The total number of notebooks returned.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization.py b/src/datadog_api_client/v1/model/organization.py index efc084c3b6..5e4aebd824 100644 --- a/src/datadog_api_client/v1/model/organization.py +++ b/src/datadog_api_client/v1/model/organization.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,95 @@ def discriminator(): "subscription": "subscription", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Organization - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + billing (OrganizationBilling): [optional] # noqa: E501 + created (str): Date of the organization creation.. [optional] # noqa: E501 + description (str): Description of the organization.. [optional] # noqa: E501 + name (str): The name of the new child-organization, limited to 32 characters.. [optional] # noqa: E501 + public_id (str): The `public_id` of the organization you are operating within.. [optional] # noqa: E501 + settings (OrganizationSettings): [optional] # noqa: E501 + subscription (OrganizationSubscription): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +281,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_billing.py b/src/datadog_api_client/v1/model/organization_billing.py index a70c3fc5b5..625d1fb275 100644 --- a/src/datadog_api_client/v1/model/organization_billing.py +++ b/src/datadog_api_client/v1/model/organization_billing.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationBilling(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationBilling - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + type (str): The type of billing. Only `parent_billing` is supported.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_create_body.py b/src/datadog_api_client/v1/model/organization_create_body.py index 587ba48bca..286a44296f 100644 --- a/src/datadog_api_client/v1/model/organization_create_body.py +++ b/src/datadog_api_client/v1/model/organization_create_body.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "subscription": "subscription", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """OrganizationCreateBody - a model defined in OpenAPI + + Args: + name (str): The name of the new child-organization, limited to 32 characters. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + billing (OrganizationBilling): [optional] # noqa: E501 + subscription (OrganizationSubscription): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_create_response.py b/src/datadog_api_client/v1/model/organization_create_response.py index c30ac5e165..d265c5ca3b 100644 --- a/src/datadog_api_client/v1/model/organization_create_response.py +++ b/src/datadog_api_client/v1/model/organization_create_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,90 @@ def discriminator(): "user": "user", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationCreateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + api_key (ApiKey): [optional] # noqa: E501 + application_key (ApplicationKey): [optional] # noqa: E501 + org (Organization): [optional] # noqa: E501 + user (User): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_list_response.py b/src/datadog_api_client/v1/model/organization_list_response.py index 40d14aec8d..23dc93a423 100644 --- a/src/datadog_api_client/v1/model/organization_list_response.py +++ b/src/datadog_api_client/v1/model/organization_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "orgs": "orgs", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + orgs ([Organization]): Array of organization objects.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_response.py b/src/datadog_api_client/v1/model/organization_response.py index 68f9322040..0405d8612a 100644 --- a/src/datadog_api_client/v1/model/organization_response.py +++ b/src/datadog_api_client/v1/model/organization_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "org": "org", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + org (Organization): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_settings.py b/src/datadog_api_client/v1/model/organization_settings.py index 65c7478935..a8219ab044 100644 --- a/src/datadog_api_client/v1/model/organization_settings.py +++ b/src/datadog_api_client/v1/model/organization_settings.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -113,8 +115,96 @@ def discriminator(): "saml_strict_mode": "saml_strict_mode", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSettings - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + private_widget_share (bool): Whether or not the organization users can share widgets outside of Datadog.. [optional] # noqa: E501 + saml (OrganizationSettingsSaml): [optional] # noqa: E501 + saml_autocreate_access_role (AccessRole): [optional] # noqa: E501 + saml_autocreate_users_domains (OrganizationSettingsSamlAutocreateUsersDomains): [optional] # noqa: E501 + saml_can_be_enabled (bool): Whether or not SAML can be enabled for this organization.. [optional] # noqa: E501 + saml_idp_endpoint (str): Identity provider endpoint for SAML authentication.. [optional] # noqa: E501 + saml_idp_initiated_login (OrganizationSettingsSamlIdpInitiatedLogin): [optional] # noqa: E501 + saml_idp_metadata_uploaded (bool): Whether or not a SAML identity provider metadata file was provided to the Datadog organization.. [optional] # noqa: E501 + saml_login_url (str): URL for SAML logging.. [optional] # noqa: E501 + saml_strict_mode (OrganizationSettingsSamlStrictMode): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -207,3 +297,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_settings_saml.py b/src/datadog_api_client/v1/model/organization_settings_saml.py index e009276db0..4ab1c749fa 100644 --- a/src/datadog_api_client/v1/model/organization_settings_saml.py +++ b/src/datadog_api_client/v1/model/organization_settings_saml.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationSettingsSaml(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "enabled": "enabled", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSettingsSaml - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + enabled (bool): Whether or not SAML is enabled for this organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_settings_saml_autocreate_users_domains.py b/src/datadog_api_client/v1/model/organization_settings_saml_autocreate_users_domains.py index 3bf6bdad64..495c63723b 100644 --- a/src/datadog_api_client/v1/model/organization_settings_saml_autocreate_users_domains.py +++ b/src/datadog_api_client/v1/model/organization_settings_saml_autocreate_users_domains.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationSettingsSamlAutocreateUsersDomains(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "enabled": "enabled", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSettingsSamlAutocreateUsersDomains - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + domains ([str]): List of domains where the SAML automated user creation is enabled.. [optional] # noqa: E501 + enabled (bool): Whether or not the automated user creation based on SAML domain is enabled.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_settings_saml_idp_initiated_login.py b/src/datadog_api_client/v1/model/organization_settings_saml_idp_initiated_login.py index db96cd534e..954e3c45e1 100644 --- a/src/datadog_api_client/v1/model/organization_settings_saml_idp_initiated_login.py +++ b/src/datadog_api_client/v1/model/organization_settings_saml_idp_initiated_login.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationSettingsSamlIdpInitiatedLogin(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "enabled": "enabled", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSettingsSamlIdpInitiatedLogin - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + enabled (bool): Whether SAML IdP initiated login is enabled, learn more in the [SAML documentation](https://docs.datadoghq.com/account_management/saml/#idp-initiated-login).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_settings_saml_strict_mode.py b/src/datadog_api_client/v1/model/organization_settings_saml_strict_mode.py index e10c514e5f..9d88f62b0f 100644 --- a/src/datadog_api_client/v1/model/organization_settings_saml_strict_mode.py +++ b/src/datadog_api_client/v1/model/organization_settings_saml_strict_mode.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationSettingsSamlStrictMode(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "enabled": "enabled", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSettingsSamlStrictMode - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + enabled (bool): Whether or not the SAML strict mode is enabled. If true, all users must log in with SAML. Learn more on the [SAML Strict documentation](https://docs.datadoghq.com/account_management/saml/#saml-strict).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/organization_subscription.py b/src/datadog_api_client/v1/model/organization_subscription.py index f0bc307f26..0f82a4d75a 100644 --- a/src/datadog_api_client/v1/model/organization_subscription.py +++ b/src/datadog_api_client/v1/model/organization_subscription.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class OrganizationSubscription(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationSubscription - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + type (str): The subscription type. Types available are `trial`, `free`, and `pro`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/pager_duty_service.py b/src/datadog_api_client/v1/model/pager_duty_service.py index c0713325e6..a6830e71f3 100644 --- a/src/datadog_api_client/v1/model/pager_duty_service.py +++ b/src/datadog_api_client/v1/model/pager_duty_service.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class PagerDutyService(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "service_name": "service_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, service_key, service_name, *args, **kwargs): # noqa: E501 + """PagerDutyService - a model defined in OpenAPI + + Args: + service_key (str): Your service key in PagerDuty. + service_name (str): Your service name associated with a service key in PagerDuty. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.service_key = service_key + self.service_name = service_name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, service_key, service_name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/pager_duty_service_key.py b/src/datadog_api_client/v1/model/pager_duty_service_key.py index ded6fa9817..b309385d32 100644 --- a/src/datadog_api_client/v1/model/pager_duty_service_key.py +++ b/src/datadog_api_client/v1/model/pager_duty_service_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class PagerDutyServiceKey(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "service_key": "service_key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, service_key, *args, **kwargs): # noqa: E501 + """PagerDutyServiceKey - a model defined in OpenAPI + + Args: + service_key (str): Your service key in PagerDuty. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.service_key = service_key + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, service_key, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/pager_duty_service_name.py b/src/datadog_api_client/v1/model/pager_duty_service_name.py index dd836af990..3bec9cc978 100644 --- a/src/datadog_api_client/v1/model/pager_duty_service_name.py +++ b/src/datadog_api_client/v1/model/pager_duty_service_name.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class PagerDutyServiceName(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "service_name": "service_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, service_name, *args, **kwargs): # noqa: E501 + """PagerDutyServiceName - a model defined in OpenAPI + + Args: + service_name (str): Your service name associated service key in PagerDuty. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.service_name = service_name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, service_name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/pagination.py b/src/datadog_api_client/v1/model/pagination.py index d8dbe4419c..20105d66ae 100644 --- a/src/datadog_api_client/v1/model/pagination.py +++ b/src/datadog_api_client/v1/model/pagination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class Pagination(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "total_filtered_count": "total_filtered_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Pagination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): Total count.. [optional] # noqa: E501 + total_filtered_count (int): Total count of elements matched by the filter.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/point.py b/src/datadog_api_client/v1/model/point.py index 72110e60c9..edf9d202f9 100644 --- a/src/datadog_api_client/v1/model/point.py +++ b/src/datadog_api_client/v1/model/point.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class Point(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -161,9 +165,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """Point - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([float, none_type]): Array of timeseries points.. # noqa: E501 + + Keyword Args: + value ([float, none_type]): Array of timeseries points.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -189,3 +276,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/process_query_definition.py b/src/datadog_api_client/v1/model/process_query_definition.py index dafcb79857..52311df1a0 100644 --- a/src/datadog_api_client/v1/model/process_query_definition.py +++ b/src/datadog_api_client/v1/model/process_query_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ProcessQueryDefinition(ModelNormal): @@ -86,8 +88,93 @@ def discriminator(): "search_by": "search_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, metric, *args, **kwargs): # noqa: E501 + """ProcessQueryDefinition - a model defined in OpenAPI + + Args: + metric (str): Your chosen metric. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter_by ([str]): List of processes.. [optional] # noqa: E501 + limit (int): Max number of items in the filter list.. [optional] # noqa: E501 + search_by (str): Your chosen search term.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.metric = metric + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +264,8 @@ def __init__(self, metric, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/query_sort_order.py b/src/datadog_api_client/v1/model/query_sort_order.py index f53379052c..cb00aee251 100644 --- a/src/datadog_api_client/v1/model/query_sort_order.py +++ b/src/datadog_api_client/v1/model/query_sort_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class QuerySortOrder(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """QuerySortOrder - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Direction of sort.. if omitted defaults to "desc", must be one of ["asc", "desc", ] # noqa: E501 + + Keyword Args: + value (str): Direction of sort.. if omitted defaults to "desc", must be one of ["asc", "desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "desc" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/query_value_widget_definition.py b/src/datadog_api_client/v1/model/query_value_widget_definition.py index d6aa002124..f74ba74d24 100644 --- a/src/datadog_api_client/v1/model/query_value_widget_definition.py +++ b/src/datadog_api_client/v1/model/query_value_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -116,8 +118,101 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """QueryValueWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([QueryValueWidgetRequest]): Widget definition. + type (QueryValueWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + autoscale (bool): Whether to use auto-scaling or not.. [optional] # noqa: E501 + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + custom_unit (str): Display a unit of your choice on the widget.. [optional] # noqa: E501 + precision (int): Number of decimals to show. If not defined, the widget uses the raw value.. [optional] # noqa: E501 + text_align (WidgetTextAlign): [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -215,3 +310,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/query_value_widget_definition_type.py b/src/datadog_api_client/v1/model/query_value_widget_definition_type.py index 684a16ad0e..2c3c654dc0 100644 --- a/src/datadog_api_client/v1/model/query_value_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/query_value_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class QueryValueWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """QueryValueWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the query value widget.. if omitted defaults to "query_value", must be one of ["query_value", ] # noqa: E501 + + Keyword Args: + value (str): Type of the query value widget.. if omitted defaults to "query_value", must be one of ["query_value", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "query_value" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/query_value_widget_request.py b/src/datadog_api_client/v1/model/query_value_widget_request.py index 13c94bf2c2..42a34d40f8 100644 --- a/src/datadog_api_client/v1/model/query_value_widget_request.py +++ b/src/datadog_api_client/v1/model/query_value_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -123,8 +125,101 @@ def discriminator(): "security_query": "security_query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """QueryValueWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (WidgetAggregator): [optional] # noqa: E501 + apm_query (LogQueryDefinition): [optional] # noqa: E501 + audit_query (LogQueryDefinition): [optional] # noqa: E501 + conditional_formats ([WidgetConditionalFormat]): List of conditional formats.. [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + formulas ([WidgetFormula]): List of formulas that operate on queries. **This feature is currently in beta.**. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): TODO.. [optional] # noqa: E501 + queries ([FormulaAndFunctionQueryDefinition]): List of queries that can be returned directly or used in formulas. **This feature is currently in beta.**. [optional] # noqa: E501 + response_format (FormulaAndFunctionResponseFormat): [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -222,3 +317,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/response_meta_attributes.py b/src/datadog_api_client/v1/model/response_meta_attributes.py index f58531723e..705377dae4 100644 --- a/src/datadog_api_client/v1/model/response_meta_attributes.py +++ b/src/datadog_api_client/v1/model/response_meta_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ResponseMetaAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (Pagination): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/scatter_plot_request.py b/src/datadog_api_client/v1/model/scatter_plot_request.py index 25917aff76..a25ad9a7e8 100644 --- a/src/datadog_api_client/v1/model/scatter_plot_request.py +++ b/src/datadog_api_client/v1/model/scatter_plot_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,96 @@ def discriminator(): "security_query": "security_query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ScatterPlotRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (WidgetAggregator): [optional] # noqa: E501 + apm_query (LogQueryDefinition): [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Query definition.. [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -199,3 +289,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/scatter_plot_widget_definition.py b/src/datadog_api_client/v1/model/scatter_plot_widget_definition.py index 9d90f26c3a..24dede5049 100644 --- a/src/datadog_api_client/v1/model/scatter_plot_widget_definition.py +++ b/src/datadog_api_client/v1/model/scatter_plot_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,100 @@ def discriminator(): "yaxis": "yaxis", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """ScatterPlotWidgetDefinition - a model defined in OpenAPI + + Args: + requests (ScatterPlotWidgetDefinitionRequests): + type (ScatterPlotWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + color_by_groups ([str]): List of groups used for colors.. [optional] # noqa: E501 + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + xaxis (WidgetAxis): [optional] # noqa: E501 + yaxis (WidgetAxis): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -209,3 +303,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/scatter_plot_widget_definition_requests.py b/src/datadog_api_client/v1/model/scatter_plot_widget_definition_requests.py index 7f361be6bd..0b4b1f3f42 100644 --- a/src/datadog_api_client/v1/model/scatter_plot_widget_definition_requests.py +++ b/src/datadog_api_client/v1/model/scatter_plot_widget_definition_requests.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "y": "y", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, x, y, *args, **kwargs): # noqa: E501 + """ScatterPlotWidgetDefinitionRequests - a model defined in OpenAPI + + Args: + x (ScatterPlotRequest): + y (ScatterPlotRequest): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.x = x + self.y = y + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, x, y, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/scatter_plot_widget_definition_type.py b/src/datadog_api_client/v1/model/scatter_plot_widget_definition_type.py index 2880fe907e..9a49a22d7a 100644 --- a/src/datadog_api_client/v1/model/scatter_plot_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/scatter_plot_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ScatterPlotWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ScatterPlotWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the scatter plot widget.. if omitted defaults to "scatterplot", must be one of ["scatterplot", ] # noqa: E501 + + Keyword Args: + value (str): Type of the scatter plot widget.. if omitted defaults to "scatterplot", must be one of ["scatterplot", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "scatterplot" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/series.py b/src/datadog_api_client/v1/model/series.py index 9bc6db8cef..3c16fdf55d 100644 --- a/src/datadog_api_client/v1/model/series.py +++ b/src/datadog_api_client/v1/model/series.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -96,8 +98,96 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, metric, points, *args, **kwargs): # noqa: E501 + """Series - a model defined in OpenAPI + + Args: + metric (str): The name of the timeseries. + points ([Point]): Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + host (str): The name of the host that produced the metric.. [optional] # noqa: E501 + interval (int, none_type): If the type of the metric is rate or count, define the corresponding interval.. [optional] # noqa: E501 + tags ([str]): A list of tags associated with the metric.. [optional] # noqa: E501 + type (str): The type of the metric either `count`, `gauge`, or `rate`.. [optional] if omitted the server will use the default value of "gauge" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.metric = metric + self.points = points + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -190,3 +280,8 @@ def __init__(self, metric, points, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_check.py b/src/datadog_api_client/v1/model/service_check.py index c9f2bd0da5..3b7553e884 100644 --- a/src/datadog_api_client/v1/model/service_check.py +++ b/src/datadog_api_client/v1/model/service_check.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,98 @@ def discriminator(): "timestamp": "timestamp", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, check, host_name, status, tags, *args, **kwargs): # noqa: E501 + """ServiceCheck - a model defined in OpenAPI + + Args: + check (str): The check. + host_name (str): The host name correlated with the check. + status (ServiceCheckStatus): + tags ([str]): Tags related to a check. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + message (str): Message containing check status.. [optional] # noqa: E501 + timestamp (int): Time of check.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.check = check + self.host_name = host_name + self.status = status + self.tags = tags + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +281,8 @@ def __init__(self, check, host_name, status, tags, *args, **kwargs): # noqa: E5 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_check_status.py b/src/datadog_api_client/v1/model/service_check_status.py index 05c9daba61..840481f683 100644 --- a/src/datadog_api_client/v1/model/service_check_status.py +++ b/src/datadog_api_client/v1/model/service_check_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ServiceCheckStatus(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ServiceCheckStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): The status of a service check.., must be one of [0, 1, 2, 3, ] # noqa: E501 + + Keyword Args: + value (int): The status of a service check.., must be one of [0, 1, 2, 3, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/service_checks.py b/src/datadog_api_client/v1/model/service_checks.py index 811c4fb1e8..076762a90f 100644 --- a/src/datadog_api_client/v1/model/service_checks.py +++ b/src/datadog_api_client/v1/model/service_checks.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ServiceChecks - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([ServiceCheck]): The service checks.. # noqa: E501 + + Keyword Args: + value ([ServiceCheck]): The service checks.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/service_level_objective.py b/src/datadog_api_client/v1/model/service_level_objective.py index 7efdfd073c..3d93ead86c 100644 --- a/src/datadog_api_client/v1/model/service_level_objective.py +++ b/src/datadog_api_client/v1/model/service_level_objective.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -116,8 +118,108 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "id", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, thresholds, type, *args, **kwargs): # noqa: E501 + """ServiceLevelObjective - a model defined in OpenAPI + + Args: + name (str): The name of the service level objective object. + thresholds ([SLOThreshold]): The thresholds (timeframes and associated targets) for this service level objective object. + type (SLOType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (int): Creation timestamp (UNIX time in seconds) Always included in service level objective responses.. [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + description (str, none_type): A user-defined description of the service level objective. Always included in service level objective responses (but may be `null`). Optional in create/update requests.. [optional] # noqa: E501 + groups ([str]): A list of (up to 20) monitor groups that narrow the scope of a monitor service level objective. Included in service level objective responses if it is not empty. Optional in create/update requests for monitor service level objectives, but may only be used when then length of the `monitor_ids` field is one.. [optional] # noqa: E501 + id (str): A unique identifier for the service level objective object. Always included in service level objective responses.. [optional] # noqa: E501 + modified_at (int): Modification timestamp (UNIX time in seconds) Always included in service level objective responses.. [optional] # noqa: E501 + monitor_ids ([int]): A list of monitor ids that defines the scope of a monitor service level objective. **Required if type is `monitor`**.. [optional] # noqa: E501 + monitor_tags ([str]): The union of monitor tags for all monitors referenced by the `monitor_ids` field. Always included in service level objective responses for monitor service level objectives (but may be empty). Ignored in create/update requests. Does not affect which monitors are included in the service level objective (that is determined entirely by the `monitor_ids` field).. [optional] # noqa: E501 + query (ServiceLevelObjectiveQuery): [optional] # noqa: E501 + tags ([str]): A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.thresholds = thresholds + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -218,3 +320,8 @@ def __init__(self, name, thresholds, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_level_objective_query.py b/src/datadog_api_client/v1/model/service_level_objective_query.py index 3c57c95df3..f062e73669 100644 --- a/src/datadog_api_client/v1/model/service_level_objective_query.py +++ b/src/datadog_api_client/v1/model/service_level_objective_query.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ServiceLevelObjectiveQuery(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "numerator": "numerator", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, denominator, numerator, *args, **kwargs): # noqa: E501 + """ServiceLevelObjectiveQuery - a model defined in OpenAPI + + Args: + denominator (str): A Datadog metric query for total (valid) events. + numerator (str): A Datadog metric query for good events. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.denominator = denominator + self.numerator = numerator + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, denominator, numerator, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_level_objective_request.py b/src/datadog_api_client/v1/model/service_level_objective_request.py index 513819ec01..844e7b8dc9 100644 --- a/src/datadog_api_client/v1/model/service_level_objective_request.py +++ b/src/datadog_api_client/v1/model/service_level_objective_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -104,8 +106,99 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, thresholds, type, *args, **kwargs): # noqa: E501 + """ServiceLevelObjectiveRequest - a model defined in OpenAPI + + Args: + name (str): The name of the service level objective object. + thresholds ([SLOThreshold]): The thresholds (timeframes and associated targets) for this service level objective object. + type (SLOType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + description (str, none_type): A user-defined description of the service level objective. Always included in service level objective responses (but may be `null`). Optional in create/update requests.. [optional] # noqa: E501 + groups ([str]): A list of (up to 20) monitor groups that narrow the scope of a monitor service level objective. Included in service level objective responses if it is not empty. Optional in create/update requests for monitor service level objectives, but may only be used when then length of the `monitor_ids` field is one.. [optional] # noqa: E501 + monitor_ids ([int]): A list of monitor ids that defines the scope of a monitor service level objective. **Required if type is `monitor`**.. [optional] # noqa: E501 + query (ServiceLevelObjectiveQuery): [optional] # noqa: E501 + tags ([str]): A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.thresholds = thresholds + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -201,3 +294,8 @@ def __init__(self, name, thresholds, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_map_widget_definition.py b/src/datadog_api_client/v1/model/service_map_widget_definition.py index ebb11709c0..23fad0b9e2 100644 --- a/src/datadog_api_client/v1/model/service_map_widget_definition.py +++ b/src/datadog_api_client/v1/model/service_map_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,98 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, filters, service, type, *args, **kwargs): # noqa: E501 + """ServiceMapWidgetDefinition - a model defined in OpenAPI + + Args: + filters ([str]): Your environment and primary tag (or * if enabled for your account). + service (str): The ID of the service you want to map. + type (ServiceMapWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + title (str): The title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.filters = filters + self.service = service + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -199,3 +291,8 @@ def __init__(self, filters, service, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_map_widget_definition_type.py b/src/datadog_api_client/v1/model/service_map_widget_definition_type.py index 7e0108de60..2567f99008 100644 --- a/src/datadog_api_client/v1/model/service_map_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/service_map_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ServiceMapWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ServiceMapWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the service map widget.. if omitted defaults to "servicemap", must be one of ["servicemap", ] # noqa: E501 + + Keyword Args: + value (str): Type of the service map widget.. if omitted defaults to "servicemap", must be one of ["servicemap", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "servicemap" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/service_summary_widget_definition.py b/src/datadog_api_client/v1/model/service_summary_widget_definition.py index 2b8e6b236b..a53780de8e 100644 --- a/src/datadog_api_client/v1/model/service_summary_widget_definition.py +++ b/src/datadog_api_client/v1/model/service_summary_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -121,8 +123,108 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, env, service, span_name, type, *args, **kwargs): # noqa: E501 + """ServiceSummaryWidgetDefinition - a model defined in OpenAPI + + Args: + env (str): APM environment. + service (str): APM service. + span_name (str): APM span name. + type (ServiceSummaryWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + display_format (WidgetServiceSummaryDisplayFormat): [optional] # noqa: E501 + show_breakdown (bool): Whether to show the latency breakdown or not.. [optional] # noqa: E501 + show_distribution (bool): Whether to show the latency distribution or not.. [optional] # noqa: E501 + show_errors (bool): Whether to show the error metrics or not.. [optional] # noqa: E501 + show_hits (bool): Whether to show the hits metrics or not.. [optional] # noqa: E501 + show_latency (bool): Whether to show the latency metrics or not.. [optional] # noqa: E501 + show_resource_list (bool): Whether to show the resource list or not.. [optional] # noqa: E501 + size_format (WidgetSizeFormat): [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.env = env + self.service = service + self.span_name = span_name + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -227,3 +329,8 @@ def __init__(self, env, service, span_name, type, *args, **kwargs): # noqa: E50 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/service_summary_widget_definition_type.py b/src/datadog_api_client/v1/model/service_summary_widget_definition_type.py index 4fb25f8c98..7e62b1b85e 100644 --- a/src/datadog_api_client/v1/model/service_summary_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/service_summary_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ServiceSummaryWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ServiceSummaryWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the service summary widget.. if omitted defaults to "trace_service", must be one of ["trace_service", ] # noqa: E501 + + Keyword Args: + value (str): Type of the service summary widget.. if omitted defaults to "trace_service", must be one of ["trace_service", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "trace_service" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slack_integration_channel.py b/src/datadog_api_client/v1/model/slack_integration_channel.py index fdb0ca9482..0d1cfda5c8 100644 --- a/src/datadog_api_client/v1/model/slack_integration_channel.py +++ b/src/datadog_api_client/v1/model/slack_integration_channel.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SlackIntegrationChannel - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + display (SlackIntegrationChannelDisplay): [optional] # noqa: E501 + name (str): Your channel name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slack_integration_channel_display.py b/src/datadog_api_client/v1/model/slack_integration_channel_display.py index 3aefd1df80..aa8016b0c9 100644 --- a/src/datadog_api_client/v1/model/slack_integration_channel_display.py +++ b/src/datadog_api_client/v1/model/slack_integration_channel_display.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SlackIntegrationChannelDisplay(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SlackIntegrationChannelDisplay - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + message (bool): Show the main body of the alert event.. [optional] if omitted the server will use the default value of True # noqa: E501 + notified (bool): Show the list of @-handles in the alert event.. [optional] if omitted the server will use the default value of True # noqa: E501 + snapshot (bool): Show the alert event's snapshot image.. [optional] if omitted the server will use the default value of True # noqa: E501 + tags (bool): Show the scopes on which the monitor alerted.. [optional] if omitted the server will use the default value of True # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slack_integration_channels.py b/src/datadog_api_client/v1/model/slack_integration_channels.py index a76c5f2357..2e49e0f761 100644 --- a/src/datadog_api_client/v1/model/slack_integration_channels.py +++ b/src/datadog_api_client/v1/model/slack_integration_channels.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SlackIntegrationChannels - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([SlackIntegrationChannel]): A list of configured Slack channels.. # noqa: E501 + + Keyword Args: + value ([SlackIntegrationChannel]): A list of configured Slack channels.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_bulk_delete.py b/src/datadog_api_client/v1/model/slo_bulk_delete.py index e3c7ba8471..406e637caf 100644 --- a/src/datadog_api_client/v1/model/slo_bulk_delete.py +++ b/src/datadog_api_client/v1/model/slo_bulk_delete.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -86,8 +88,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOBulkDelete - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_bulk_delete_error.py b/src/datadog_api_client/v1/model/slo_bulk_delete_error.py index d1963fbc1a..253573eb9c 100644 --- a/src/datadog_api_client/v1/model/slo_bulk_delete_error.py +++ b/src/datadog_api_client/v1/model/slo_bulk_delete_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,94 @@ def discriminator(): "timeframe": "timeframe", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, message, timeframe, *args, **kwargs): # noqa: E501 + """SLOBulkDeleteError - a model defined in OpenAPI + + Args: + id (str): The ID of the service level objective object associated with this error. + message (str): The error message. + timeframe (SLOErrorTimeframe): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.message = message + self.timeframe = timeframe + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +267,8 @@ def __init__(self, id, message, timeframe, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_bulk_delete_response.py b/src/datadog_api_client/v1/model/slo_bulk_delete_response.py index 135cf43c2e..39c2da8b5a 100644 --- a/src/datadog_api_client/v1/model/slo_bulk_delete_response.py +++ b/src/datadog_api_client/v1/model/slo_bulk_delete_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOBulkDeleteResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOBulkDeleteResponseData): [optional] # noqa: E501 + errors ([SLOBulkDeleteError]): Array of errors object returned.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_bulk_delete_response_data.py b/src/datadog_api_client/v1/model/slo_bulk_delete_response_data.py index bd06cb612a..e4d9d036d0 100644 --- a/src/datadog_api_client/v1/model/slo_bulk_delete_response_data.py +++ b/src/datadog_api_client/v1/model/slo_bulk_delete_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOBulkDeleteResponseData(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "updated": "updated", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOBulkDeleteResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted ([str]): An array of service level objective object IDs that indicates which objects that were completely deleted.. [optional] # noqa: E501 + updated ([str]): An array of service level objective object IDs that indicates which objects that were modified (objects for which at least one threshold was deleted, but that were not completely deleted).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction.py b/src/datadog_api_client/v1/model/slo_correction.py index ba472dfa2e..88253dd8c6 100644 --- a/src/datadog_api_client/v1/model/slo_correction.py +++ b/src/datadog_api_client/v1/model/slo_correction.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrection - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (SLOCorrectionResponseAttributes): [optional] # noqa: E501 + id (str): The ID of the SLO correction. [optional] # noqa: E501 + type (SLOCorrectionType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_category.py b/src/datadog_api_client/v1/model/slo_correction_category.py index cf12d54bd5..7aa3babc2b 100644 --- a/src/datadog_api_client/v1/model/slo_correction_category.py +++ b/src/datadog_api_client/v1/model/slo_correction_category.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOCorrectionCategory(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOCorrectionCategory - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Category the SLO correction belongs to., must be one of ["Scheduled Maintenance", "Outside Business Hours", "Deployment", "Other", ] # noqa: E501 + + Keyword Args: + value (str): Category the SLO correction belongs to., must be one of ["Scheduled Maintenance", "Outside Business Hours", "Deployment", "Other", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_correction_create_data.py b/src/datadog_api_client/v1/model/slo_correction_create_data.py index 4a6b1d910a..1f74cbfee1 100644 --- a/src/datadog_api_client/v1/model/slo_correction_create_data.py +++ b/src/datadog_api_client/v1/model/slo_correction_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionCreateData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (SLOCorrectionCreateRequestAttributes): [optional] # noqa: E501 + type (SLOCorrectionType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_create_request.py b/src/datadog_api_client/v1/model/slo_correction_create_request.py index cbea257245..5a7352ebfa 100644 --- a/src/datadog_api_client/v1/model/slo_correction_create_request.py +++ b/src/datadog_api_client/v1/model/slo_correction_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionCreateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOCorrectionCreateData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_create_request_attributes.py b/src/datadog_api_client/v1/model/slo_correction_create_request_attributes.py index 280db5d5a9..4730953520 100644 --- a/src/datadog_api_client/v1/model/slo_correction_create_request_attributes.py +++ b/src/datadog_api_client/v1/model/slo_correction_create_request_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,98 @@ def discriminator(): "timezone": "timezone", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, category, end, slo_id, start, *args, **kwargs): # noqa: E501 + """SLOCorrectionCreateRequestAttributes - a model defined in OpenAPI + + Args: + category (SLOCorrectionCategory): + end (int): Ending time of the correction in epoch seconds + slo_id (str): ID of the SLO that this correction will be applied to + start (int): Starting time of the correction in epoch seconds + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + description (str): Description of the correction being made.. [optional] # noqa: E501 + timezone (str): The timezone to display in the UI for the correction times (defaults to \"UTC\"). [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.category = category + self.end = end + self.slo_id = slo_id + self.start = start + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +281,8 @@ def __init__(self, category, end, slo_id, start, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_list_response.py b/src/datadog_api_client/v1/model/slo_correction_list_response.py index 5da68f8e61..e908b4e71c 100644 --- a/src/datadog_api_client/v1/model/slo_correction_list_response.py +++ b/src/datadog_api_client/v1/model/slo_correction_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([SLOCorrection]): The list of of SLO corrections objects. [optional] # noqa: E501 + meta (ResponseMetaAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_response.py b/src/datadog_api_client/v1/model/slo_correction_response.py index f35fa4570e..018b2e61e4 100644 --- a/src/datadog_api_client/v1/model/slo_correction_response.py +++ b/src/datadog_api_client/v1/model/slo_correction_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOCorrection): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_response_attributes.py b/src/datadog_api_client/v1/model/slo_correction_response_attributes.py index 952d15a284..424094ca52 100644 --- a/src/datadog_api_client/v1/model/slo_correction_response_attributes.py +++ b/src/datadog_api_client/v1/model/slo_correction_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,93 @@ def discriminator(): "timezone": "timezone", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionResponseAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + category (SLOCorrectionCategory): [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + description (str): Description of the correction being made.. [optional] # noqa: E501 + end (int): Ending time of the correction in epoch seconds. [optional] # noqa: E501 + slo_id (str): ID of the SLO that this correction will be applied to. [optional] # noqa: E501 + start (int): Starting time of the correction in epoch seconds. [optional] # noqa: E501 + timezone (str): The timezone to display in the UI for the correction times (defaults to \"UTC\"). [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +275,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_type.py b/src/datadog_api_client/v1/model/slo_correction_type.py index 34d4f08e8c..a6fcd9e789 100644 --- a/src/datadog_api_client/v1/model/slo_correction_type.py +++ b/src/datadog_api_client/v1/model/slo_correction_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOCorrectionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOCorrectionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): SLO correction resource type.. if omitted defaults to "correction", must be one of ["correction", ] # noqa: E501 + + Keyword Args: + value (str): SLO correction resource type.. if omitted defaults to "correction", must be one of ["correction", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "correction" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_correction_update_data.py b/src/datadog_api_client/v1/model/slo_correction_update_data.py index 92bd9b8644..f1f89fd3ac 100644 --- a/src/datadog_api_client/v1/model/slo_correction_update_data.py +++ b/src/datadog_api_client/v1/model/slo_correction_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionUpdateData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (SLOCorrectionUpdateRequestAttributes): [optional] # noqa: E501 + type (SLOCorrectionType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_update_request.py b/src/datadog_api_client/v1/model/slo_correction_update_request.py index 7b5388d8db..7eacb824dc 100644 --- a/src/datadog_api_client/v1/model/slo_correction_update_request.py +++ b/src/datadog_api_client/v1/model/slo_correction_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionUpdateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOCorrectionUpdateData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_correction_update_request_attributes.py b/src/datadog_api_client/v1/model/slo_correction_update_request_attributes.py index 1c67037754..e6b29baee7 100644 --- a/src/datadog_api_client/v1/model/slo_correction_update_request_attributes.py +++ b/src/datadog_api_client/v1/model/slo_correction_update_request_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,91 @@ def discriminator(): "timezone": "timezone", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOCorrectionUpdateRequestAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + category (SLOCorrectionCategory): [optional] # noqa: E501 + description (str): Description of the correction being made.. [optional] # noqa: E501 + end (int): Ending time of the correction in epoch seconds. [optional] # noqa: E501 + start (int): Starting time of the correction in epoch seconds. [optional] # noqa: E501 + timezone (str): The timezone to display in the UI for the correction times (defaults to \"UTC\"). [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -180,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_delete_response.py b/src/datadog_api_client/v1/model/slo_delete_response.py index 37b8cb76ef..a3f9d9b426 100644 --- a/src/datadog_api_client/v1/model/slo_delete_response.py +++ b/src/datadog_api_client/v1/model/slo_delete_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLODeleteResponse(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLODeleteResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([str]): An array containing the ID of the deleted service level objective object.. [optional] # noqa: E501 + errors ({str: (str,)}): An dictionary containing the ID of the SLO as key and a deletion error as value.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_error_budget_remaining_data.py b/src/datadog_api_client/v1/model/slo_error_budget_remaining_data.py index b9d21ee277..0b5045d4d3 100644 --- a/src/datadog_api_client/v1/model/slo_error_budget_remaining_data.py +++ b/src/datadog_api_client/v1/model/slo_error_budget_remaining_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOErrorBudgetRemainingData(ModelNormal): @@ -78,8 +80,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOErrorBudgetRemainingData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -162,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_error_timeframe.py b/src/datadog_api_client/v1/model/slo_error_timeframe.py index 363c4a8a5e..b438ccaea4 100644 --- a/src/datadog_api_client/v1/model/slo_error_timeframe.py +++ b/src/datadog_api_client/v1/model/slo_error_timeframe.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOErrorTimeframe(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOErrorTimeframe - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The timeframe of the threshold associated with this error or \"all\" if all thresholds are affected.., must be one of ["7d", "30d", "90d", "all", ] # noqa: E501 + + Keyword Args: + value (str): The timeframe of the threshold associated with this error or \"all\" if all thresholds are affected.., must be one of ["7d", "30d", "90d", "all", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_history_metrics.py b/src/datadog_api_client/v1/model/slo_history_metrics.py index fefe353fc3..bbdffc2a8b 100644 --- a/src/datadog_api_client/v1/model/slo_history_metrics.py +++ b/src/datadog_api_client/v1/model/slo_history_metrics.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,105 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data( + cls, denominator, interval, numerator, query, res_type, resp_version, times, *args, **kwargs + ): # noqa: E501 + """SLOHistoryMetrics - a model defined in OpenAPI + + Args: + denominator (SLOHistoryMetricsSeries): + interval (int): The aggregated query interval for the series data. It's implicit based on the query time window. + numerator (SLOHistoryMetricsSeries): + query (str): The combined numerator and denominator query CSV. + res_type (str): The series result type. This mimics `batch_query` response type. + resp_version (int): The series response version type. This mimics `batch_query` response type. + times ([float]): An array of query timestamps in EPOCH milliseconds + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + message (str): Optional message if there are specific query issues/warnings.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.denominator = denominator + self.interval = interval + self.numerator = numerator + self.query = query + self.res_type = res_type + self.resp_version = resp_version + self.times = times + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +299,8 @@ def __init__( # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_metrics_series.py b/src/datadog_api_client/v1/model/slo_history_metrics_series.py index be2bc0d99d..3078e5de02 100644 --- a/src/datadog_api_client/v1/model/slo_history_metrics_series.py +++ b/src/datadog_api_client/v1/model/slo_history_metrics_series.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,96 @@ def discriminator(): "values": "values", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, count, metadata, sum, values, *args, **kwargs): # noqa: E501 + """SLOHistoryMetricsSeries - a model defined in OpenAPI + + Args: + count (int): Count of submitted metrics. + metadata (SLOHistoryMetricsSeriesMetadata): + sum (float): Total sum of the query. + values ([float]): The query values for each metric. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.count = count + self.metadata = metadata + self.sum = sum + self.values = values + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +273,8 @@ def __init__(self, count, metadata, sum, values, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata.py b/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata.py index 80e9f2d97a..25c8a22400 100644 --- a/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata.py +++ b/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -96,8 +98,92 @@ def discriminator(): "unit": "unit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistoryMetricsSeriesMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggr (str): Query aggregator function.. [optional] # noqa: E501 + expression (str): Query expression.. [optional] # noqa: E501 + metric (str): Query metric used.. [optional] # noqa: E501 + query_index (int): Query index from original combined query.. [optional] # noqa: E501 + scope (str): Query scope.. [optional] # noqa: E501 + unit ([SLOHistoryMetricsSeriesMetadataUnit], none_type): An array of metric units that contains up to two unit objects. For example, bytes represents one unit object and bytes per second represents two unit objects. If a metric query only has one unit object, the second array element is null.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +272,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata_unit.py b/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata_unit.py index 1639d3b65f..d8454d8f8a 100644 --- a/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata_unit.py +++ b/src/datadog_api_client/v1/model/slo_history_metrics_series_metadata_unit.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOHistoryMetricsSeriesMetadataUnit(ModelNormal): @@ -92,8 +94,92 @@ def discriminator(): "short_name": "short_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistoryMetricsSeriesMetadataUnit - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + family (str): The family of metric unit, for example `bytes` is the family for `kibibyte`, `byte`, and `bit` units.. [optional] # noqa: E501 + id (int): The ID of the metric unit.. [optional] # noqa: E501 + name (str): The unit of the metric, for instance `byte`.. [optional] # noqa: E501 + plural (str, none_type): The plural Unit of metric, for instance `bytes`.. [optional] # noqa: E501 + scale_factor (float): The scale factor of metric unit, for instance `1.0`.. [optional] # noqa: E501 + short_name (str, none_type): A shorter and abbreviated version of the metric unit, for instance `B`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +268,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_response.py b/src/datadog_api_client/v1/model/slo_history_response.py index a502ec75e1..17842ad626 100644 --- a/src/datadog_api_client/v1/model/slo_history_response.py +++ b/src/datadog_api_client/v1/model/slo_history_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistoryResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOHistoryResponseData): [optional] # noqa: E501 + errors ([SLOHistoryResponseError]): A list of errors while querying the history data for the service level objective.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_response_data.py b/src/datadog_api_client/v1/model/slo_history_response_data.py index 6e4f29e362..f8696fea2c 100644 --- a/src/datadog_api_client/v1/model/slo_history_response_data.py +++ b/src/datadog_api_client/v1/model/slo_history_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -109,8 +111,96 @@ def discriminator(): "type_id": "type_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistoryResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + from_ts (int): The `from` timestamp in epoch seconds.. [optional] # noqa: E501 + group_by ([str]): For `metric` based SLOs where the query includes a group-by clause, this represents the list of grouping parameters. This is not included in responses for `monitor` based SLOs.. [optional] # noqa: E501 + groups ([SLOHistorySLIData]): For grouped SLOs, this represents SLI data for specific groups. This is not included in the responses for `metric` based SLOs.. [optional] # noqa: E501 + monitors ([SLOHistorySLIData]): For multi-monitor SLOs, this represents SLI data for specific monitors. This is not included in the responses for `metric` based SLOs.. [optional] # noqa: E501 + overall (SLOHistorySLIData): [optional] # noqa: E501 + series (SLOHistoryMetrics): [optional] # noqa: E501 + thresholds ({str: (SLOThreshold,)}): mapping of string timeframe to the SLO threshold.. [optional] # noqa: E501 + to_ts (int): The `to` timestamp in epoch seconds.. [optional] # noqa: E501 + type (SLOType): [optional] # noqa: E501 + type_id (SLOTypeNumeric): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +293,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_response_error.py b/src/datadog_api_client/v1/model/slo_history_response_error.py index 84c8ed56fc..5359749ebf 100644 --- a/src/datadog_api_client/v1/model/slo_history_response_error.py +++ b/src/datadog_api_client/v1/model/slo_history_response_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOHistoryResponseError(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "error": "error", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistoryResponseError - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): Human readable error.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_history_sli_data.py b/src/datadog_api_client/v1/model/slo_history_sli_data.py index 48d847ea45..0f45fc7b0a 100644 --- a/src/datadog_api_client/v1/model/slo_history_sli_data.py +++ b/src/datadog_api_client/v1/model/slo_history_sli_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,98 @@ def discriminator(): "uptime": "uptime", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOHistorySLIData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error_budget_remaining (SLOErrorBudgetRemainingData): [optional] # noqa: E501 + errors ([SLOHistoryResponseError]): A list of errors while querying the history data for the service level objective.. [optional] # noqa: E501 + group (str): For groups in a grouped SLO, this is the group name.. [optional] # noqa: E501 + history ([[float]]): For `monitor` based SLOs, this includes the aggregated history uptime time series.. [optional] # noqa: E501 + monitor_modified (int): For `monitor` based SLOs, this is the last modified timestamp in epoch seconds of the monitor.. [optional] # noqa: E501 + monitor_type (str): For `monitor` based SLOs, this describes the type of monitor.. [optional] # noqa: E501 + name (str): For groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.. [optional] # noqa: E501 + precision ({str: (float,)}): A mapping of threshold `timeframe` to number of accurate decimals, regardless of the from && to timestamp.. [optional] # noqa: E501 + preview (bool): For `monitor` based SLOs, when `true` this indicates that a replay is in progress to give an accurate uptime calculation.. [optional] # noqa: E501 + sli_value (float): The current SLI value of the SLO over the history window.. [optional] # noqa: E501 + span_precision (float): The amount of decimal places the SLI value is accurate to for the given from `&&` to timestamp.. [optional] # noqa: E501 + uptime (float): Use `sli_value` instead.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +295,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_list_response.py b/src/datadog_api_client/v1/model/slo_list_response.py index f3a9ec2b73..103d10cc29 100644 --- a/src/datadog_api_client/v1/model/slo_list_response.py +++ b/src/datadog_api_client/v1/model/slo_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "metadata": "metadata", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([ServiceLevelObjective]): An array of service level objective objects.. [optional] # noqa: E501 + errors ([str]): An array of error messages. Each endpoint documents how/whether this field is used.. [optional] # noqa: E501 + metadata (SLOListResponseMetadata): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_list_response_metadata.py b/src/datadog_api_client/v1/model/slo_list_response_metadata.py index 03171c4bd3..50b5399853 100644 --- a/src/datadog_api_client/v1/model/slo_list_response_metadata.py +++ b/src/datadog_api_client/v1/model/slo_list_response_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOListResponseMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (SLOListResponseMetadataPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_list_response_metadata_page.py b/src/datadog_api_client/v1/model/slo_list_response_metadata_page.py index b7777086e9..b38217ef3b 100644 --- a/src/datadog_api_client/v1/model/slo_list_response_metadata_page.py +++ b/src/datadog_api_client/v1/model/slo_list_response_metadata_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOListResponseMetadataPage(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "total_filtered_count": "total_filtered_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOListResponseMetadataPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): The total number of resources that could be retrieved ignoring the parameters and filters in the request.. [optional] # noqa: E501 + total_filtered_count (int): The total number of resources that match the parameters and filters in the request. This attribute can be used by a client to determine the total number of pages.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_response.py b/src/datadog_api_client/v1/model/slo_response.py index 62c6dadfe4..b90326a32f 100644 --- a/src/datadog_api_client/v1/model/slo_response.py +++ b/src/datadog_api_client/v1/model/slo_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SLOResponseData): [optional] # noqa: E501 + errors ([str]): An array of error messages. Each endpoint documents how/whether this field is used.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_response_data.py b/src/datadog_api_client/v1/model/slo_response_data.py index cd7289f47d..3149397f17 100644 --- a/src/datadog_api_client/v1/model/slo_response_data.py +++ b/src/datadog_api_client/v1/model/slo_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -118,8 +120,104 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "id", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SLOResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + configured_alert_ids ([int]): A list of SLO monitors IDs that reference this SLO. This field is returned only when `with_configured_alert_ids` parameter is true in query.. [optional] # noqa: E501 + created_at (int): Creation timestamp (UNIX time in seconds) Always included in service level objective responses.. [optional] # noqa: E501 + creator (Creator): [optional] # noqa: E501 + description (str, none_type): A user-defined description of the service level objective. Always included in service level objective responses (but may be `null`). Optional in create/update requests.. [optional] # noqa: E501 + groups ([str]): A list of (up to 20) monitor groups that narrow the scope of a monitor service level objective. Included in service level objective responses if it is not empty. Optional in create/update requests for monitor service level objectives, but may only be used when then length of the `monitor_ids` field is one.. [optional] # noqa: E501 + id (str): A unique identifier for the service level objective object. Always included in service level objective responses.. [optional] # noqa: E501 + modified_at (int): Modification timestamp (UNIX time in seconds) Always included in service level objective responses.. [optional] # noqa: E501 + monitor_ids ([int]): A list of monitor ids that defines the scope of a monitor service level objective. **Required if type is `monitor`**.. [optional] # noqa: E501 + monitor_tags ([str]): The union of monitor tags for all monitors referenced by the `monitor_ids` field. Always included in service level objective responses for monitor service level objectives (but may be empty). Ignored in create/update requests. Does not affect which monitors are included in the service level objective (that is determined entirely by the `monitor_ids` field).. [optional] # noqa: E501 + name (str): The name of the service level objective object.. [optional] # noqa: E501 + query (ServiceLevelObjectiveQuery): [optional] # noqa: E501 + tags ([str]): A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.. [optional] # noqa: E501 + thresholds ([SLOThreshold]): The thresholds (timeframes and associated targets) for this service level objective object.. [optional] # noqa: E501 + type (SLOType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -216,3 +314,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_threshold.py b/src/datadog_api_client/v1/model/slo_threshold.py index 5bb6f37836..f12f8e6cd2 100644 --- a/src/datadog_api_client/v1/model/slo_threshold.py +++ b/src/datadog_api_client/v1/model/slo_threshold.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "warning_display": "warning_display", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, target, timeframe, *args, **kwargs): # noqa: E501 + """SLOThreshold - a model defined in OpenAPI + + Args: + target (float): The target value for the service level indicator within the corresponding timeframe. + timeframe (SLOTimeframe): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + target_display (str): A string representation of the target that indicates its precision. It uses trailing zeros to show significant decimal places (e.g. `98.00`). Always included in service level objective responses. Ignored in create/update requests.. [optional] # noqa: E501 + warning (float): The warning value for the service level objective.. [optional] # noqa: E501 + warning_display (str): A string representation of the warning target (see the description of the `target_display` field for details). Included in service level objective responses if a warning target exists. Ignored in create/update requests.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.target = target + self.timeframe = timeframe + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, target, timeframe, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_timeframe.py b/src/datadog_api_client/v1/model/slo_timeframe.py index ede9796934..fe5ba8a86a 100644 --- a/src/datadog_api_client/v1/model/slo_timeframe.py +++ b/src/datadog_api_client/v1/model/slo_timeframe.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOTimeframe(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOTimeframe - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The SLO time window options.., must be one of ["7d", "30d", "90d", "custom", ] # noqa: E501 + + Keyword Args: + value (str): The SLO time window options.., must be one of ["7d", "30d", "90d", "custom", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_type.py b/src/datadog_api_client/v1/model/slo_type.py index 6f124483ba..2abdcaec76 100644 --- a/src/datadog_api_client/v1/model/slo_type.py +++ b/src/datadog_api_client/v1/model/slo_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of the service level objective.., must be one of ["metric", "monitor", ] # noqa: E501 + + Keyword Args: + value (str): The type of the service level objective.., must be one of ["metric", "monitor", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_type_numeric.py b/src/datadog_api_client/v1/model/slo_type_numeric.py index f393109f27..ced0874893 100644 --- a/src/datadog_api_client/v1/model/slo_type_numeric.py +++ b/src/datadog_api_client/v1/model/slo_type_numeric.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOTypeNumeric(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOTypeNumeric - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): A numeric representation of the type of the service level objective (`0` for monitor, `1` for metric). Always included in service level objective responses. Ignored in create/update requests.., must be one of [0, 1, ] # noqa: E501 + + Keyword Args: + value (int): A numeric representation of the type of the service level objective (`0` for monitor, `1` for metric). Always included in service level objective responses. Ignored in create/update requests.., must be one of [0, 1, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/slo_widget_definition.py b/src/datadog_api_client/v1/model/slo_widget_definition.py index 838a2cdd5f..3fdb46dd43 100644 --- a/src/datadog_api_client/v1/model/slo_widget_definition.py +++ b/src/datadog_api_client/v1/model/slo_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,101 @@ def discriminator(): "view_mode": "view_mode", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """SLOWidgetDefinition - a model defined in OpenAPI + + Args: + type (SLOWidgetDefinitionType): + + Keyword Args: + view_type (str): Type of view displayed by the widget.. defaults to "detail" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + global_time_target (str): Defined global time target.. [optional] # noqa: E501 + show_error_budget (bool): Defined error budget.. [optional] # noqa: E501 + slo_id (str): ID of the SLO displayed.. [optional] # noqa: E501 + time_windows ([WidgetTimeWindows]): Times being monitored.. [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + view_mode (WidgetViewMode): [optional] # noqa: E501 + """ + + view_type = kwargs.get("view_type", "detail") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + self.view_type = view_type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -206,3 +301,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/slo_widget_definition_type.py b/src/datadog_api_client/v1/model/slo_widget_definition_type.py index f98c6c31f4..2cc2d00028 100644 --- a/src/datadog_api_client/v1/model/slo_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/slo_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SLOWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SLOWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the SLO widget.. if omitted defaults to "slo", must be one of ["slo", ] # noqa: E501 + + Keyword Args: + value (str): Type of the SLO widget.. if omitted defaults to "slo", must be one of ["slo", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "slo" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_api_step.py b/src/datadog_api_client/v1/model/synthetics_api_step.py index 27965a671c..0c39b5eb5e 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_step.py +++ b/src/datadog_api_client/v1/model/synthetics_api_step.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,93 @@ def discriminator(): "subtype": "subtype", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPIStep - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + allow_failure (bool): Determines whether or not to continue with test if this step fails.. [optional] # noqa: E501 + assertions ([SyntheticsAssertion]): Array of assertions used for the test.. [optional] if omitted the server will use the default value of [] # noqa: E501 + extracted_values ([SyntheticsParsingOptions]): Array of values to parse and save as variables from the response.. [optional] # noqa: E501 + is_critical (bool): Determines whether or not to consider the entire test as failed if this step fails. Can be used only if `allowFailure` is `true`.. [optional] # noqa: E501 + name (str): The name of the step.. [optional] # noqa: E501 + request (SyntheticsTestRequest): [optional] # noqa: E501 + subtype (SyntheticsAPIStepSubtype): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +279,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_step_subtype.py b/src/datadog_api_client/v1/model/synthetics_api_step_subtype.py index 706c384d2e..bbb094cd64 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_step_subtype.py +++ b/src/datadog_api_client/v1/model/synthetics_api_step_subtype.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAPIStepSubtype(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsAPIStepSubtype - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The subtype of the Synthetic multistep API test step, currently only supporting `http`.. if omitted defaults to "http", must be one of ["http", ] # noqa: E501 + + Keyword Args: + value (str): The subtype of the Synthetic multistep API test step, currently only supporting `http`.. if omitted defaults to "http", must be one of ["http", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "http" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_api_test.py b/src/datadog_api_client/v1/model/synthetics_api_test.py index 83b2438b9a..5e472bd288 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,100 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "monitor_id", # noqa: E501 + "public_id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + config (SyntheticsAPITestConfig): [optional] # noqa: E501 + locations ([str]): Array of locations used to run the test.. [optional] # noqa: E501 + message (str): Notification message associated with the test.. [optional] # noqa: E501 + monitor_id (int): The associated monitor ID.. [optional] # noqa: E501 + name (str): Name of the test.. [optional] # noqa: E501 + options (SyntheticsTestOptions): [optional] # noqa: E501 + public_id (str): The public ID for the test.. [optional] # noqa: E501 + status (SyntheticsTestPauseStatus): [optional] # noqa: E501 + subtype (SyntheticsTestDetailsSubType): [optional] # noqa: E501 + tags ([str]): Array of tags attached to the test.. [optional] # noqa: E501 + type (SyntheticsAPITestType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -206,3 +300,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_config.py b/src/datadog_api_client/v1/model/synthetics_api_test_config.py index f475df8a5d..1899f8eb5f 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_config.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_config.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,90 @@ def discriminator(): "steps": "steps", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestConfig - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + assertions ([SyntheticsAssertion]): Array of assertions used for the test.. [optional] if omitted the server will use the default value of [] # noqa: E501 + config_variables ([SyntheticsConfigVariable]): Array of variables used for the test.. [optional] # noqa: E501 + request (SyntheticsTestRequest): [optional] # noqa: E501 + steps ([SyntheticsAPIStep]): When the test subtype is `multi`, the steps of the test.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_result_data.py b/src/datadog_api_client/v1/model/synthetics_api_test_result_data.py index 073d2d1e94..4eb3d8bbb8 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_result_data.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_result_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,13 +85,9 @@ def openapi_types(): "error_message": (str,), # noqa: E501 "event_type": (SyntheticsTestProcessStatus,), # noqa: E501 "http_status_code": (int,), # noqa: E501 - "request_headers": ( - {str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}, - ), # noqa: E501 + "request_headers": ({str: (dict,)},), # noqa: E501 "response_body": (str,), # noqa: E501 - "response_headers": ( - {str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}, - ), # noqa: E501 + "response_headers": ({str: (dict,)},), # noqa: E501 "response_size": (int,), # noqa: E501 "timings": (SyntheticsTiming,), # noqa: E501 } @@ -111,8 +109,96 @@ def discriminator(): "timings": "timings", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestResultData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cert (SyntheticsSSLCertificate): [optional] # noqa: E501 + error_code (SyntheticsErrorCode): [optional] # noqa: E501 + error_message (str): The API test error message.. [optional] # noqa: E501 + event_type (SyntheticsTestProcessStatus): [optional] # noqa: E501 + http_status_code (int): The API test HTTP status code.. [optional] # noqa: E501 + request_headers ({str: (dict,)}): Request header object used for the API test.. [optional] # noqa: E501 + response_body (str): Response body returned for the API test.. [optional] # noqa: E501 + response_headers ({str: (dict,)}): Response headers returned for the API test.. [optional] # noqa: E501 + response_size (int): Global size in byte of the API test response.. [optional] # noqa: E501 + timings (SyntheticsTiming): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,9 +250,9 @@ def __init__(self, *args, **kwargs): # noqa: E501 error_message (str): The API test error message.. [optional] # noqa: E501 event_type (SyntheticsTestProcessStatus): [optional] # noqa: E501 http_status_code (int): The API test HTTP status code.. [optional] # noqa: E501 - request_headers ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}): Request header object used for the API test.. [optional] # noqa: E501 + request_headers ({str: (dict,)}): Request header object used for the API test.. [optional] # noqa: E501 response_body (str): Response body returned for the API test.. [optional] # noqa: E501 - response_headers ({str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}): Response headers returned for the API test.. [optional] # noqa: E501 + response_headers ({str: (dict,)}): Response headers returned for the API test.. [optional] # noqa: E501 response_size (int): Global size in byte of the API test response.. [optional] # noqa: E501 timings (SyntheticsTiming): [optional] # noqa: E501 """ @@ -205,3 +291,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_result_full.py b/src/datadog_api_client/v1/model/synthetics_api_test_result_full.py index 485b507c37..0773219a36 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_result_full.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_result_full.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,93 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestResultFull - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check (SyntheticsAPITestResultFullCheck): [optional] # noqa: E501 + check_time (float): When the API test was conducted.. [optional] # noqa: E501 + check_version (int): Version of the API test used.. [optional] # noqa: E501 + probe_dc (str): Locations for which to query the API test results.. [optional] # noqa: E501 + result (SyntheticsAPITestResultData): [optional] # noqa: E501 + result_id (str): ID of the API test result.. [optional] # noqa: E501 + status (SyntheticsTestMonitorStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -190,3 +277,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_result_full_check.py b/src/datadog_api_client/v1/model/synthetics_api_test_result_full_check.py index 7b55cff7e6..84ce44c41c 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_result_full_check.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_result_full_check.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "config": "config", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, config, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestResultFullCheck - a model defined in OpenAPI + + Args: + config (SyntheticsTestConfig): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.config = config + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, config, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_result_short.py b/src/datadog_api_client/v1/model/synthetics_api_test_result_short.py index b79375f336..defedc6d3a 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_result_short.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_result_short.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,91 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestResultShort - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check_time (float): Last time the API test was performed.. [optional] # noqa: E501 + probe_dc (str): Location from which the API test was performed.. [optional] # noqa: E501 + result (SyntheticsAPITestResultShortResult): [optional] # noqa: E501 + result_id (str): ID of the API test result.. [optional] # noqa: E501 + status (SyntheticsTestMonitorStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_result_short_result.py b/src/datadog_api_client/v1/model/synthetics_api_test_result_short_result.py index 9f9edfa3d2..73f6807a98 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_result_short_result.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_result_short_result.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "timings": "timings", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAPITestResultShortResult - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + passed (bool): Describes if the test run has passed or failed.. [optional] # noqa: E501 + timings (SyntheticsTiming): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_api_test_type.py b/src/datadog_api_client/v1/model/synthetics_api_test_type.py index 9cf7538d01..f61c147ba4 100644 --- a/src/datadog_api_client/v1/model/synthetics_api_test_type.py +++ b/src/datadog_api_client/v1/model/synthetics_api_test_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAPITestType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsAPITestType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Synthetic test, `api`.. if omitted defaults to "api", must be one of ["api", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Synthetic test, `api`.. if omitted defaults to "api", must be one of ["api", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "api" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_assertion.py b/src/datadog_api_client/v1/model/synthetics_assertion.py index 11624cc656..0f849c9a43 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -66,24 +68,7 @@ class SyntheticsAssertion(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -105,6 +90,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAssertion - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _property (str): The associated assertion property.. [optional] # noqa: E501 + target (SyntheticsAssertionJSONPathTargetTarget): [optional] # noqa: E501 + operator (SyntheticsAssertionJSONPathOperator): [optional] # noqa: E501 + type (SyntheticsAssertionType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -191,28 +261,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_operator.py b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_operator.py index 125745a385..c14a48c5f2 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_operator.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_operator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAssertionJSONPathOperator(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsAssertionJSONPathOperator - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Assertion operator to apply.. if omitted defaults to "validatesJSONPath", must be one of ["validatesJSONPath", ] # noqa: E501 + + Keyword Args: + value (str): Assertion operator to apply.. if omitted defaults to "validatesJSONPath", must be one of ["validatesJSONPath", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "validatesJSONPath" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target.py b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target.py index 932a286a89..ef309191f9 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,94 @@ def discriminator(): "target": "target", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, operator, type, *args, **kwargs): # noqa: E501 + """SyntheticsAssertionJSONPathTarget - a model defined in OpenAPI + + Args: + operator (SyntheticsAssertionJSONPathOperator): + type (SyntheticsAssertionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _property (str): The associated assertion property.. [optional] # noqa: E501 + target (SyntheticsAssertionJSONPathTargetTarget): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.operator = operator + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,3 +275,8 @@ def __init__(self, operator, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target_target.py b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target_target.py index 713494f344..339137e734 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target_target.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_json_path_target_target.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAssertionJSONPathTargetTarget(ModelNormal): @@ -90,8 +92,89 @@ def discriminator(): "target_value": "targetValue", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsAssertionJSONPathTargetTarget - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + json_path (str): The JSON path to assert.. [optional] # noqa: E501 + operator (str): The specific operator to use on the path.. [optional] # noqa: E501 + target_value (bool, date, datetime, dict, float, int, list, str, none_type): The path target value to compare to.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +260,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_operator.py b/src/datadog_api_client/v1/model/synthetics_assertion_operator.py index 4ecd805f1b..0347677667 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_operator.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_operator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAssertionOperator(ModelSimple): @@ -86,6 +88,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -189,3 +193,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsAssertionOperator - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Assertion operator to apply.., must be one of ["contains", "doesNotContain", "is", "isNot", "lessThan", "lessThanOrEqual", "moreThan", "moreThanOrEqual", "matches", "doesNotMatch", "validates", "isInMoreThan", "isInLessThan", ] # noqa: E501 + + Keyword Args: + value (str): Assertion operator to apply.., must be one of ["contains", "doesNotContain", "is", "isNot", "lessThan", "lessThanOrEqual", "moreThan", "moreThanOrEqual", "matches", "doesNotMatch", "validates", "isInMoreThan", "isInLessThan", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_target.py b/src/datadog_api_client/v1/model/synthetics_assertion_target.py index 044e585f11..a73c1aec97 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_target.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_target.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -86,6 +88,7 @@ def openapi_types(): int, list, str, + none_type, ), # noqa: E501 } @@ -100,8 +103,94 @@ def discriminator(): "target": "target", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, operator, type, *args, **kwargs): # noqa: E501 + """SyntheticsAssertionTarget - a model defined in OpenAPI + + Args: + operator (SyntheticsAssertionOperator): + type (SyntheticsAssertionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _property (str): The associated assertion property.. [optional] # noqa: E501 + target (bool, date, datetime, dict, float, int, list, str, none_type): Value used by the operator.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.operator = operator + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -153,7 +242,7 @@ def __init__(self, operator, type, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) _property (str): The associated assertion property.. [optional] # noqa: E501 - target (bool, date, datetime, dict, float, int, list, str): Value used by the operator.. [optional] # noqa: E501 + target (bool, date, datetime, dict, float, int, list, str, none_type): Value used by the operator.. [optional] # noqa: E501 """ _check_type = kwargs.pop("_check_type", True) @@ -192,3 +281,8 @@ def __init__(self, operator, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_assertion_type.py b/src/datadog_api_client/v1/model/synthetics_assertion_type.py index 8fc45e7d53..255e477ff2 100644 --- a/src/datadog_api_client/v1/model/synthetics_assertion_type.py +++ b/src/datadog_api_client/v1/model/synthetics_assertion_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsAssertionType(ModelSimple): @@ -87,6 +89,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -190,3 +194,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsAssertionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the assertion.., must be one of ["body", "header", "statusCode", "certificate", "responseTime", "property", "recordEvery", "recordSome", "tlsVersion", "minTlsVersion", "latency", "packetLossPercentage", "packetsReceived", "networkHop", ] # noqa: E501 + + Keyword Args: + value (str): Type of the assertion.., must be one of ["body", "header", "statusCode", "certificate", "responseTime", "property", "recordEvery", "recordSome", "tlsVersion", "minTlsVersion", "latency", "packetLossPercentage", "packetsReceived", "networkHop", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_basic_auth.py b/src/datadog_api_client/v1/model/synthetics_basic_auth.py index e865b46747..6af48cb0ec 100644 --- a/src/datadog_api_client/v1/model/synthetics_basic_auth.py +++ b/src/datadog_api_client/v1/model/synthetics_basic_auth.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsBasicAuth(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "username": "username", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, password, username, *args, **kwargs): # noqa: E501 + """SyntheticsBasicAuth - a model defined in OpenAPI + + Args: + password (str): Password to use for the basic authentication. + username (str): Username to use for the basic authentication. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.password = password + self.username = username + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, password, username, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_error.py b/src/datadog_api_client/v1/model/synthetics_browser_error.py index cc494fbeae..2dc09be908 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_error.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_error.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,95 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, description, name, type, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserError - a model defined in OpenAPI + + Args: + description (str): Description of the error. + name (str): Name of the error. + type (SyntheticsBrowserErrorType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + status (int): Status Code of the error.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.description = description + self.name = name + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +271,8 @@ def __init__(self, description, name, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_error_type.py b/src/datadog_api_client/v1/model/synthetics_browser_error_type.py index 76148febec..b8d395f901 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_error_type.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_error_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsBrowserErrorType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsBrowserErrorType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Error type returned by a browser test.., must be one of ["network", "js", ] # noqa: E501 + + Keyword Args: + value (str): Error type returned by a browser test.., must be one of ["network", "js", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test.py b/src/datadog_api_client/v1/model/synthetics_browser_test.py index e221aae957..a3281f7749 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,103 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "monitor_id", # noqa: E501 + "public_id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, message, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTest - a model defined in OpenAPI + + Args: + message (str): Notification message associated with the test. Message can either be text or an empty string. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + config (SyntheticsBrowserTestConfig): [optional] # noqa: E501 + locations ([str]): Array of locations used to run the test.. [optional] # noqa: E501 + monitor_id (int): The associated monitor ID.. [optional] # noqa: E501 + name (str): Name of the test.. [optional] # noqa: E501 + options (SyntheticsTestOptions): [optional] # noqa: E501 + public_id (str): The public ID of the test.. [optional] # noqa: E501 + status (SyntheticsTestPauseStatus): [optional] # noqa: E501 + steps ([SyntheticsStep]): The steps of the test.. [optional] # noqa: E501 + tags ([str]): Array of tags attached to the test.. [optional] # noqa: E501 + type (SyntheticsBrowserTestType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.message = message + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -209,3 +306,8 @@ def __init__(self, message, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_config.py b/src/datadog_api_client/v1/model/synthetics_browser_test_config.py index f0b3e1c359..fc31b80c36 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_config.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_config.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,95 @@ def discriminator(): "variables": "variables", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, request, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestConfig - a model defined in OpenAPI + + Args: + request (SyntheticsTestRequest): + + Keyword Args: + assertions ([SyntheticsAssertion]): Array of assertions used for the test.. defaults to [] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + set_cookie (str): Cookies to be used for the request, using the [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) syntax.. [optional] # noqa: E501 + variables ([SyntheticsBrowserVariable]): Array of variables used for the test steps.. [optional] # noqa: E501 + """ + + assertions = kwargs.get("assertions", []) + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.assertions = assertions + self.request = request + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +275,8 @@ def __init__(self, request, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_result_data.py b/src/datadog_api_client/v1/model/synthetics_browser_test_result_data.py index 0df78661c5..3f44aa2f26 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_result_data.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_result_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,97 @@ def discriminator(): "time_to_interactive": "timeToInteractive", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestResultData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + browser_type (str): Type of browser device used for the browser test.. [optional] # noqa: E501 + browser_version (str): Browser version used for the browser test.. [optional] # noqa: E501 + device (SyntheticsDevice): [optional] # noqa: E501 + duration (float): Global duration in second of the browser test.. [optional] # noqa: E501 + error (str): Error returned for the browser test.. [optional] # noqa: E501 + passed (bool): Whether or not the browser test was conducted.. [optional] # noqa: E501 + received_email_count (int): The amount of email received during the browser test.. [optional] # noqa: E501 + start_url (str): Starting URL for the browser test.. [optional] # noqa: E501 + step_details ([SyntheticsStepDetail]): Array containing the different browser test steps.. [optional] # noqa: E501 + thumbnails_bucket_key (bool): Whether or not a thumbnail is associated with the browser test.. [optional] # noqa: E501 + time_to_interactive (float): Time in second to wait before the browser test starts after reaching the start URL.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +291,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_result_full.py b/src/datadog_api_client/v1/model/synthetics_browser_test_result_full.py index 7e928986a8..eb469b2294 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_result_full.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_result_full.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,93 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestResultFull - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check (SyntheticsBrowserTestResultFullCheck): [optional] # noqa: E501 + check_time (float): When the browser test was conducted.. [optional] # noqa: E501 + check_version (int): Version of the browser test used.. [optional] # noqa: E501 + probe_dc (str): Location from which the browser test was performed.. [optional] # noqa: E501 + result (SyntheticsBrowserTestResultData): [optional] # noqa: E501 + result_id (str): ID of the browser test result.. [optional] # noqa: E501 + status (SyntheticsTestMonitorStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +279,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_result_full_check.py b/src/datadog_api_client/v1/model/synthetics_browser_test_result_full_check.py index 3dd5bac669..434d132f0d 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_result_full_check.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_result_full_check.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "config": "config", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, config, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestResultFullCheck - a model defined in OpenAPI + + Args: + config (SyntheticsTestConfig): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.config = config + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, config, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_result_short.py b/src/datadog_api_client/v1/model/synthetics_browser_test_result_short.py index 2f46afa25f..078063acbe 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_result_short.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_result_short.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,91 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestResultShort - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check_time (float): Last time the browser test was performed.. [optional] # noqa: E501 + probe_dc (str): Location from which the Browser test was performed.. [optional] # noqa: E501 + result (SyntheticsBrowserTestResultShortResult): [optional] # noqa: E501 + result_id (str): ID of the browser test result.. [optional] # noqa: E501 + status (SyntheticsTestMonitorStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +269,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_result_short_result.py b/src/datadog_api_client/v1/model/synthetics_browser_test_result_short_result.py index a43200f346..903ab719e0 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_result_short_result.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_result_short_result.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,91 @@ def discriminator(): "step_count_total": "stepCountTotal", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserTestResultShortResult - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + device (SyntheticsDevice): [optional] # noqa: E501 + duration (float): Length in second of the browser test run.. [optional] # noqa: E501 + error_count (int): Amount of errors collected for a single browser test run.. [optional] # noqa: E501 + step_count_completed (int): Amount of browser test steps completed before failing.. [optional] # noqa: E501 + step_count_total (int): Total amount of browser test steps.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -180,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_test_type.py b/src/datadog_api_client/v1/model/synthetics_browser_test_type.py index 8a4f9afcc4..c010ff0399 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_test_type.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_test_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsBrowserTestType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsBrowserTestType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Synthetic test, `browser`.. if omitted defaults to "browser", must be one of ["browser", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Synthetic test, `browser`.. if omitted defaults to "browser", must be one of ["browser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "browser" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_browser_variable.py b/src/datadog_api_client/v1/model/synthetics_browser_variable.py index 207ad89590..c455e84803 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_variable.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_variable.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "pattern": "pattern", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, type, *args, **kwargs): # noqa: E501 + """SyntheticsBrowserVariable - a model defined in OpenAPI + + Args: + name (str): Name of the variable. + type (SyntheticsBrowserVariableType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + example (str): Example for the variable.. [optional] # noqa: E501 + id (str): ID for the variable.. [optional] # noqa: E501 + pattern (str): Pattern of the variable.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, name, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_browser_variable_type.py b/src/datadog_api_client/v1/model/synthetics_browser_variable_type.py index 27f6929453..137d65ae95 100644 --- a/src/datadog_api_client/v1/model/synthetics_browser_variable_type.py +++ b/src/datadog_api_client/v1/model/synthetics_browser_variable_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsBrowserVariableType(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsBrowserVariableType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of browser test variable.., must be one of ["element", "email", "global", "javascript", "text", ] # noqa: E501 + + Keyword Args: + value (str): Type of browser test variable.., must be one of ["element", "email", "global", "javascript", "text", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_check_type.py b/src/datadog_api_client/v1/model/synthetics_check_type.py index 72e0c10658..4e99f37058 100644 --- a/src/datadog_api_client/v1/model/synthetics_check_type.py +++ b/src/datadog_api_client/v1/model/synthetics_check_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsCheckType(ModelSimple): @@ -87,6 +89,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -190,3 +194,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsCheckType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of assertion to apply in an API test.., must be one of ["equals", "notEquals", "contains", "notContains", "startsWith", "notStartsWith", "greater", "lower", "greaterEquals", "lowerEquals", "matchRegex", "between", "isEmpty", "notIsEmpty", ] # noqa: E501 + + Keyword Args: + value (str): Type of assertion to apply in an API test.., must be one of ["equals", "notEquals", "contains", "notContains", "startsWith", "notStartsWith", "greater", "lower", "greaterEquals", "lowerEquals", "matchRegex", "between", "isEmpty", "notIsEmpty", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_ci_test.py b/src/datadog_api_client/v1/model/synthetics_ci_test.py index e0c57d5468..4c51cd6306 100644 --- a/src/datadog_api_client/v1/model/synthetics_ci_test.py +++ b/src/datadog_api_client/v1/model/synthetics_ci_test.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -117,8 +119,103 @@ def discriminator(): "variables": "variables", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, public_id, *args, **kwargs): # noqa: E501 + """SyntheticsCITest - a model defined in OpenAPI + + Args: + public_id (str): The public ID of the Synthetics test to trigger. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + allow_insecure_certificates (bool): Disable certificate checks in API tests.. [optional] # noqa: E501 + basic_auth (SyntheticsBasicAuth): [optional] # noqa: E501 + body (str): Body to include in the test.. [optional] # noqa: E501 + body_type (str): Type of the data sent in a synthetics API test.. [optional] # noqa: E501 + cookies (str): Cookies for the request.. [optional] # noqa: E501 + device_ids ([SyntheticsDeviceID]): For browser test, array with the different device IDs used to run the test.. [optional] # noqa: E501 + follow_redirects (bool): For API HTTP test, whether or not the test should follow redirects.. [optional] # noqa: E501 + headers (SyntheticsTestHeaders): [optional] # noqa: E501 + locations ([str]): Array of locations used to run the test.. [optional] # noqa: E501 + metadata (SyntheticsCITestMetadata): [optional] # noqa: E501 + retry (SyntheticsTestOptionsRetry): [optional] # noqa: E501 + start_url (str): Starting URL for the browser test.. [optional] # noqa: E501 + variables ({str: (str,)}): Variables to replace in the test.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.public_id = public_id + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -218,3 +315,8 @@ def __init__(self, public_id, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ci_test_body.py b/src/datadog_api_client/v1/model/synthetics_ci_test_body.py index 84ddf28592..c07a8de4ce 100644 --- a/src/datadog_api_client/v1/model/synthetics_ci_test_body.py +++ b/src/datadog_api_client/v1/model/synthetics_ci_test_body.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "tests": "tests", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsCITestBody - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tests ([SyntheticsCITest]): Individual synthetics test.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata.py b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata.py index ac07c406ea..8aca54c259 100644 --- a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata.py +++ b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "git": "git", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsCITestMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + ci (SyntheticsCITestMetadataCi): [optional] # noqa: E501 + git (SyntheticsCITestMetadataGit): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_ci.py b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_ci.py index 4587a081aa..6375d3e07b 100644 --- a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_ci.py +++ b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_ci.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsCITestMetadataCi(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "provider": "provider", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsCITestMetadataCi - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + pipeline (str): Name of the pipeline.. [optional] # noqa: E501 + provider (str): Name of the CI provider.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_git.py b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_git.py index f328ef44b6..3d51a8db2c 100644 --- a/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_git.py +++ b/src/datadog_api_client/v1/model/synthetics_ci_test_metadata_git.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsCITestMetadataGit(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "commit_sha": "commit_sha", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsCITestMetadataGit - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + branch (str): Branch name.. [optional] # noqa: E501 + commit_sha (str): Commit SHA.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_config_variable.py b/src/datadog_api_client/v1/model/synthetics_config_variable.py index 8f6eaadafc..e1ae7118ca 100644 --- a/src/datadog_api_client/v1/model/synthetics_config_variable.py +++ b/src/datadog_api_client/v1/model/synthetics_config_variable.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "pattern": "pattern", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, type, *args, **kwargs): # noqa: E501 + """SyntheticsConfigVariable - a model defined in OpenAPI + + Args: + name (str): Name of the variable. + type (SyntheticsConfigVariableType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + example (str): Example for the variable.. [optional] # noqa: E501 + id (str): ID of the variable for global variables.. [optional] # noqa: E501 + pattern (str): Pattern of the variable.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, name, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_config_variable_type.py b/src/datadog_api_client/v1/model/synthetics_config_variable_type.py index cc94c9b6fa..ff6d63a22f 100644 --- a/src/datadog_api_client/v1/model/synthetics_config_variable_type.py +++ b/src/datadog_api_client/v1/model/synthetics_config_variable_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsConfigVariableType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsConfigVariableType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the configuration variable.., must be one of ["global", "text", ] # noqa: E501 + + Keyword Args: + value (str): Type of the configuration variable.., must be one of ["global", "text", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_core_web_vitals.py b/src/datadog_api_client/v1/model/synthetics_core_web_vitals.py index 3a1f61f3e9..4e0007dc42 100644 --- a/src/datadog_api_client/v1/model/synthetics_core_web_vitals.py +++ b/src/datadog_api_client/v1/model/synthetics_core_web_vitals.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsCoreWebVitals(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsCoreWebVitals - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cls (int): Cumulative Layout Shift.. [optional] # noqa: E501 + lcp (int): Largest Contentful Paint in milliseconds.. [optional] # noqa: E501 + url (str): URL attached to the metrics.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_delete_tests_payload.py b/src/datadog_api_client/v1/model/synthetics_delete_tests_payload.py index ef5dba59cd..c30741a662 100644 --- a/src/datadog_api_client/v1/model/synthetics_delete_tests_payload.py +++ b/src/datadog_api_client/v1/model/synthetics_delete_tests_payload.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsDeleteTestsPayload(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "public_ids": "public_ids", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsDeleteTestsPayload - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + public_ids ([str]): An array of Synthetic test IDs you want to delete.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_delete_tests_response.py b/src/datadog_api_client/v1/model/synthetics_delete_tests_response.py index 563c107062..ab0c377a96 100644 --- a/src/datadog_api_client/v1/model/synthetics_delete_tests_response.py +++ b/src/datadog_api_client/v1/model/synthetics_delete_tests_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "deleted_tests": "deleted_tests", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsDeleteTestsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_tests ([SyntheticsDeletedTest]): Array of objects containing a deleted Synthetic test ID with the associated deletion timestamp.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_deleted_test.py b/src/datadog_api_client/v1/model/synthetics_deleted_test.py index a35fb0981d..b53eb3fd13 100644 --- a/src/datadog_api_client/v1/model/synthetics_deleted_test.py +++ b/src/datadog_api_client/v1/model/synthetics_deleted_test.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsDeletedTest(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "public_id": "public_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsDeletedTest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_at (datetime): Deletion timestamp of the Synthetic test ID.. [optional] # noqa: E501 + public_id (str): The Synthetic test ID deleted.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_device.py b/src/datadog_api_client/v1/model/synthetics_device.py index 3f72c67280..68ce9390a4 100644 --- a/src/datadog_api_client/v1/model/synthetics_device.py +++ b/src/datadog_api_client/v1/model/synthetics_device.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,97 @@ def discriminator(): "is_mobile": "isMobile", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, height, id, name, width, *args, **kwargs): # noqa: E501 + """SyntheticsDevice - a model defined in OpenAPI + + Args: + height (int): Screen height of the device. + id (SyntheticsDeviceID): + name (str): The device name. + width (int): Screen width of the device. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_mobile (bool): Whether or not the device is a mobile.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.height = height + self.id = id + self.name = name + self.width = width + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +277,8 @@ def __init__(self, height, id, name, width, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_device_id.py b/src/datadog_api_client/v1/model/synthetics_device_id.py index 1cc358309c..8a8cb10e4b 100644 --- a/src/datadog_api_client/v1/model/synthetics_device_id.py +++ b/src/datadog_api_client/v1/model/synthetics_device_id.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsDeviceID(ModelSimple): @@ -82,6 +84,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -185,3 +189,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsDeviceID - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The device ID.., must be one of ["laptop_large", "tablet", "mobile_small", "chrome.laptop_large", "chrome.tablet", "chrome.mobile_small", "firefox.laptop_large", "firefox.tablet", "firefox.mobile_small", ] # noqa: E501 + + Keyword Args: + value (str): The device ID.., must be one of ["laptop_large", "tablet", "mobile_small", "chrome.laptop_large", "chrome.tablet", "chrome.mobile_small", "firefox.laptop_large", "firefox.tablet", "firefox.mobile_small", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_error_code.py b/src/datadog_api_client/v1/model/synthetics_error_code.py index 38025a1d81..7452bcd3e2 100644 --- a/src/datadog_api_client/v1/model/synthetics_error_code.py +++ b/src/datadog_api_client/v1/model/synthetics_error_code.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsErrorCode(ModelSimple): @@ -80,6 +82,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -183,3 +187,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsErrorCode - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Error code that can be returned by a Synthetic test.., must be one of ["NO_ERROR", "UNKNOWN", "DNS", "SSL", "TIMEOUT", "DENIED", "INCORRECT_ASSERTION", ] # noqa: E501 + + Keyword Args: + value (str): Error code that can be returned by a Synthetic test.., must be one of ["NO_ERROR", "UNKNOWN", "DNS", "SSL", "TIMEOUT", "DENIED", "INCORRECT_ASSERTION", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_get_api_test_latest_results_response.py b/src/datadog_api_client/v1/model/synthetics_get_api_test_latest_results_response.py index 639b902eb0..fbcd73b46a 100644 --- a/src/datadog_api_client/v1/model/synthetics_get_api_test_latest_results_response.py +++ b/src/datadog_api_client/v1/model/synthetics_get_api_test_latest_results_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "results": "results", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsGetAPITestLatestResultsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + last_timestamp_fetched (int): Timestamp of the latest API test run.. [optional] # noqa: E501 + results ([SyntheticsAPITestResultShort]): Result of the latest API test run.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_get_browser_test_latest_results_response.py b/src/datadog_api_client/v1/model/synthetics_get_browser_test_latest_results_response.py index 541893f761..3da949d711 100644 --- a/src/datadog_api_client/v1/model/synthetics_get_browser_test_latest_results_response.py +++ b/src/datadog_api_client/v1/model/synthetics_get_browser_test_latest_results_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "results": "results", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsGetBrowserTestLatestResultsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + last_timestamp_fetched (int): Timestamp of the latest browser test run.. [optional] # noqa: E501 + results ([SyntheticsBrowserTestResultShort]): Result of the latest browser test run.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable.py b/src/datadog_api_client/v1/model/synthetics_global_variable.py index cae0c4510e..f7c6a0d7ea 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,101 @@ def discriminator(): "parse_test_public_id": "parse_test_public_id", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, description, name, tags, value, *args, **kwargs): # noqa: E501 + """SyntheticsGlobalVariable - a model defined in OpenAPI + + Args: + description (str): Description of the global variable. + name (str): Name of the global variable. + tags ([str]): Tags of the global variable. + value (SyntheticsGlobalVariableValue): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Unique identifier of the global variable.. [optional] # noqa: E501 + parse_test_options (SyntheticsGlobalVariableParseTestOptions): [optional] # noqa: E501 + parse_test_public_id (str): A Synthetic test ID to use as a test to generate the variable value.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.description = description + self.name = name + self.tags = tags + self.value = value + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -196,3 +291,8 @@ def __init__(self, description, name, tags, value, *args, **kwargs): # noqa: E5 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options.py b/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options.py index 777f2a53fc..df895e64fb 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "field": "field", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, parser, type, *args, **kwargs): # noqa: E501 + """SyntheticsGlobalVariableParseTestOptions - a model defined in OpenAPI + + Args: + parser (SyntheticsVariableParser): + type (SyntheticsGlobalVariableParseTestOptionsType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + field (str): When type is `http_header`, name of the header to use to extract the value.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.parser = parser + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, parser, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options_type.py b/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options_type.py index fb89b6a2b9..b098d3076b 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options_type.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable_parse_test_options_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsGlobalVariableParseTestOptionsType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsGlobalVariableParseTestOptionsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Property of the Synthetics Test Response to use for a Synthetics global variable.., must be one of ["http_body", "http_header", ] # noqa: E501 + + Keyword Args: + value (str): Property of the Synthetics Test Response to use for a Synthetics global variable.., must be one of ["http_body", "http_header", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable_parser_type.py b/src/datadog_api_client/v1/model/synthetics_global_variable_parser_type.py index 2b652a2112..81fab5474c 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable_parser_type.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable_parser_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsGlobalVariableParserType(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsGlobalVariableParserType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of parser for a Synthetics global variable from a synthetics test.., must be one of ["raw", "json_path", "regex", ] # noqa: E501 + + Keyword Args: + value (str): Type of parser for a Synthetics global variable from a synthetics test.., must be one of ["raw", "json_path", "regex", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable_value.py b/src/datadog_api_client/v1/model/synthetics_global_variable_value.py index 5e8cb67779..bc90087fcf 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable_value.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable_value.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsGlobalVariableValue(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsGlobalVariableValue - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + secure (bool): Determines if the variable is secure.. [optional] # noqa: E501 + value (str): Value of the global variable. When reading a global variable, the value will not be present if the variable is secure.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_list_global_variables_response.py b/src/datadog_api_client/v1/model/synthetics_list_global_variables_response.py index e092de2821..2af18eeb1d 100644 --- a/src/datadog_api_client/v1/model/synthetics_list_global_variables_response.py +++ b/src/datadog_api_client/v1/model/synthetics_list_global_variables_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "variables": "variables", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsListGlobalVariablesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + variables ([SyntheticsGlobalVariable]): Array of Synthetic global variables.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_list_tests_response.py b/src/datadog_api_client/v1/model/synthetics_list_tests_response.py index fb1d7b6f55..6764af9f92 100644 --- a/src/datadog_api_client/v1/model/synthetics_list_tests_response.py +++ b/src/datadog_api_client/v1/model/synthetics_list_tests_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "tests": "tests", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsListTestsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tests ([SyntheticsTestDetails]): Array of Synthetic tests configuration.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_location.py b/src/datadog_api_client/v1/model/synthetics_location.py index da36f74d80..009f31bf70 100644 --- a/src/datadog_api_client/v1/model/synthetics_location.py +++ b/src/datadog_api_client/v1/model/synthetics_location.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsLocation(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsLocation - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Unique identifier of the location.. [optional] # noqa: E501 + name (str): Name of the location.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_locations.py b/src/datadog_api_client/v1/model/synthetics_locations.py index 261eb5632e..7448559da1 100644 --- a/src/datadog_api_client/v1/model/synthetics_locations.py +++ b/src/datadog_api_client/v1/model/synthetics_locations.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "locations": "locations", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsLocations - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + locations ([SyntheticsLocation]): List of Synthetics locations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_parsing_options.py b/src/datadog_api_client/v1/model/synthetics_parsing_options.py index bcf2d8fcbf..86f39c94e9 100644 --- a/src/datadog_api_client/v1/model/synthetics_parsing_options.py +++ b/src/datadog_api_client/v1/model/synthetics_parsing_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsParsingOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + field (str): When type is `http_header`, name of the header to use to extract the value.. [optional] # noqa: E501 + name (str): Name of the variable to extract.. [optional] # noqa: E501 + parser (SyntheticsVariableParser): [optional] # noqa: E501 + type (SyntheticsGlobalVariableParseTestOptionsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_playing_tab.py b/src/datadog_api_client/v1/model/synthetics_playing_tab.py index 45945bf53f..91ea8e01c7 100644 --- a/src/datadog_api_client/v1/model/synthetics_playing_tab.py +++ b/src/datadog_api_client/v1/model/synthetics_playing_tab.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsPlayingTab(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsPlayingTab - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): Navigate between different tabs for your browser test.., must be one of [-1, 0, 1, 2, 3, ] # noqa: E501 + + Keyword Args: + value (int): Navigate between different tabs for your browser test.., must be one of [-1, 0, 1, 2, 3, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_private_location.py b/src/datadog_api_client/v1/model/synthetics_private_location.py index 5163f1ff26..72688d06af 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,98 @@ def discriminator(): "secrets": "secrets", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, description, name, tags, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocation - a model defined in OpenAPI + + Args: + description (str): Description of the private location. + name (str): Name of the private location. + tags ([str]): Array of tags attached to the private location. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Unique identifier of the private location.. [optional] # noqa: E501 + secrets (SyntheticsPrivateLocationSecrets): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.description = description + self.name = name + self.tags = tags + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +277,8 @@ def __init__(self, description, name, tags, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_private_location_creation_response.py b/src/datadog_api_client/v1/model/synthetics_private_location_creation_response.py index 247ebad03d..ffe6328098 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location_creation_response.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location_creation_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -78,7 +80,7 @@ def openapi_types(): """ lazy_import() return { - "config": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + "config": (dict,), # noqa: E501 "private_location": (SyntheticsPrivateLocation,), # noqa: E501 "result_encryption": (SyntheticsPrivateLocationCreationResponseResultEncryption,), # noqa: E501 } @@ -93,8 +95,89 @@ def discriminator(): "result_encryption": "result_encryption", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocationCreationResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + config (dict): Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration.. [optional] # noqa: E501 + private_location (SyntheticsPrivateLocation): [optional] # noqa: E501 + result_encryption (SyntheticsPrivateLocationCreationResponseResultEncryption): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -141,7 +224,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration.. [optional] # noqa: E501 + config (dict): Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration.. [optional] # noqa: E501 private_location (SyntheticsPrivateLocation): [optional] # noqa: E501 result_encryption (SyntheticsPrivateLocationCreationResponseResultEncryption): [optional] # noqa: E501 """ @@ -180,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_private_location_creation_response_result_encryption.py b/src/datadog_api_client/v1/model/synthetics_private_location_creation_response_result_encryption.py index 50cd1e0989..495d4c0be9 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location_creation_response_result_encryption.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location_creation_response_result_encryption.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsPrivateLocationCreationResponseResultEncryption(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "key": "key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocationCreationResponseResultEncryption - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Fingerprint for the encryption key.. [optional] # noqa: E501 + key (str): Public key for result encryption.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_private_location_secrets.py b/src/datadog_api_client/v1/model/synthetics_private_location_secrets.py index c05d93105d..456cdf7402 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location_secrets.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location_secrets.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,88 @@ def discriminator(): "config_decryption": "config_decryption", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocationSecrets - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + authentication (SyntheticsPrivateLocationSecretsAuthentication): [optional] # noqa: E501 + config_decryption (SyntheticsPrivateLocationSecretsConfigDecryption): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_private_location_secrets_authentication.py b/src/datadog_api_client/v1/model/synthetics_private_location_secrets_authentication.py index 8a3035d4b2..14c83e6212 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location_secrets_authentication.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location_secrets_authentication.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsPrivateLocationSecretsAuthentication(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "key": "key", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + "key", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocationSecretsAuthentication - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): Access key for the private location.. [optional] # noqa: E501 + key (str): Secret access key for the private location.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_private_location_secrets_config_decryption.py b/src/datadog_api_client/v1/model/synthetics_private_location_secrets_config_decryption.py index 816bd87774..893d7e90b2 100644 --- a/src/datadog_api_client/v1/model/synthetics_private_location_secrets_config_decryption.py +++ b/src/datadog_api_client/v1/model/synthetics_private_location_secrets_config_decryption.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsPrivateLocationSecretsConfigDecryption(ModelNormal): @@ -76,8 +78,89 @@ def discriminator(): "key": "key", # noqa: E501 } + read_only_vars = { + "key", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsPrivateLocationSecretsConfigDecryption - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + key (str): Private key for the private location.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +244,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ssl_certificate.py b/src/datadog_api_client/v1/model/synthetics_ssl_certificate.py index 0d1187a527..6bac936307 100644 --- a/src/datadog_api_client/v1/model/synthetics_ssl_certificate.py +++ b/src/datadog_api_client/v1/model/synthetics_ssl_certificate.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,98 @@ def discriminator(): "valid_to": "validTo", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsSSLCertificate - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cipher (str): Cipher used for the connection.. [optional] # noqa: E501 + exponent (float): Exponent associated to the certificate.. [optional] # noqa: E501 + ext_key_usage ([str]): Array of extensions and details used for the certificate.. [optional] # noqa: E501 + fingerprint (str): MD5 digest of the DER-encoded Certificate information.. [optional] # noqa: E501 + fingerprint256 (str): SHA-1 digest of the DER-encoded Certificate information.. [optional] # noqa: E501 + issuer (SyntheticsSSLCertificateIssuer): [optional] # noqa: E501 + modulus (str): Modulus associated to the SSL certificate private key.. [optional] # noqa: E501 + protocol (str): TLS protocol used for the test.. [optional] # noqa: E501 + serial_number (str): Serial Number assigned by Symantec to the SSL certificate.. [optional] # noqa: E501 + subject (SyntheticsSSLCertificateSubject): [optional] # noqa: E501 + valid_from (datetime): Date from which the SSL certificate is valid.. [optional] # noqa: E501 + valid_to (datetime): Date until which the SSL certificate is valid.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +295,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ssl_certificate_issuer.py b/src/datadog_api_client/v1/model/synthetics_ssl_certificate_issuer.py index b29edff51a..f149b9d59f 100644 --- a/src/datadog_api_client/v1/model/synthetics_ssl_certificate_issuer.py +++ b/src/datadog_api_client/v1/model/synthetics_ssl_certificate_issuer.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsSSLCertificateIssuer(ModelNormal): @@ -86,8 +88,92 @@ def discriminator(): "st": "ST", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsSSLCertificateIssuer - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + c (str): Country Name that issued the certificate.. [optional] # noqa: E501 + cn (str): Common Name that issued certificate.. [optional] # noqa: E501 + l (str): Locality that issued the certificate.. [optional] # noqa: E501 + o (str): Organization that issued the certificate.. [optional] # noqa: E501 + ou (str): Organizational Unit that issued the certificate.. [optional] # noqa: E501 + st (str): State Or Province Name that issued the certificate.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +262,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_ssl_certificate_subject.py b/src/datadog_api_client/v1/model/synthetics_ssl_certificate_subject.py index 1532214048..919e7a00eb 100644 --- a/src/datadog_api_client/v1/model/synthetics_ssl_certificate_subject.py +++ b/src/datadog_api_client/v1/model/synthetics_ssl_certificate_subject.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsSSLCertificateSubject(ModelNormal): @@ -88,8 +90,93 @@ def discriminator(): "alt_name": "altName", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsSSLCertificateSubject - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + c (str): Country Name associated with the certificate.. [optional] # noqa: E501 + cn (str): Common Name that associated with the certificate.. [optional] # noqa: E501 + l (str): Locality associated with the certificate.. [optional] # noqa: E501 + o (str): Organization associated with the certificate.. [optional] # noqa: E501 + ou (str): Organizational Unit associated with the certificate.. [optional] # noqa: E501 + st (str): State Or Province Name associated with the certificate.. [optional] # noqa: E501 + alt_name (str): Subject Alternative Name associated with the certificate.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +266,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_step.py b/src/datadog_api_client/v1/model/synthetics_step.py index db71fd08fa..80f4b1e950 100644 --- a/src/datadog_api_client/v1/model/synthetics_step.py +++ b/src/datadog_api_client/v1/model/synthetics_step.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -74,7 +76,7 @@ def openapi_types(): return { "allow_failure": (bool,), # noqa: E501 "name": (str,), # noqa: E501 - "params": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + "params": (dict,), # noqa: E501 "timeout": (int,), # noqa: E501 "type": (SyntheticsStepType,), # noqa: E501 } @@ -91,8 +93,91 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsStep - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + allow_failure (bool): A boolean set to allow this step to fail.. [optional] # noqa: E501 + name (str): The name of the step.. [optional] # noqa: E501 + params (dict): The parameters of the step.. [optional] # noqa: E501 + timeout (int): The time before declaring a step failed.. [optional] # noqa: E501 + type (SyntheticsStepType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -141,7 +226,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) allow_failure (bool): A boolean set to allow this step to fail.. [optional] # noqa: E501 name (str): The name of the step.. [optional] # noqa: E501 - params ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): The parameters of the step.. [optional] # noqa: E501 + params (dict): The parameters of the step.. [optional] # noqa: E501 timeout (int): The time before declaring a step failed.. [optional] # noqa: E501 type (SyntheticsStepType): [optional] # noqa: E501 """ @@ -180,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_step_detail.py b/src/datadog_api_client/v1/model/synthetics_step_detail.py index e147d164b9..302233b4b2 100644 --- a/src/datadog_api_client/v1/model/synthetics_step_detail.py +++ b/src/datadog_api_client/v1/model/synthetics_step_detail.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -96,7 +98,7 @@ def openapi_types(): "time_to_interactive": (float,), # noqa: E501 "type": (SyntheticsStepType,), # noqa: E501 "url": (str,), # noqa: E501 - "value": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + "value": (dict,), # noqa: E501 "vitals_metrics": ([SyntheticsCoreWebVitals],), # noqa: E501 "warnings": ([SyntheticsStepDetailWarning],), # noqa: E501 } @@ -125,8 +127,103 @@ def discriminator(): "warnings": "warnings", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsStepDetail - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + browser_errors ([SyntheticsBrowserError]): Array of errors collected for a browser test.. [optional] # noqa: E501 + check_type (SyntheticsCheckType): [optional] # noqa: E501 + description (str): Description of the test.. [optional] # noqa: E501 + duration (float): Total duration in millisecond of the test.. [optional] # noqa: E501 + error (str): Error returned by the test.. [optional] # noqa: E501 + playing_tab (SyntheticsPlayingTab): [optional] # noqa: E501 + screenshot_bucket_key (bool): Whether or not screenshots where collected by the test.. [optional] # noqa: E501 + skipped (bool): Whether or not to skip this step.. [optional] # noqa: E501 + snapshot_bucket_key (bool): Whether or not snapshots where collected by the test.. [optional] # noqa: E501 + step_id (int): The step ID.. [optional] # noqa: E501 + sub_test_step_details ([SyntheticsStepDetail]): If this steps include a sub-test. [Subtests documentation](https://docs.datadoghq.com/synthetics/browser_tests/advanced_options/#subtests).. [optional] # noqa: E501 + time_to_interactive (float): Time before starting the step.. [optional] # noqa: E501 + type (SyntheticsStepType): [optional] # noqa: E501 + url (str): URL to perform the step against.. [optional] # noqa: E501 + value (dict): Value for the step.. [optional] # noqa: E501 + vitals_metrics ([SyntheticsCoreWebVitals]): Array of Core Web Vitals metrics for the step.. [optional] # noqa: E501 + warnings ([SyntheticsStepDetailWarning]): Warning collected that didn't failed the step.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,7 +284,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 time_to_interactive (float): Time before starting the step.. [optional] # noqa: E501 type (SyntheticsStepType): [optional] # noqa: E501 url (str): URL to perform the step against.. [optional] # noqa: E501 - value ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Value for the step.. [optional] # noqa: E501 + value (dict): Value for the step.. [optional] # noqa: E501 vitals_metrics ([SyntheticsCoreWebVitals]): Array of Core Web Vitals metrics for the step.. [optional] # noqa: E501 warnings ([SyntheticsStepDetailWarning]): Warning collected that didn't failed the step.. [optional] # noqa: E501 """ @@ -226,3 +323,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_step_detail_warning.py b/src/datadog_api_client/v1/model/synthetics_step_detail_warning.py index e017c42dad..773135d241 100644 --- a/src/datadog_api_client/v1/model/synthetics_step_detail_warning.py +++ b/src/datadog_api_client/v1/model/synthetics_step_detail_warning.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, message, type, *args, **kwargs): # noqa: E501 + """SyntheticsStepDetailWarning - a model defined in OpenAPI + + Args: + message (str): Message for the warning. + type (SyntheticsWarningType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.message = message + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, message, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_step_type.py b/src/datadog_api_client/v1/model/synthetics_step_type.py index 56ebca4739..6de821709f 100644 --- a/src/datadog_api_client/v1/model/synthetics_step_type.py +++ b/src/datadog_api_client/v1/model/synthetics_step_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsStepType(ModelSimple): @@ -98,6 +100,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -201,3 +205,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsStepType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Step type used in your Synthetic test.., must be one of ["assertCurrentUrl", "assertElementAttribute", "assertElementContent", "assertElementPresent", "assertEmail", "assertFileDownload", "assertFromJavascript", "assertPageContains", "assertPageLacks", "click", "extractFromJavascript", "extractVariable", "goToEmailLink", "goToUrl", "goToUrlAndMeasureTti", "hover", "playSubTest", "pressKey", "refresh", "runApiTest", "scroll", "selectOption", "typeText", "uploadFiles", "wait", ] # noqa: E501 + + Keyword Args: + value (str): Step type used in your Synthetic test.., must be one of ["assertCurrentUrl", "assertElementAttribute", "assertElementContent", "assertElementPresent", "assertEmail", "assertFileDownload", "assertFromJavascript", "assertPageContains", "assertPageLacks", "click", "extractFromJavascript", "extractVariable", "goToEmailLink", "goToUrl", "goToUrlAndMeasureTti", "hover", "playSubTest", "pressKey", "refresh", "runApiTest", "scroll", "selectOption", "typeText", "uploadFiles", "wait", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_config.py b/src/datadog_api_client/v1/model/synthetics_test_config.py index 1b5a6561a5..751bb1fe10 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_config.py +++ b/src/datadog_api_client/v1/model/synthetics_test_config.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,90 @@ def discriminator(): "variables": "variables", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestConfig - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + assertions ([SyntheticsAssertion]): Array of assertions used for the test.. [optional] if omitted the server will use the default value of [] # noqa: E501 + config_variables ([SyntheticsConfigVariable]): API tests only - array of variables used for the test.. [optional] # noqa: E501 + request (SyntheticsTestRequest): [optional] # noqa: E501 + variables ([SyntheticsBrowserVariable]): Browser tests only - array of variables used for the test steps.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_details.py b/src/datadog_api_client/v1/model/synthetics_test_details.py index 1b00fdf0cd..64f9f0ddac 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_details.py +++ b/src/datadog_api_client/v1/model/synthetics_test_details.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -115,8 +117,101 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "monitor_id", # noqa: E501 + "public_id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestDetails - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + config (SyntheticsTestConfig): [optional] # noqa: E501 + locations ([str]): Array of locations used to run the test.. [optional] # noqa: E501 + message (str): Notification message associated with the test.. [optional] # noqa: E501 + monitor_id (int): The associated monitor ID.. [optional] # noqa: E501 + name (str): Name of the test.. [optional] # noqa: E501 + options (SyntheticsTestOptions): [optional] # noqa: E501 + public_id (str): The test public ID.. [optional] # noqa: E501 + status (SyntheticsTestPauseStatus): [optional] # noqa: E501 + steps ([SyntheticsStep]): For browser test, the steps of the test.. [optional] # noqa: E501 + subtype (SyntheticsTestDetailsSubType): [optional] # noqa: E501 + tags ([str]): Array of tags attached to the test.. [optional] # noqa: E501 + type (SyntheticsTestDetailsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -211,3 +306,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_details_sub_type.py b/src/datadog_api_client/v1/model/synthetics_test_details_sub_type.py index 88cec79a9b..6d9c19c137 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_details_sub_type.py +++ b/src/datadog_api_client/v1/model/synthetics_test_details_sub_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestDetailsSubType(ModelSimple): @@ -79,6 +81,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -182,3 +186,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsTestDetailsSubType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The subtype of the Synthetic API test, `http`, `ssl`, `tcp`, `dns`, `icmp` or `multi`.., must be one of ["http", "ssl", "tcp", "dns", "multi", "icmp", ] # noqa: E501 + + Keyword Args: + value (str): The subtype of the Synthetic API test, `http`, `ssl`, `tcp`, `dns`, `icmp` or `multi`.., must be one of ["http", "ssl", "tcp", "dns", "multi", "icmp", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_details_type.py b/src/datadog_api_client/v1/model/synthetics_test_details_type.py index 528ad1ba18..bec9540a9d 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_details_type.py +++ b/src/datadog_api_client/v1/model/synthetics_test_details_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestDetailsType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsTestDetailsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Synthetic test, either `api` or `browser`.., must be one of ["api", "browser", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Synthetic test, either `api` or `browser`.., must be one of ["api", "browser", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_headers.py b/src/datadog_api_client/v1/model/synthetics_test_headers.py index 46fb829954..376cc6f9c5 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_headers.py +++ b/src/datadog_api_client/v1/model/synthetics_test_headers.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestHeaders(ModelNormal): @@ -78,8 +80,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestHeaders - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -162,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_monitor_status.py b/src/datadog_api_client/v1/model/synthetics_test_monitor_status.py index 1892f61373..846b37b645 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_monitor_status.py +++ b/src/datadog_api_client/v1/model/synthetics_test_monitor_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestMonitorStatus(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsTestMonitorStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): The status of your Synthetic monitor. * `O` for not triggered * `1` for triggered * `2` for no data., must be one of [0, 1, 2, ] # noqa: E501 + + Keyword Args: + value (int): The status of your Synthetic monitor. * `O` for not triggered * `1` for triggered * `2` for no data., must be one of [0, 1, 2, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_options.py b/src/datadog_api_client/v1/model/synthetics_test_options.py index de90d0b09b..b89e473bc3 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_options.py +++ b/src/datadog_api_client/v1/model/synthetics_test_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -120,8 +122,99 @@ def discriminator(): "tick_every": "tick_every", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + accept_self_signed (bool): For SSL test, whether or not the test should allow self signed certificates.. [optional] # noqa: E501 + allow_insecure (bool): Allows loading insecure content for an HTTP request.. [optional] # noqa: E501 + device_ids ([SyntheticsDeviceID]): For browser test, array with the different device IDs used to run the test.. [optional] # noqa: E501 + disable_cors (bool): Whether or not to disable CORS mechanism.. [optional] # noqa: E501 + follow_redirects (bool): For API HTTP test, whether or not the test should follow redirects.. [optional] # noqa: E501 + min_failure_duration (int): Minimum amount of time in failure required to trigger an alert.. [optional] # noqa: E501 + min_location_failed (int): Minimum number of locations in failure required to trigger an alert.. [optional] # noqa: E501 + monitor_name (str): The monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.. [optional] # noqa: E501 + monitor_options (SyntheticsTestOptionsMonitorOptions): [optional] # noqa: E501 + monitor_priority (int): Integer from 1 (high) to 5 (low) indicating alert severity.. [optional] # noqa: E501 + no_screenshot (bool): Prevents saving screenshots of the steps.. [optional] # noqa: E501 + retry (SyntheticsTestOptionsRetry): [optional] # noqa: E501 + tick_every (int): The frequency at which to run the Synthetic test (in seconds).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -217,3 +310,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_options_monitor_options.py b/src/datadog_api_client/v1/model/synthetics_test_options_monitor_options.py index e638b1d2e7..9ad79eb8b6 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_options_monitor_options.py +++ b/src/datadog_api_client/v1/model/synthetics_test_options_monitor_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestOptionsMonitorOptions(ModelNormal): @@ -81,8 +83,87 @@ def discriminator(): "renotify_interval": "renotify_interval", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestOptionsMonitorOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + renotify_interval (int): Time interval before renotifying if the test is still failing (in minutes).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -166,3 +247,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_options_retry.py b/src/datadog_api_client/v1/model/synthetics_test_options_retry.py index bd0eb58f5e..97d999b81f 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_options_retry.py +++ b/src/datadog_api_client/v1/model/synthetics_test_options_retry.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestOptionsRetry(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "interval": "interval", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestOptionsRetry - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + count (int): Number of times a test needs to be retried before marking a location as failed. Defaults to 0.. [optional] # noqa: E501 + interval (float): Time interval between retries (in milliseconds). Defaults to 300ms.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_pause_status.py b/src/datadog_api_client/v1/model/synthetics_test_pause_status.py index c8726ac8ad..d394f5d21d 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_pause_status.py +++ b/src/datadog_api_client/v1/model/synthetics_test_pause_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestPauseStatus(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsTestPauseStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Define whether you want to start (`live`) or pause (`paused`) a Synthetic test.., must be one of ["live", "paused", ] # noqa: E501 + + Keyword Args: + value (str): Define whether you want to start (`live`) or pause (`paused`) a Synthetic test.., must be one of ["live", "paused", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_process_status.py b/src/datadog_api_client/v1/model/synthetics_test_process_status.py index 682995f0a6..7a20b78042 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_process_status.py +++ b/src/datadog_api_client/v1/model/synthetics_test_process_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestProcessStatus(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsTestProcessStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Status of a Synthetic test.., must be one of ["not_scheduled", "scheduled", "started", "finished", "finished_with_error", ] # noqa: E501 + + Keyword Args: + value (str): Status of a Synthetic test.., must be one of ["not_scheduled", "scheduled", "started", "finished", "finished_with_error", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/synthetics_test_request.py b/src/datadog_api_client/v1/model/synthetics_test_request.py index 714f4d3cf1..6bbb0c14c1 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_request.py +++ b/src/datadog_api_client/v1/model/synthetics_test_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -99,7 +101,7 @@ def openapi_types(): "no_saving_response_body": (bool,), # noqa: E501 "number_of_packets": (int,), # noqa: E501 "port": (int,), # noqa: E501 - "query": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + "query": (dict,), # noqa: E501 "should_track_hops": (bool,), # noqa: E501 "timeout": (float,), # noqa: E501 "url": (str,), # noqa: E501 @@ -128,8 +130,102 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + allow_insecure (bool): Allows loading insecure content for an HTTP request in a multistep test step.. [optional] # noqa: E501 + basic_auth (SyntheticsBasicAuth): [optional] # noqa: E501 + body (str): Body to include in the test.. [optional] # noqa: E501 + certificate (SyntheticsTestRequestCertificate): [optional] # noqa: E501 + dns_server (str): DNS server to use for DNS tests.. [optional] # noqa: E501 + dns_server_port (int): DNS server port to use for DNS tests.. [optional] # noqa: E501 + headers (SyntheticsTestHeaders): [optional] # noqa: E501 + host (str): Host name to perform the test with.. [optional] # noqa: E501 + method (HTTPMethod): [optional] # noqa: E501 + no_saving_response_body (bool): Determines whether or not to save the response body.. [optional] # noqa: E501 + number_of_packets (int): Number of pings to use per test.. [optional] # noqa: E501 + port (int): Port to use when performing the test.. [optional] # noqa: E501 + query (dict): Query to use for the test.. [optional] # noqa: E501 + should_track_hops (bool): Turns on a traceroute probe to discover all gateways along the path to the host destination.. [optional] # noqa: E501 + timeout (float): Timeout in seconds for the test.. [optional] # noqa: E501 + url (str): URL to perform the test with.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,7 +284,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 no_saving_response_body (bool): Determines whether or not to save the response body.. [optional] # noqa: E501 number_of_packets (int): Number of pings to use per test.. [optional] # noqa: E501 port (int): Port to use when performing the test.. [optional] # noqa: E501 - query ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Query to use for the test.. [optional] # noqa: E501 + query (dict): Query to use for the test.. [optional] # noqa: E501 should_track_hops (bool): Turns on a traceroute probe to discover all gateways along the path to the host destination.. [optional] # noqa: E501 timeout (float): Timeout in seconds for the test.. [optional] # noqa: E501 url (str): URL to perform the test with.. [optional] # noqa: E501 @@ -228,3 +324,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_request_certificate.py b/src/datadog_api_client/v1/model/synthetics_test_request_certificate.py index c25827be48..1cfb5e0a42 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_request_certificate.py +++ b/src/datadog_api_client/v1/model/synthetics_test_request_certificate.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "key": "key", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestRequestCertificate - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cert (SyntheticsTestRequestCertificateItem): [optional] # noqa: E501 + key (SyntheticsTestRequestCertificateItem): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_test_request_certificate_item.py b/src/datadog_api_client/v1/model/synthetics_test_request_certificate_item.py index 021fe023ba..aa52415559 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_request_certificate_item.py +++ b/src/datadog_api_client/v1/model/synthetics_test_request_certificate_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTestRequestCertificateItem(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "updated_at": "updatedAt", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTestRequestCertificateItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + content (str): Content of the certificate or key.. [optional] # noqa: E501 + filename (str): File name for the certificate or key.. [optional] # noqa: E501 + updated_at (str): Date of update of the certificate or key, ISO format.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_timing.py b/src/datadog_api_client/v1/model/synthetics_timing.py index af77f7a0d5..f3ae187721 100644 --- a/src/datadog_api_client/v1/model/synthetics_timing.py +++ b/src/datadog_api_client/v1/model/synthetics_timing.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTiming(ModelNormal): @@ -92,8 +94,95 @@ def discriminator(): "wait": "wait", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTiming - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dns (float): The duration in millisecond of the DNS lookup.. [optional] # noqa: E501 + download (float): The time in millisecond to download the response.. [optional] # noqa: E501 + first_byte (float): The time in millisecond to first byte.. [optional] # noqa: E501 + handshake (float): The duration in millisecond of the TLS handshake.. [optional] # noqa: E501 + redirect (float): The time in millisecond spent during redirections.. [optional] # noqa: E501 + ssl (float): The duration in millisecond of the TLS handshake.. [optional] # noqa: E501 + tcp (float): Time in millisecond to establish the TCP connection.. [optional] # noqa: E501 + total (float): The overall time in millisecond the request took to be processed.. [optional] # noqa: E501 + wait (float): Time spent in millisecond waiting for a response.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +274,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_location.py b/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_location.py index 99dbf48adf..17a2478cfa 100644 --- a/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_location.py +++ b/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_location.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsTriggerCITestLocation(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTriggerCITestLocation - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): Unique identifier of the location.. [optional] # noqa: E501 + name (str): Name of the location.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_run_result.py b/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_run_result.py index b43634da9b..a4d9021551 100644 --- a/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_run_result.py +++ b/src/datadog_api_client/v1/model/synthetics_trigger_ci_test_run_result.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,90 @@ def discriminator(): "result_id": "result_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTriggerCITestRunResult - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + device (SyntheticsDeviceID): [optional] # noqa: E501 + location (int): The location ID of the test run.. [optional] # noqa: E501 + public_id (str): The public ID of the Synthetics test.. [optional] # noqa: E501 + result_id (str): ID of the result.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_trigger_ci_tests_response.py b/src/datadog_api_client/v1/model/synthetics_trigger_ci_tests_response.py index 4f66fa8563..3b51d90a22 100644 --- a/src/datadog_api_client/v1/model/synthetics_trigger_ci_tests_response.py +++ b/src/datadog_api_client/v1/model/synthetics_trigger_ci_tests_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "triggered_check_ids": "triggered_check_ids", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsTriggerCITestsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + locations ([SyntheticsTriggerCITestLocation]): List of Synthetics locations.. [optional] # noqa: E501 + results ([SyntheticsTriggerCITestRunResult]): Information about the tests runs.. [optional] # noqa: E501 + triggered_check_ids ([str]): The public IDs of the Synthetics test triggered.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_update_test_pause_status_payload.py b/src/datadog_api_client/v1/model/synthetics_update_test_pause_status_payload.py index 80d3685e70..23e3ddda2f 100644 --- a/src/datadog_api_client/v1/model/synthetics_update_test_pause_status_payload.py +++ b/src/datadog_api_client/v1/model/synthetics_update_test_pause_status_payload.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "new_status": "new_status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SyntheticsUpdateTestPauseStatusPayload - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + new_status (SyntheticsTestPauseStatus): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_variable_parser.py b/src/datadog_api_client/v1/model/synthetics_variable_parser.py index 061ee176c8..ee47759f94 100644 --- a/src/datadog_api_client/v1/model/synthetics_variable_parser.py +++ b/src/datadog_api_client/v1/model/synthetics_variable_parser.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,91 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """SyntheticsVariableParser - a model defined in OpenAPI + + Args: + type (SyntheticsGlobalVariableParserType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + value (str): Regex or JSON path used for the parser. Not used with type `raw`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +259,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/synthetics_warning_type.py b/src/datadog_api_client/v1/model/synthetics_warning_type.py index 623172e395..c418d01e90 100644 --- a/src/datadog_api_client/v1/model/synthetics_warning_type.py +++ b/src/datadog_api_client/v1/model/synthetics_warning_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class SyntheticsWarningType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SyntheticsWarningType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): User locator used.. if omitted defaults to "user_locator", must be one of ["user_locator", ] # noqa: E501 + + Keyword Args: + value (str): User locator used.. if omitted defaults to "user_locator", must be one of ["user_locator", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "user_locator" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/table_widget_cell_display_mode.py b/src/datadog_api_client/v1/model/table_widget_cell_display_mode.py index 7ac322e014..8c6a0a294a 100644 --- a/src/datadog_api_client/v1/model/table_widget_cell_display_mode.py +++ b/src/datadog_api_client/v1/model/table_widget_cell_display_mode.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TableWidgetCellDisplayMode(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TableWidgetCellDisplayMode - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Define a display mode for the table cell.., must be one of ["number", "bar", ] # noqa: E501 + + Keyword Args: + value (str): Define a display mode for the table cell.., must be one of ["number", "bar", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/table_widget_definition.py b/src/datadog_api_client/v1/model/table_widget_definition.py index 331a06a79c..070ef9a92a 100644 --- a/src/datadog_api_client/v1/model/table_widget_definition.py +++ b/src/datadog_api_client/v1/model/table_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,98 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """TableWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([TableWidgetRequest]): Widget definition. + type (TableWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + has_search_bar (TableWidgetHasSearchBar): [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +295,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/table_widget_definition_type.py b/src/datadog_api_client/v1/model/table_widget_definition_type.py index 32a73581bf..937da62d0a 100644 --- a/src/datadog_api_client/v1/model/table_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/table_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TableWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TableWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the table widget.. if omitted defaults to "query_table", must be one of ["query_table", ] # noqa: E501 + + Keyword Args: + value (str): Type of the table widget.. if omitted defaults to "query_table", must be one of ["query_table", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "query_table" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/table_widget_has_search_bar.py b/src/datadog_api_client/v1/model/table_widget_has_search_bar.py index 810a6ca87d..608300ac11 100644 --- a/src/datadog_api_client/v1/model/table_widget_has_search_bar.py +++ b/src/datadog_api_client/v1/model/table_widget_has_search_bar.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TableWidgetHasSearchBar(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TableWidgetHasSearchBar - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Controls the display of the search bar.., must be one of ["always", "never", "auto", ] # noqa: E501 + + Keyword Args: + value (str): Controls the display of the search bar.., must be one of ["always", "never", "auto", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/table_widget_request.py b/src/datadog_api_client/v1/model/table_widget_request.py index de7a808d48..ada1e44a46 100644 --- a/src/datadog_api_client/v1/model/table_widget_request.py +++ b/src/datadog_api_client/v1/model/table_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -137,8 +139,105 @@ def discriminator(): "security_query": "security_query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """TableWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregator (WidgetAggregator): [optional] # noqa: E501 + alias (str): The column name (defaults to the metric name).. [optional] # noqa: E501 + apm_query (LogQueryDefinition): [optional] # noqa: E501 + apm_stats_query (ApmStatsQueryDefinition): [optional] # noqa: E501 + cell_display_mode ([TableWidgetCellDisplayMode]): A list of display modes for each table cell.. [optional] # noqa: E501 + conditional_formats ([WidgetConditionalFormat]): List of conditional formats.. [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + formulas ([WidgetFormula]): List of formulas that operate on queries. **This feature is currently in beta.**. [optional] # noqa: E501 + limit (int): For metric queries, the number of lines to show in the table. Only one request should have this property.. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + order (WidgetSort): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Query definition.. [optional] # noqa: E501 + queries ([FormulaAndFunctionQueryDefinition]): List of queries that can be returned directly or used in formulas. **This feature is currently in beta.**. [optional] # noqa: E501 + response_format (FormulaAndFunctionResponseFormat): [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -240,3 +339,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/tag_to_hosts.py b/src/datadog_api_client/v1/model/tag_to_hosts.py index 1901554c1d..8a9fe9fd2e 100644 --- a/src/datadog_api_client/v1/model/tag_to_hosts.py +++ b/src/datadog_api_client/v1/model/tag_to_hosts.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TagToHosts(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """TagToHosts - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tags ({str: ([str],)}): A list of tags to apply to the host.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/target_format_type.py b/src/datadog_api_client/v1/model/target_format_type.py index 8a985e7619..7ff6a4071f 100644 --- a/src/datadog_api_client/v1/model/target_format_type.py +++ b/src/datadog_api_client/v1/model/target_format_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TargetFormatType(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TargetFormatType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): If the `target_type` of the remapper is `attribute`, try to cast the value to a new specific type. If the cast is not possible, the original type is kept. `string`, `integer`, or `double` are the possible types. If the `target_type` is `tag`, this parameter may not be specified.., must be one of ["auto", "string", "integer", "double", ] # noqa: E501 + + Keyword Args: + value (str): If the `target_type` of the remapper is `attribute`, try to cast the value to a new specific type. If the cast is not possible, the original type is kept. `string`, `integer`, or `double` are the possible types. If the `target_type` is `tag`, this parameter may not be specified.., must be one of ["auto", "string", "integer", "double", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/timeseries_widget_definition.py b/src/datadog_api_client/v1/model/timeseries_widget_definition.py index 67db35517f..87be8cc793 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_definition.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -133,8 +135,105 @@ def discriminator(): "yaxis": "yaxis", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """TimeseriesWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([TimeseriesWidgetRequest]): List of timeseries widget requests. + type (TimeseriesWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + events ([WidgetEvent]): List of widget events.. [optional] # noqa: E501 + legend_columns ([TimeseriesWidgetLegendColumn]): Columns displayed in the legend.. [optional] # noqa: E501 + legend_layout (TimeseriesWidgetLegendLayout): [optional] # noqa: E501 + legend_size (str): Available legend sizes for a widget. Should be one of \"0\", \"2\", \"4\", \"8\", \"16\", or \"auto\".. [optional] # noqa: E501 + markers ([WidgetMarker]): List of markers.. [optional] # noqa: E501 + right_yaxis (WidgetAxis): [optional] # noqa: E501 + show_legend (bool): (screenboard only) Show the legend for this widget.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + yaxis (WidgetAxis): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -236,3 +335,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/timeseries_widget_definition_type.py b/src/datadog_api_client/v1/model/timeseries_widget_definition_type.py index 4b75485ac7..3ad86170d7 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TimeseriesWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TimeseriesWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the timeseries widget.. if omitted defaults to "timeseries", must be one of ["timeseries", ] # noqa: E501 + + Keyword Args: + value (str): Type of the timeseries widget.. if omitted defaults to "timeseries", must be one of ["timeseries", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "timeseries" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/timeseries_widget_expression_alias.py b/src/datadog_api_client/v1/model/timeseries_widget_expression_alias.py index 467a2f8208..fb073bf3e1 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_expression_alias.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_expression_alias.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TimeseriesWidgetExpressionAlias(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "alias_name": "alias_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, expression, *args, **kwargs): # noqa: E501 + """TimeseriesWidgetExpressionAlias - a model defined in OpenAPI + + Args: + expression (str): Expression name. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + alias_name (str): Expression alias.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.expression = expression + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +252,8 @@ def __init__(self, expression, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/timeseries_widget_legend_column.py b/src/datadog_api_client/v1/model/timeseries_widget_legend_column.py index 4e51565ae3..214a4dc66d 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_legend_column.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_legend_column.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TimeseriesWidgetLegendColumn(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TimeseriesWidgetLegendColumn - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Legend column.., must be one of ["value", "avg", "sum", "min", "max", ] # noqa: E501 + + Keyword Args: + value (str): Legend column.., must be one of ["value", "avg", "sum", "min", "max", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/timeseries_widget_legend_layout.py b/src/datadog_api_client/v1/model/timeseries_widget_legend_layout.py index 2e6c589069..85dc3657f1 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_legend_layout.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_legend_layout.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TimeseriesWidgetLegendLayout(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TimeseriesWidgetLegendLayout - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Layout of the legend.., must be one of ["auto", "horizontal", "vertical", ] # noqa: E501 + + Keyword Args: + value (str): Layout of the legend.., must be one of ["auto", "horizontal", "vertical", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/timeseries_widget_request.py b/src/datadog_api_client/v1/model/timeseries_widget_request.py index 9c7be076b8..0957d013be 100644 --- a/src/datadog_api_client/v1/model/timeseries_widget_request.py +++ b/src/datadog_api_client/v1/model/timeseries_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -129,8 +131,103 @@ def discriminator(): "style": "style", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """TimeseriesWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + audit_query (LogQueryDefinition): [optional] # noqa: E501 + display_type (WidgetDisplayType): [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + formulas ([WidgetFormula]): List of formulas that operate on queries. **This feature is currently in beta.**. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + metadata ([TimeseriesWidgetExpressionAlias]): Used to define expression aliases.. [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + on_right_yaxis (bool): Whether or not to display a second y-axis on the right.. [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Widget query.. [optional] # noqa: E501 + queries ([FormulaAndFunctionQueryDefinition]): List of queries that can be returned directly or used in formulas. **This feature is currently in beta.**. [optional] # noqa: E501 + response_format (FormulaAndFunctionResponseFormat): [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + style (WidgetRequestStyle): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -230,3 +327,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/toplist_widget_definition.py b/src/datadog_api_client/v1/model/toplist_widget_definition.py index 3e6a200e6d..546b1e529c 100644 --- a/src/datadog_api_client/v1/model/toplist_widget_definition.py +++ b/src/datadog_api_client/v1/model/toplist_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,97 @@ def discriminator(): "title_size": "title_size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, requests, type, *args, **kwargs): # noqa: E501 + """ToplistWidgetDefinition - a model defined in OpenAPI + + Args: + requests ([ToplistWidgetRequest]): List of top list widget requests. + type (ToplistWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of your widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.requests = requests + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -198,3 +289,8 @@ def __init__(self, requests, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/toplist_widget_definition_type.py b/src/datadog_api_client/v1/model/toplist_widget_definition_type.py index 90e2b51cf0..b4b56a0f30 100644 --- a/src/datadog_api_client/v1/model/toplist_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/toplist_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class ToplistWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ToplistWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the top list widget.. if omitted defaults to "toplist", must be one of ["toplist", ] # noqa: E501 + + Keyword Args: + value (str): Type of the top list widget.. if omitted defaults to "toplist", must be one of ["toplist", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "toplist" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/toplist_widget_request.py b/src/datadog_api_client/v1/model/toplist_widget_request.py index a79c0460ec..065985c6cc 100644 --- a/src/datadog_api_client/v1/model/toplist_widget_request.py +++ b/src/datadog_api_client/v1/model/toplist_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -127,8 +129,101 @@ def discriminator(): "style": "style", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ToplistWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_query (LogQueryDefinition): [optional] # noqa: E501 + audit_query (LogQueryDefinition): [optional] # noqa: E501 + conditional_formats ([WidgetConditionalFormat]): List of conditional formats.. [optional] # noqa: E501 + event_query (LogQueryDefinition): [optional] # noqa: E501 + formulas ([WidgetFormula]): List of formulas that operate on queries. **This feature is currently in beta.**. [optional] # noqa: E501 + log_query (LogQueryDefinition): [optional] # noqa: E501 + network_query (LogQueryDefinition): [optional] # noqa: E501 + process_query (ProcessQueryDefinition): [optional] # noqa: E501 + profile_metrics_query (LogQueryDefinition): [optional] # noqa: E501 + q (str): Widget query.. [optional] # noqa: E501 + queries ([FormulaAndFunctionQueryDefinition]): List of queries that can be returned directly or used in formulas. **This feature is currently in beta.**. [optional] # noqa: E501 + response_format (FormulaAndFunctionResponseFormat): [optional] # noqa: E501 + rum_query (LogQueryDefinition): [optional] # noqa: E501 + security_query (LogQueryDefinition): [optional] # noqa: E501 + style (WidgetRequestStyle): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -226,3 +321,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/tree_map_color_by.py b/src/datadog_api_client/v1/model/tree_map_color_by.py index daa137003f..4fd32d51be 100644 --- a/src/datadog_api_client/v1/model/tree_map_color_by.py +++ b/src/datadog_api_client/v1/model/tree_map_color_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TreeMapColorBy(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TreeMapColorBy - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The attribute used to determine color in the widget.. if omitted defaults to "user", must be one of ["user", ] # noqa: E501 + + Keyword Args: + value (str): The attribute used to determine color in the widget.. if omitted defaults to "user", must be one of ["user", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "user" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/tree_map_group_by.py b/src/datadog_api_client/v1/model/tree_map_group_by.py index 5d720f6bd1..adbc8457c6 100644 --- a/src/datadog_api_client/v1/model/tree_map_group_by.py +++ b/src/datadog_api_client/v1/model/tree_map_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TreeMapGroupBy(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TreeMapGroupBy - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The attribute used to group elements in the widget.., must be one of ["user", "family", "process", ] # noqa: E501 + + Keyword Args: + value (str): The attribute used to group elements in the widget.., must be one of ["user", "family", "process", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/tree_map_size_by.py b/src/datadog_api_client/v1/model/tree_map_size_by.py index aa1026fd7c..608feb2c37 100644 --- a/src/datadog_api_client/v1/model/tree_map_size_by.py +++ b/src/datadog_api_client/v1/model/tree_map_size_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TreeMapSizeBy(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TreeMapSizeBy - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The attribute used to determine size in the widget.., must be one of ["pct_cpu", "pct_mem", ] # noqa: E501 + + Keyword Args: + value (str): The attribute used to determine size in the widget.., must be one of ["pct_cpu", "pct_mem", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/tree_map_widget_definition.py b/src/datadog_api_client/v1/model/tree_map_widget_definition.py index 05b150c5f9..6eda312dc2 100644 --- a/src/datadog_api_client/v1/model/tree_map_widget_definition.py +++ b/src/datadog_api_client/v1/model/tree_map_widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -106,8 +108,99 @@ def discriminator(): "title": "title", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, color_by, group_by, requests, size_by, type, *args, **kwargs): # noqa: E501 + """TreeMapWidgetDefinition - a model defined in OpenAPI + + Args: + color_by (TreeMapColorBy): + group_by (TreeMapGroupBy): + requests ([TreeMapWidgetRequest]): List of top list widget requests. + size_by (TreeMapSizeBy): + type (TreeMapWidgetDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + title (str): Title of your widget.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.color_by = color_by + self.group_by = group_by + self.requests = requests + self.size_by = size_by + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -203,3 +296,8 @@ def __init__(self, color_by, group_by, requests, size_by, type, *args, **kwargs) # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/tree_map_widget_definition_type.py b/src/datadog_api_client/v1/model/tree_map_widget_definition_type.py index 318e536f4b..7a318d7457 100644 --- a/src/datadog_api_client/v1/model/tree_map_widget_definition_type.py +++ b/src/datadog_api_client/v1/model/tree_map_widget_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TreeMapWidgetDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """TreeMapWidgetDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the treemap widget.. if omitted defaults to "treemap", must be one of ["treemap", ] # noqa: E501 + + Keyword Args: + value (str): Type of the treemap widget.. if omitted defaults to "treemap", must be one of ["treemap", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "treemap" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/tree_map_widget_request.py b/src/datadog_api_client/v1/model/tree_map_widget_request.py index d380a0ddfc..585b65b933 100644 --- a/src/datadog_api_client/v1/model/tree_map_widget_request.py +++ b/src/datadog_api_client/v1/model/tree_map_widget_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class TreeMapWidgetRequest(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "q": "q", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """TreeMapWidgetRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + q (str): The widget metrics query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_analyzed_logs_hour.py b/src/datadog_api_client/v1/model/usage_analyzed_logs_hour.py index 04eabc7321..091ce41910 100644 --- a/src/datadog_api_client/v1/model/usage_analyzed_logs_hour.py +++ b/src/datadog_api_client/v1/model/usage_analyzed_logs_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAnalyzedLogsHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAnalyzedLogsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + analyzed_logs (int): Contains the number of analyzed logs.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_analyzed_logs_response.py b/src/datadog_api_client/v1/model/usage_analyzed_logs_response.py index ff8b1b4561..63c00b6049 100644 --- a/src/datadog_api_client/v1/model/usage_analyzed_logs_response.py +++ b/src/datadog_api_client/v1/model/usage_analyzed_logs_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAnalyzedLogsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageAnalyzedLogsHour]): Get hourly usage for analyzed logs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_aggregates.py b/src/datadog_api_client/v1/model/usage_attribution_aggregates.py index e3194a4b0c..b0fda4342e 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_aggregates.py +++ b/src/datadog_api_client/v1/model/usage_attribution_aggregates.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -163,9 +167,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageAttributionAggregates - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([UsageAttributionAggregatesBody]): An array of available aggregates.. # noqa: E501 + + Keyword Args: + value ([UsageAttributionAggregatesBody]): An array of available aggregates.. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -191,3 +278,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_attribution_aggregates_body.py b/src/datadog_api_client/v1/model/usage_attribution_aggregates_body.py index 1dc04fbdb6..04d9af2665 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_aggregates_body.py +++ b/src/datadog_api_client/v1/model/usage_attribution_aggregates_body.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionAggregatesBody(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionAggregatesBody - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agg_type (str): The aggregate type.. [optional] # noqa: E501 + field (str): The field.. [optional] # noqa: E501 + value (float): The value for a given field.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_body.py b/src/datadog_api_client/v1/model/usage_attribution_body.py index 0a5f11ab40..0bc6dc9f21 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_body.py +++ b/src/datadog_api_client/v1/model/usage_attribution_body.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,93 @@ def discriminator(): "values": "values", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionBody - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + month (datetime): Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM].. [optional] # noqa: E501 + org_name (str): The name of the organization.. [optional] # noqa: E501 + public_id (str): The organization public ID.. [optional] # noqa: E501 + tag_config_source (str): The source of the usage attribution tag configuration and the selected tags in the format `:--`.. [optional] # noqa: E501 + tags (UsageAttributionTagNames): [optional] # noqa: E501 + updated_at (str): Shows the the most recent hour in the current months for all organizations for which all usages were calculated.. [optional] # noqa: E501 + values (UsageAttributionValues): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +275,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_metadata.py b/src/datadog_api_client/v1/model/usage_attribution_metadata.py index c7da064c2e..486c14a7f9 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_metadata.py +++ b/src/datadog_api_client/v1/model/usage_attribution_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "pagination": "pagination", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregates (UsageAttributionAggregates): [optional] # noqa: E501 + pagination (UsageAttributionPagination): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_pagination.py b/src/datadog_api_client/v1/model/usage_attribution_pagination.py index e4589ea5c2..d55581b093 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_pagination.py +++ b/src/datadog_api_client/v1/model/usage_attribution_pagination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionPagination(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "total_number_of_records": "total_number_of_records", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionPagination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + limit (int): Maximum amount of records to be returned.. [optional] # noqa: E501 + next_record_id (str): The cursor to use to get the next results, if any. To make the next request, use the same parameters with the addition of this next_record_id.. [optional] # noqa: E501 + total_number_of_records (int): Total number of records. (deprecated after May 1st, 2021). [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_response.py b/src/datadog_api_client/v1/model/usage_attribution_response.py index e109fd365e..84648797ce 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_response.py +++ b/src/datadog_api_client/v1/model/usage_attribution_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + metadata (UsageAttributionMetadata): [optional] # noqa: E501 + usage ([UsageAttributionBody]): Get Usage Summary by tag(s).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_sort.py b/src/datadog_api_client/v1/model/usage_attribution_sort.py index 7047138ed5..b18bb8c790 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_sort.py +++ b/src/datadog_api_client/v1/model/usage_attribution_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionSort(ModelSimple): @@ -95,6 +97,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -194,3 +198,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageAttributionSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The field to sort by.. if omitted defaults to "custom_timeseries_usage", must be one of ["api_percentage", "snmp_usage", "apm_host_usage", "api_usage", "container_usage", "custom_timeseries_percentage", "container_percentage", "apm_host_percentage", "npm_host_percentage", "browser_percentage", "browser_usage", "infra_host_percentage", "snmp_percentage", "npm_host_usage", "infra_host_usage", "custom_timeseries_usage", "lambda_functions_usage", "lambda_functions_percentage", "lambda_invocations_usage", "lambda_invocations_percentage", "lambda_usage", "lambda_percentage", ] # noqa: E501 + + Keyword Args: + value (str): The field to sort by.. if omitted defaults to "custom_timeseries_usage", must be one of ["api_percentage", "snmp_usage", "apm_host_usage", "api_usage", "container_usage", "custom_timeseries_percentage", "container_percentage", "apm_host_percentage", "npm_host_percentage", "browser_percentage", "browser_usage", "infra_host_percentage", "snmp_percentage", "npm_host_usage", "infra_host_usage", "custom_timeseries_usage", "lambda_functions_usage", "lambda_functions_percentage", "lambda_invocations_usage", "lambda_invocations_percentage", "lambda_usage", "lambda_percentage", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "custom_timeseries_usage" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_attribution_supported_metrics.py b/src/datadog_api_client/v1/model/usage_attribution_supported_metrics.py index 01adfc2d66..d69882ff32 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_supported_metrics.py +++ b/src/datadog_api_client/v1/model/usage_attribution_supported_metrics.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionSupportedMetrics(ModelSimple): @@ -102,6 +104,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -205,3 +209,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageAttributionSupportedMetrics - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Supported fields for usage attribution requests (valid requests contain one or more metrics, or `*` for all).., must be one of ["custom_timeseries_usage", "container_usage", "snmp_percentage", "apm_host_usage", "browser_usage", "npm_host_percentage", "infra_host_usage", "custom_timeseries_percentage", "container_percentage", "lambda_usage", "api_usage", "apm_host_percentage", "infra_host_percentage", "snmp_usage", "browser_percentage", "api_percentage", "lambda_percentage", "npm_host_usage", "lambda_functions_usage", "lambda_functions_percentage", "lambda_invocations_usage", "lambda_invocations_percentage", "fargate_usage", "fargate_percentage", "profiled_host_usage", "profiled_host_percentage", "profiled_container_usage", "profiled_container_percentage", "*", ] # noqa: E501 + + Keyword Args: + value (str): Supported fields for usage attribution requests (valid requests contain one or more metrics, or `*` for all).., must be one of ["custom_timeseries_usage", "container_usage", "snmp_percentage", "apm_host_usage", "browser_usage", "npm_host_percentage", "infra_host_usage", "custom_timeseries_percentage", "container_percentage", "lambda_usage", "api_usage", "apm_host_percentage", "infra_host_percentage", "snmp_usage", "browser_percentage", "api_percentage", "lambda_percentage", "npm_host_usage", "lambda_functions_usage", "lambda_functions_percentage", "lambda_invocations_usage", "lambda_invocations_percentage", "fargate_usage", "fargate_percentage", "profiled_host_usage", "profiled_host_percentage", "profiled_container_usage", "profiled_container_percentage", "*", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_attribution_tag_names.py b/src/datadog_api_client/v1/model/usage_attribution_tag_names.py index ccc1d9ba19..8d549219d6 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_tag_names.py +++ b/src/datadog_api_client/v1/model/usage_attribution_tag_names.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionTagNames(ModelNormal): @@ -78,8 +80,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionTagNames - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -162,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_attribution_values.py b/src/datadog_api_client/v1/model/usage_attribution_values.py index 4773a68074..9645f43a2f 100644 --- a/src/datadog_api_client/v1/model/usage_attribution_values.py +++ b/src/datadog_api_client/v1/model/usage_attribution_values.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAttributionValues(ModelNormal): @@ -142,8 +144,120 @@ def discriminator(): "snmp_usage": "snmp_usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAttributionValues - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + api_percentage (float): The percentage of synthetic API test usage by tag(s).. [optional] # noqa: E501 + api_usage (float): The synthetic API test usage by tag(s).. [optional] # noqa: E501 + apm_host_percentage (float): The percentage of APM host usage by tag(s).. [optional] # noqa: E501 + apm_host_usage (float): The APM host usage by tag(s).. [optional] # noqa: E501 + browser_percentage (float): The percentage of synthetic browser test usage by tag(s).. [optional] # noqa: E501 + browser_usage (float): The synthetic browser test usage by tag(s).. [optional] # noqa: E501 + container_percentage (float): The percentage of container usage by tag(s).. [optional] # noqa: E501 + container_usage (float): The container usage by tag(s).. [optional] # noqa: E501 + cspm_container_percentage (float): The percentage of Cloud Security Posture Management container usage by tag(s). [optional] # noqa: E501 + cspm_container_usage (float): The Cloud Security Posture Management container usage by tag(s). [optional] # noqa: E501 + cspm_host_percentage (float): The percentage of Cloud Security Posture Management host usage by tag(s). [optional] # noqa: E501 + cspm_host_usage (float): The Cloud Security Posture Management host usage by tag(s). [optional] # noqa: E501 + custom_timeseries_percentage (float): The percentage of custom metrics usage by tag(s).. [optional] # noqa: E501 + custom_timeseries_usage (float): The custom metrics usage by tag(s).. [optional] # noqa: E501 + cws_container_percentage (float): The percentage of Cloud Workload Security container usage by tag(s). [optional] # noqa: E501 + cws_container_usage (float): The Cloud Workload Security container usage by tag(s). [optional] # noqa: E501 + cws_host_percentage (float): The percentage of Cloud Workload Security host usage by tag(s). [optional] # noqa: E501 + cws_host_usage (float): The Cloud Workload Security host usage by tag(s). [optional] # noqa: E501 + infra_host_percentage (float): The percentage of infrastructure host usage by tag(s).. [optional] # noqa: E501 + infra_host_usage (float): The infrastructure host usage by tag(s).. [optional] # noqa: E501 + lambda_functions_percentage (float): The percentage of Lambda function usage by tag(s).. [optional] # noqa: E501 + lambda_functions_usage (float): The Lambda function usage by tag(s).. [optional] # noqa: E501 + lambda_invocations_percentage (float): The percentage of Lambda invocation usage by tag(s).. [optional] # noqa: E501 + lambda_invocations_usage (float): The Lambda invocation usage by tag(s).. [optional] # noqa: E501 + lambda_percentage (float): The percentage of Lambda function usage by tag(s). **Note** this field is deprecated. Use lambda_functions_percentage instead.. [optional] # noqa: E501 + lambda_usage (float): The Lambda function usage by tag(s). **Note** this field is deprecated. Use lambda_functions_usage instead.. [optional] # noqa: E501 + npm_host_percentage (float): The percentage of network host usage by tag(s).. [optional] # noqa: E501 + npm_host_usage (float): The network host usage by tag(s).. [optional] # noqa: E501 + profiled_containers_percentage (float): The percentage of profiled containers usage by tag(s).. [optional] # noqa: E501 + profiled_containers_usage (float): The profiled container usage by tag(s).. [optional] # noqa: E501 + profiled_hosts_percentage (float): The percentage of profiled hosts usage by tag(s).. [optional] # noqa: E501 + profiled_hosts_usage (float): The profiled host usage by tag(s).. [optional] # noqa: E501 + snmp_percentage (float): The percentage of network device usage by tag(s).. [optional] # noqa: E501 + snmp_usage (float): The network device usage by tag(s).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -260,3 +374,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_audit_logs_hour.py b/src/datadog_api_client/v1/model/usage_audit_logs_hour.py index b254aa0df6..600609f703 100644 --- a/src/datadog_api_client/v1/model/usage_audit_logs_hour.py +++ b/src/datadog_api_client/v1/model/usage_audit_logs_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageAuditLogsHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "lines_indexed": "lines_indexed", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAuditLogsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + lines_indexed (int): The total number of audit logs lines indexed during a given hour.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_audit_logs_response.py b/src/datadog_api_client/v1/model/usage_audit_logs_response.py index 75030822ab..183680c468 100644 --- a/src/datadog_api_client/v1/model/usage_audit_logs_response.py +++ b/src/datadog_api_client/v1/model/usage_audit_logs_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageAuditLogsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageAuditLogsHour]): Get hourly usage for audit logs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_billable_summary_body.py b/src/datadog_api_client/v1/model/usage_billable_summary_body.py index 8ecd00bd01..77adf0f153 100644 --- a/src/datadog_api_client/v1/model/usage_billable_summary_body.py +++ b/src/datadog_api_client/v1/model/usage_billable_summary_body.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageBillableSummaryBody(ModelNormal): @@ -88,8 +90,93 @@ def discriminator(): "usage_unit": "usage_unit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageBillableSummaryBody - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + account_billable_usage (int): The total account usage.. [optional] # noqa: E501 + elapsed_usage_hours (int): Elapsed usage hours for some billable product.. [optional] # noqa: E501 + first_billable_usage_hour (datetime): The first billable hour for the org.. [optional] # noqa: E501 + last_billable_usage_hour (datetime): The last billable hour for the org.. [optional] # noqa: E501 + org_billable_usage (int): The number of units used within the billable timeframe.. [optional] # noqa: E501 + percentage_in_account (float): The percentage of account usage the org represents.. [optional] # noqa: E501 + usage_unit (str): Units pertaining to the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +266,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_billable_summary_hour.py b/src/datadog_api_client/v1/model/usage_billable_summary_hour.py index 493a42a7f6..8e933a4638 100644 --- a/src/datadog_api_client/v1/model/usage_billable_summary_hour.py +++ b/src/datadog_api_client/v1/model/usage_billable_summary_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,94 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageBillableSummaryHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + billing_plan (str): The billing plan.. [optional] # noqa: E501 + end_date (datetime): Shows the last date of usage.. [optional] # noqa: E501 + num_orgs (int): The number of organizations.. [optional] # noqa: E501 + org_name (str): The organization name.. [optional] # noqa: E501 + public_id (str): The organization public ID.. [optional] # noqa: E501 + ratio_in_month (int): Shows usage aggregation for a billing period.. [optional] # noqa: E501 + start_date (datetime): Shows the first date of usage.. [optional] # noqa: E501 + usage (UsageBillableSummaryKeys): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +277,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_billable_summary_keys.py b/src/datadog_api_client/v1/model/usage_billable_summary_keys.py index c05c280e54..325c3fccf9 100644 --- a/src/datadog_api_client/v1/model/usage_billable_summary_keys.py +++ b/src/datadog_api_client/v1/model/usage_billable_summary_keys.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -145,8 +147,118 @@ def discriminator(): "timeseries_average": "timeseries_average", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageBillableSummaryKeys - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + apm_host_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + apm_host_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + apm_trace_search_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + fargate_container_average (UsageBillableSummaryBody): [optional] # noqa: E501 + infra_container_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + infra_host_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + infra_host_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + iot_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + lambda_function_average (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_15day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_180day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_30day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_3day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_45day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_60day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_7day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_90day_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_custom_retention_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_indexed_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + logs_ingested_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + network_device_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + npm_flow_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + npm_host_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + npm_host_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + prof_container_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + prof_host_top99p (UsageBillableSummaryBody): [optional] # noqa: E501 + rum_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + serverless_invocation_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + siem_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + synthetics_api_tests_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + synthetics_browser_checks_sum (UsageBillableSummaryBody): [optional] # noqa: E501 + timeseries_average (UsageBillableSummaryBody): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -261,3 +373,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_billable_summary_response.py b/src/datadog_api_client/v1/model/usage_billable_summary_response.py index 0f61ea9954..e09775ae51 100644 --- a/src/datadog_api_client/v1/model/usage_billable_summary_response.py +++ b/src/datadog_api_client/v1/model/usage_billable_summary_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageBillableSummaryResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageBillableSummaryHour]): An array of objects regarding usage of billable summary.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_hour.py b/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_hour.py index 6793f55340..92f2add8fd 100644 --- a/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_hour.py +++ b/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageCloudSecurityPostureManagementHour(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCloudSecurityPostureManagementHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + container_count (int): The total number of Cloud Security Posture Management containers during a given hour.. [optional] # noqa: E501 + host_count (int): The total number of Cloud Security Posture Management hosts during a given hour.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_response.py b/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_response.py index c488245396..fcd92f2fea 100644 --- a/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_response.py +++ b/src/datadog_api_client/v1/model/usage_cloud_security_posture_management_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCloudSecurityPostureManagementResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageCloudSecurityPostureManagementHour]): Get hourly usage for Cloud Security Posture Management.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +251,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_custom_reports_attributes.py b/src/datadog_api_client/v1/model/usage_custom_reports_attributes.py index 3300d7b250..9e373ba6de 100644 --- a/src/datadog_api_client/v1/model/usage_custom_reports_attributes.py +++ b/src/datadog_api_client/v1/model/usage_custom_reports_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageCustomReportsAttributes(ModelNormal): @@ -84,8 +86,91 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCustomReportsAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + computed_on (str): The date the specified custom report was computed.. [optional] # noqa: E501 + end_date (str): The ending date of custom report.. [optional] # noqa: E501 + size (int): size. [optional] # noqa: E501 + start_date (str): The starting date of custom report.. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to custom reports.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_custom_reports_data.py b/src/datadog_api_client/v1/model/usage_custom_reports_data.py index 929c947ae8..5fb77b2662 100644 --- a/src/datadog_api_client/v1/model/usage_custom_reports_data.py +++ b/src/datadog_api_client/v1/model/usage_custom_reports_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCustomReportsData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UsageCustomReportsAttributes): [optional] # noqa: E501 + id (str): The date for specified custom reports.. [optional] # noqa: E501 + type (UsageReportsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_custom_reports_meta.py b/src/datadog_api_client/v1/model/usage_custom_reports_meta.py index 0aec321fab..19a22164fb 100644 --- a/src/datadog_api_client/v1/model/usage_custom_reports_meta.py +++ b/src/datadog_api_client/v1/model/usage_custom_reports_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCustomReportsMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (UsageCustomReportsPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_custom_reports_page.py b/src/datadog_api_client/v1/model/usage_custom_reports_page.py index 51e7c8111b..8a27b64733 100644 --- a/src/datadog_api_client/v1/model/usage_custom_reports_page.py +++ b/src/datadog_api_client/v1/model/usage_custom_reports_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageCustomReportsPage(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "total_count": "total_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCustomReportsPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): Total page count.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_custom_reports_response.py b/src/datadog_api_client/v1/model/usage_custom_reports_response.py index 8094852002..64dc7b363c 100644 --- a/src/datadog_api_client/v1/model/usage_custom_reports_response.py +++ b/src/datadog_api_client/v1/model/usage_custom_reports_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCustomReportsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([UsageCustomReportsData]): An array of available custom reports.. [optional] # noqa: E501 + meta (UsageCustomReportsMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_cws_hour.py b/src/datadog_api_client/v1/model/usage_cws_hour.py index b43493882b..6b8fcea64f 100644 --- a/src/datadog_api_client/v1/model/usage_cws_hour.py +++ b/src/datadog_api_client/v1/model/usage_cws_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageCWSHour(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCWSHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cws_container_count (int): The total number of Cloud Workload Security container hours from the start of the given hour’s month until the given hour.. [optional] # noqa: E501 + cws_host_count (int): The total number of Cloud Workload Security host hours from the start of the given hour’s month until the given hour.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_cws_response.py b/src/datadog_api_client/v1/model/usage_cws_response.py index 316d29dbb8..c6c45bb40d 100644 --- a/src/datadog_api_client/v1/model/usage_cws_response.py +++ b/src/datadog_api_client/v1/model/usage_cws_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageCWSResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageCWSHour]): Get hourly usage for Cloud Workload Security.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_fargate_hour.py b/src/datadog_api_client/v1/model/usage_fargate_hour.py index c5280f1c10..347b79e7ba 100644 --- a/src/datadog_api_client/v1/model/usage_fargate_hour.py +++ b/src/datadog_api_client/v1/model/usage_fargate_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageFargateHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "tasks_count": "tasks_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageFargateHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + tasks_count (int): The number of Fargate tasks run.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_fargate_response.py b/src/datadog_api_client/v1/model/usage_fargate_response.py index 12542f7789..ac90cf0367 100644 --- a/src/datadog_api_client/v1/model/usage_fargate_response.py +++ b/src/datadog_api_client/v1/model/usage_fargate_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageFargateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageFargateHour]): Array with the number of hourly Fargate tasks recorded for a given organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_host_hour.py b/src/datadog_api_client/v1/model/usage_host_hour.py index 3f573c6b16..37a8630f43 100644 --- a/src/datadog_api_client/v1/model/usage_host_hour.py +++ b/src/datadog_api_client/v1/model/usage_host_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageHostHour(ModelNormal): @@ -102,8 +104,100 @@ def discriminator(): "vsphere_host_count": "vsphere_host_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageHostHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_host_count (int): Contains the total number of infrastructure hosts reporting during a given hour that were running the Datadog Agent.. [optional] # noqa: E501 + alibaba_host_count (int): Contains the total number of hosts that reported via Alibaba integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + apm_azure_app_service_host_count (int): Contains the total number of Azure App Services hosts using APM.. [optional] # noqa: E501 + apm_host_count (int): Shows the total number of hosts using APM during the hour, these are counted as billable (except during trial periods).. [optional] # noqa: E501 + aws_host_count (int): Contains the total number of hosts that reported via the AWS integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + azure_host_count (int): Contains the total number of hosts that reported via Azure integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + container_count (int): Shows the total number of containers reported by the Docker integration during the hour.. [optional] # noqa: E501 + gcp_host_count (int): Contains the total number of hosts that reported via the Google Cloud integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + heroku_host_count (int): Contains the total number of Heroku dynos reported by the Datadog Agent.. [optional] # noqa: E501 + host_count (int): Contains the total number of billable infrastructure hosts reporting during a given hour. This is the sum of `agent_host_count`, `aws_host_count`, and `gcp_host_count`.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + infra_azure_app_service (int): Contains the total number of hosts that reported via the Azure App Services integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + opentelemetry_host_count (int): Contains the total number of hosts reported by Datadog exporter for the OpenTelemetry Collector.. [optional] # noqa: E501 + vsphere_host_count (int): Contains the total number of hosts that reported via vSphere integration (and were NOT running the Datadog Agent).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -200,3 +294,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_hosts_response.py b/src/datadog_api_client/v1/model/usage_hosts_response.py index 997695fd72..475656fb5e 100644 --- a/src/datadog_api_client/v1/model/usage_hosts_response.py +++ b/src/datadog_api_client/v1/model/usage_hosts_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageHostsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageHostHour]): An array of objects related to host usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_incident_management_hour.py b/src/datadog_api_client/v1/model/usage_incident_management_hour.py index f91341e41a..01555f8ab8 100644 --- a/src/datadog_api_client/v1/model/usage_incident_management_hour.py +++ b/src/datadog_api_client/v1/model/usage_incident_management_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageIncidentManagementHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "monthly_active_users": "monthly_active_users", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIncidentManagementHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + monthly_active_users (int): Contains the total number monthly active users from the start of the given hour's month until the given hour.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_incident_management_response.py b/src/datadog_api_client/v1/model/usage_incident_management_response.py index 07ade4b5ea..edcf213b8d 100644 --- a/src/datadog_api_client/v1/model/usage_incident_management_response.py +++ b/src/datadog_api_client/v1/model/usage_incident_management_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIncidentManagementResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageIncidentManagementHour]): Get hourly usage for incident management.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_indexed_spans_hour.py b/src/datadog_api_client/v1/model/usage_indexed_spans_hour.py index d2ba17c4b0..a25fd8d18f 100644 --- a/src/datadog_api_client/v1/model/usage_indexed_spans_hour.py +++ b/src/datadog_api_client/v1/model/usage_indexed_spans_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageIndexedSpansHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "indexed_events_count": "indexed_events_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIndexedSpansHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + indexed_events_count (int): Contains the number of spans indexed.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_indexed_spans_response.py b/src/datadog_api_client/v1/model/usage_indexed_spans_response.py index a25b5f4cb3..50b0825524 100644 --- a/src/datadog_api_client/v1/model/usage_indexed_spans_response.py +++ b/src/datadog_api_client/v1/model/usage_indexed_spans_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIndexedSpansResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageIndexedSpansHour]): Array with the number of hourly traces indexed for a given organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_ingested_spans_hour.py b/src/datadog_api_client/v1/model/usage_ingested_spans_hour.py index b475b973df..cd65a99b01 100644 --- a/src/datadog_api_client/v1/model/usage_ingested_spans_hour.py +++ b/src/datadog_api_client/v1/model/usage_ingested_spans_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageIngestedSpansHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "ingested_events_bytes": "ingested_events_bytes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIngestedSpansHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + ingested_events_bytes (int): Contains the total number of bytes ingested during a given hour.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_ingested_spans_response.py b/src/datadog_api_client/v1/model/usage_ingested_spans_response.py index 865e60d462..b20bc36739 100644 --- a/src/datadog_api_client/v1/model/usage_ingested_spans_response.py +++ b/src/datadog_api_client/v1/model/usage_ingested_spans_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIngestedSpansResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageIngestedSpansHour]): Get hourly usage for ingested spans.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_io_t_hour.py b/src/datadog_api_client/v1/model/usage_io_t_hour.py index a15b8d355d..44a16a060e 100644 --- a/src/datadog_api_client/v1/model/usage_io_t_hour.py +++ b/src/datadog_api_client/v1/model/usage_io_t_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageIoTHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "iot_device_count": "iot_device_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIoTHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + iot_device_count (int): The total number of IoT devices during a given hour.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_io_t_response.py b/src/datadog_api_client/v1/model/usage_io_t_response.py index cfcf73b5c5..3b25ce807b 100644 --- a/src/datadog_api_client/v1/model/usage_io_t_response.py +++ b/src/datadog_api_client/v1/model/usage_io_t_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageIoTResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageIoTHour]): Get hourly usage for IoT.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_lambda_hour.py b/src/datadog_api_client/v1/model/usage_lambda_hour.py index f2dead2171..967300a4d7 100644 --- a/src/datadog_api_client/v1/model/usage_lambda_hour.py +++ b/src/datadog_api_client/v1/model/usage_lambda_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageLambdaHour(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "invocations_sum": "invocations_sum", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLambdaHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + func_count (int): Contains the number of different functions for each region and AWS account.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + invocations_sum (int): Contains the sum of invocations of all functions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_lambda_response.py b/src/datadog_api_client/v1/model/usage_lambda_response.py index 68fa56006d..3d7af3b309 100644 --- a/src/datadog_api_client/v1/model/usage_lambda_response.py +++ b/src/datadog_api_client/v1/model/usage_lambda_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLambdaResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageLambdaHour]): Get hourly usage for Lambda.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_by_index_hour.py b/src/datadog_api_client/v1/model/usage_logs_by_index_hour.py index e5239f1527..97c6424544 100644 --- a/src/datadog_api_client/v1/model/usage_logs_by_index_hour.py +++ b/src/datadog_api_client/v1/model/usage_logs_by_index_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageLogsByIndexHour(ModelNormal): @@ -84,8 +86,91 @@ def discriminator(): "retention": "retention", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsByIndexHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + event_count (int): The total number of indexed logs for the queried hour.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + index_id (str): The index ID for this usage.. [optional] # noqa: E501 + index_name (str): The user specified name for this index ID.. [optional] # noqa: E501 + retention (int): The retention period (in days) for this index ID.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_by_index_response.py b/src/datadog_api_client/v1/model/usage_logs_by_index_response.py index 76927ae3c0..6e46ba8f4f 100644 --- a/src/datadog_api_client/v1/model/usage_logs_by_index_response.py +++ b/src/datadog_api_client/v1/model/usage_logs_by_index_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsByIndexResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageLogsByIndexHour]): An array of objects regarding hourly usage of logs by index response.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_by_retention_hour.py b/src/datadog_api_client/v1/model/usage_logs_by_retention_hour.py index 20c9d760bf..2a2b61dd1d 100644 --- a/src/datadog_api_client/v1/model/usage_logs_by_retention_hour.py +++ b/src/datadog_api_client/v1/model/usage_logs_by_retention_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageLogsByRetentionHour(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "retention": "retention", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsByRetentionHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + indexed_events_count (int): Total logs indexed with this retention period during a given hour.. [optional] # noqa: E501 + live_indexed_events_count (int): Live logs indexed with this retention period during a given hour.. [optional] # noqa: E501 + rehydrated_indexed_events_count (int): Rehydrated logs indexed with this retention period during a given hour.. [optional] # noqa: E501 + retention (str): The retention period in days or \"custom\" for all custom retention usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_by_retention_response.py b/src/datadog_api_client/v1/model/usage_logs_by_retention_response.py index ad5711ca26..45c274eadd 100644 --- a/src/datadog_api_client/v1/model/usage_logs_by_retention_response.py +++ b/src/datadog_api_client/v1/model/usage_logs_by_retention_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsByRetentionResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageLogsByRetentionHour]): Get hourly usage for indexed logs by retention period.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_hour.py b/src/datadog_api_client/v1/model/usage_logs_hour.py index 65476de7ec..d0e3d84310 100644 --- a/src/datadog_api_client/v1/model/usage_logs_hour.py +++ b/src/datadog_api_client/v1/model/usage_logs_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageLogsHour(ModelNormal): @@ -90,8 +92,94 @@ def discriminator(): "logs_rehydrated_ingested_bytes": "logs_rehydrated_ingested_bytes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + billable_ingested_bytes (int): Contains the number of billable log bytes ingested.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + indexed_events_count (int): Contains the number of log events indexed.. [optional] # noqa: E501 + ingested_events_bytes (int): Contains the number of log bytes ingested.. [optional] # noqa: E501 + logs_live_indexed_count (int): Contains the number of live log events indexed (data available as of December 1, 2020).. [optional] # noqa: E501 + logs_live_ingested_bytes (int): Contains the number of live log bytes ingested (data available as of December 1, 2020).. [optional] # noqa: E501 + logs_rehydrated_indexed_count (int): Contains the number of rehydrated log events indexed (data available as of December 1, 2020).. [optional] # noqa: E501 + logs_rehydrated_ingested_bytes (int): Contains the number of rehydrated log bytes ingested (data available as of December 1, 2020).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +270,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_logs_response.py b/src/datadog_api_client/v1/model/usage_logs_response.py index 5b0976ee3c..07be52fdc6 100644 --- a/src/datadog_api_client/v1/model/usage_logs_response.py +++ b/src/datadog_api_client/v1/model/usage_logs_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageLogsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageLogsHour]): An array of objects regarding hourly usage of logs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_metric_category.py b/src/datadog_api_client/v1/model/usage_metric_category.py index f542662195..a3e48af642 100644 --- a/src/datadog_api_client/v1/model/usage_metric_category.py +++ b/src/datadog_api_client/v1/model/usage_metric_category.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageMetricCategory(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageMetricCategory - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Contains the metric category.., must be one of ["standard", "custom", ] # noqa: E501 + + Keyword Args: + value (str): Contains the metric category.., must be one of ["standard", "custom", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_network_flows_hour.py b/src/datadog_api_client/v1/model/usage_network_flows_hour.py index 47eab2ef67..a7fbd14fe4 100644 --- a/src/datadog_api_client/v1/model/usage_network_flows_hour.py +++ b/src/datadog_api_client/v1/model/usage_network_flows_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageNetworkFlowsHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "indexed_event_count": "indexed_event_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageNetworkFlowsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + indexed_event_count (int): Contains the number of netflow events indexed.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_network_flows_response.py b/src/datadog_api_client/v1/model/usage_network_flows_response.py index 311300d363..3fa49134d9 100644 --- a/src/datadog_api_client/v1/model/usage_network_flows_response.py +++ b/src/datadog_api_client/v1/model/usage_network_flows_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageNetworkFlowsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageNetworkFlowsHour]): Get hourly usage for Network Flows.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_network_hosts_hour.py b/src/datadog_api_client/v1/model/usage_network_hosts_hour.py index a9b5d5d18c..00cc0f949d 100644 --- a/src/datadog_api_client/v1/model/usage_network_hosts_hour.py +++ b/src/datadog_api_client/v1/model/usage_network_hosts_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageNetworkHostsHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageNetworkHostsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + host_count (int): Contains the number of active NPM hosts.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_network_hosts_response.py b/src/datadog_api_client/v1/model/usage_network_hosts_response.py index 174ad9f92b..e202cbbe2d 100644 --- a/src/datadog_api_client/v1/model/usage_network_hosts_response.py +++ b/src/datadog_api_client/v1/model/usage_network_hosts_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageNetworkHostsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageNetworkHostsHour]): Get hourly usage for NPM hosts.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_profiling_hour.py b/src/datadog_api_client/v1/model/usage_profiling_hour.py index b48e208ed1..cdb854f690 100644 --- a/src/datadog_api_client/v1/model/usage_profiling_hour.py +++ b/src/datadog_api_client/v1/model/usage_profiling_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageProfilingHour(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageProfilingHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + avg_container_agent_count (int): Get average number of container agents for that hour.. [optional] # noqa: E501 + host_count (int): Contains the total number of profiled hosts reporting during a given hour.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_profiling_response.py b/src/datadog_api_client/v1/model/usage_profiling_response.py index 90abbfb280..3c07900ffb 100644 --- a/src/datadog_api_client/v1/model/usage_profiling_response.py +++ b/src/datadog_api_client/v1/model/usage_profiling_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageProfilingResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageProfilingHour]): Get hourly usage for profiled hosts.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_reports_type.py b/src/datadog_api_client/v1/model/usage_reports_type.py index d09714518c..b69d6d9464 100644 --- a/src/datadog_api_client/v1/model/usage_reports_type.py +++ b/src/datadog_api_client/v1/model/usage_reports_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageReportsType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageReportsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of reports.. if omitted defaults to "reports", must be one of ["reports", ] # noqa: E501 + + Keyword Args: + value (str): The type of reports.. if omitted defaults to "reports", must be one of ["reports", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "reports" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_rum_sessions_hour.py b/src/datadog_api_client/v1/model/usage_rum_sessions_hour.py index 7c1f609bde..5af688124d 100644 --- a/src/datadog_api_client/v1/model/usage_rum_sessions_hour.py +++ b/src/datadog_api_client/v1/model/usage_rum_sessions_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageRumSessionsHour(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "session_count_ios": "session_count_ios", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageRumSessionsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + session_count (int): Contains the number of RUM Sessions.. [optional] # noqa: E501 + session_count_android (int): Contains the number of mobile RUM Sessions on Android (data available beginning December 1, 2020).. [optional] # noqa: E501 + session_count_ios (int): Contains the number of mobile RUM Sessions on iOS (data available beginning December 1, 2020).. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_rum_sessions_response.py b/src/datadog_api_client/v1/model/usage_rum_sessions_response.py index 36f7e28fb2..a9137f3d7e 100644 --- a/src/datadog_api_client/v1/model/usage_rum_sessions_response.py +++ b/src/datadog_api_client/v1/model/usage_rum_sessions_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageRumSessionsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageRumSessionsHour]): Get hourly usage for RUM Sessions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_snmp_hour.py b/src/datadog_api_client/v1/model/usage_snmp_hour.py index 5559ca043d..b225970c3a 100644 --- a/src/datadog_api_client/v1/model/usage_snmp_hour.py +++ b/src/datadog_api_client/v1/model/usage_snmp_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSNMPHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "snmp_devices": "snmp_devices", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSNMPHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + snmp_devices (int): Contains the number of SNMP devices.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_snmp_response.py b/src/datadog_api_client/v1/model/usage_snmp_response.py index 5f24e43803..e3d6c7ee6c 100644 --- a/src/datadog_api_client/v1/model/usage_snmp_response.py +++ b/src/datadog_api_client/v1/model/usage_snmp_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSNMPResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageSNMPHour]): Get hourly usage for SNMP devices.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_sort.py b/src/datadog_api_client/v1/model/usage_sort.py index d1ac819772..ddb69b9f24 100644 --- a/src/datadog_api_client/v1/model/usage_sort.py +++ b/src/datadog_api_client/v1/model/usage_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSort(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -176,3 +180,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The field to sort by.. if omitted defaults to "start_date", must be one of ["computed_on", "size", "start_date", "end_date", ] # noqa: E501 + + Keyword Args: + value (str): The field to sort by.. if omitted defaults to "start_date", must be one of ["computed_on", "size", "start_date", "end_date", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "start_date" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_sort_direction.py b/src/datadog_api_client/v1/model/usage_sort_direction.py index 5a91cd0666..80ba0a5077 100644 --- a/src/datadog_api_client/v1/model/usage_sort_direction.py +++ b/src/datadog_api_client/v1/model/usage_sort_direction.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSortDirection(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsageSortDirection - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The direction to sort by.. if omitted defaults to "desc", must be one of ["desc", "asc", ] # noqa: E501 + + Keyword Args: + value (str): The direction to sort by.. if omitted defaults to "desc", must be one of ["desc", "asc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "desc" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/usage_specified_custom_reports_attributes.py b/src/datadog_api_client/v1/model/usage_specified_custom_reports_attributes.py index 884f303acb..6e05f0c1c0 100644 --- a/src/datadog_api_client/v1/model/usage_specified_custom_reports_attributes.py +++ b/src/datadog_api_client/v1/model/usage_specified_custom_reports_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSpecifiedCustomReportsAttributes(ModelNormal): @@ -86,8 +88,92 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSpecifiedCustomReportsAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + computed_on (str): The date the specified custom report was computed.. [optional] # noqa: E501 + end_date (str): The ending date of specified custom report.. [optional] # noqa: E501 + location (str): A downloadable file for the specified custom reporting file.. [optional] # noqa: E501 + size (int): size. [optional] # noqa: E501 + start_date (str): The starting date of specified custom report.. [optional] # noqa: E501 + tags ([str]): A list of tags to apply to specified custom reports.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +262,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_specified_custom_reports_data.py b/src/datadog_api_client/v1/model/usage_specified_custom_reports_data.py index 8a0ad32b5d..476f0ace1d 100644 --- a/src/datadog_api_client/v1/model/usage_specified_custom_reports_data.py +++ b/src/datadog_api_client/v1/model/usage_specified_custom_reports_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSpecifiedCustomReportsData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UsageSpecifiedCustomReportsAttributes): [optional] # noqa: E501 + id (str): The date for specified custom reports.. [optional] # noqa: E501 + type (UsageReportsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_specified_custom_reports_meta.py b/src/datadog_api_client/v1/model/usage_specified_custom_reports_meta.py index afa92f9089..896c3225f6 100644 --- a/src/datadog_api_client/v1/model/usage_specified_custom_reports_meta.py +++ b/src/datadog_api_client/v1/model/usage_specified_custom_reports_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSpecifiedCustomReportsMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (UsageSpecifiedCustomReportsPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_specified_custom_reports_page.py b/src/datadog_api_client/v1/model/usage_specified_custom_reports_page.py index 3eac743428..ca35f83246 100644 --- a/src/datadog_api_client/v1/model/usage_specified_custom_reports_page.py +++ b/src/datadog_api_client/v1/model/usage_specified_custom_reports_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSpecifiedCustomReportsPage(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "total_count": "total_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSpecifiedCustomReportsPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): Total page count.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_specified_custom_reports_response.py b/src/datadog_api_client/v1/model/usage_specified_custom_reports_response.py index 3697de53e6..9ff319085c 100644 --- a/src/datadog_api_client/v1/model/usage_specified_custom_reports_response.py +++ b/src/datadog_api_client/v1/model/usage_specified_custom_reports_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSpecifiedCustomReportsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (UsageSpecifiedCustomReportsData): [optional] # noqa: E501 + meta (UsageSpecifiedCustomReportsMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_summary_date.py b/src/datadog_api_client/v1/model/usage_summary_date.py index 480d410e32..2cea468fd2 100644 --- a/src/datadog_api_client/v1/model/usage_summary_date.py +++ b/src/datadog_api_client/v1/model/usage_summary_date.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -167,8 +169,129 @@ def discriminator(): "vsphere_host_top99p": "vsphere_host_top99p", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSummaryDate - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_host_top99p (int): Shows the 99th percentile of all agent hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + apm_azure_app_service_host_top99p (int): Shows the 99th percentile of all Azure app services using APM over all hours in the current date all organizations.. [optional] # noqa: E501 + apm_host_top99p (int): Shows the 99th percentile of all distinct APM hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + audit_logs_lines_indexed_sum (int): Shows the sum of audit logs lines indexed over all hours in the current date for all organizations.. [optional] # noqa: E501 + aws_host_top99p (int): Shows the 99th percentile of all AWS hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + aws_lambda_func_count (int): Shows the average of the number of functions that executed 1 or more times each hour in the current date for all organizations.. [optional] # noqa: E501 + aws_lambda_invocations_sum (int): Shows the sum of all AWS Lambda invocations over all hours in the current date for all organizations.. [optional] # noqa: E501 + azure_app_service_top99p (int): Shows the 99th percentile of all Azure app services over all hours in the current date for all organizations.. [optional] # noqa: E501 + billable_ingested_bytes_sum (int): Shows the sum of all log bytes ingested over all hours in the current date for all organizations.. [optional] # noqa: E501 + container_avg (int): Shows the average of all distinct containers over all hours in the current date for all organizations.. [optional] # noqa: E501 + container_hwm (int): Shows the high-water mark of all distinct containers over all hours in the current date for all organizations.. [optional] # noqa: E501 + cspm_container_avg (int): Shows the average number of Cloud Security Posture Management containers over all hours in the current date for all organizations.. [optional] # noqa: E501 + cspm_container_hwm (int): Shows the high-water mark of Cloud Security Posture Management containers over all hours in the current date for all organizations.. [optional] # noqa: E501 + cspm_host_top99p (int): Shows the 99th percentile of all Cloud Security Posture Management hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + custom_ts_avg (int): Shows the average number of distinct custom metrics over all hours in the current date for all organizations.. [optional] # noqa: E501 + cws_container_count_avg (int): Shows the average of all distinct Cloud Workload Security containers over all hours in the current date for all organizations.. [optional] # noqa: E501 + cws_host_top99p (int): Shows the 99th percentile of all Cloud Workload Security hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + date (datetime): The date for the usage.. [optional] # noqa: E501 + fargate_tasks_count_avg (int): Shows the high-watermark of all Fargate tasks over all hours in the current date for all organizations.. [optional] # noqa: E501 + fargate_tasks_count_hwm (int): Shows the average of all Fargate tasks over all hours in the current date for all organizations.. [optional] # noqa: E501 + gcp_host_top99p (int): Shows the 99th percentile of all GCP hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + heroku_host_top99p (int): Shows the 99th percentile of all Heroku dynos over all hours in the current date for all organizations.. [optional] # noqa: E501 + incident_management_monthly_active_users_hwm (int): Shows the high-water mark of incident management monthly active users over all hours in the current date for all organizations.. [optional] # noqa: E501 + indexed_events_count_sum (int): Shows the sum of all log events indexed over all hours in the current date for all organizations.. [optional] # noqa: E501 + infra_host_top99p (int): Shows the 99th percentile of all distinct infrastructure hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + ingested_events_bytes_sum (int): Shows the sum of all log bytes ingested over all hours in the current date for all organizations.. [optional] # noqa: E501 + iot_device_sum (int): Shows the sum of all IoT devices over all hours in the current date for all organizations.. [optional] # noqa: E501 + iot_device_top99p (int): Shows the 99th percentile of all IoT devices over all hours in the current date all organizations.. [optional] # noqa: E501 + mobile_rum_session_count_android_sum (int): Shows the sum of all mobile RUM Sessions on Android over all hours in the current date for all organizations.. [optional] # noqa: E501 + mobile_rum_session_count_ios_sum (int): Shows the sum of all mobile RUM Sessions on iOS over all hours in the current date for all organizations.. [optional] # noqa: E501 + mobile_rum_session_count_sum (int): Shows the sum of all mobile RUM Sessions over all hours in the current date for all organizations. [optional] # noqa: E501 + netflow_indexed_events_count_sum (int): Shows the sum of all Network flows indexed over all hours in the current date for all organizations.. [optional] # noqa: E501 + npm_host_top99p (int): Shows the 99th percentile of all distinct Networks hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + opentelemetry_host_top99p (int): Shows the 99th percentile of all hosts reported by the Datadog exporter for the OpenTelemetry Collector over all hours in the current date for all organizations.. [optional] # noqa: E501 + orgs ([UsageSummaryDateOrg]): Organizations associated with a user.. [optional] # noqa: E501 + profiling_host_top99p (int): Shows the 99th percentile of all profiled hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + rum_session_count_sum (int): Shows the sum of all browser RUM Sessions over all hours in the current date for all organizations. [optional] # noqa: E501 + rum_total_session_count_sum (int): Shows the sum of RUM Sessions (browser and mobile) over all hours in the current date for all organizations.. [optional] # noqa: E501 + synthetics_browser_check_calls_count_sum (int): Shows the sum of all Synthetic browser tests over all hours in the current date for all organizations.. [optional] # noqa: E501 + synthetics_check_calls_count_sum (int): Shows the sum of all Synthetic API tests over all hours in the current date for all organizations.. [optional] # noqa: E501 + trace_search_indexed_events_count_sum (int): Shows the sum of all Indexed Spans indexed over all hours in the current date for all organizations.. [optional] # noqa: E501 + twol_ingested_events_bytes_sum (int): Shows the sum of all tracing without limits bytes ingested over all hours in the current date for all organizations.. [optional] # noqa: E501 + vsphere_host_top99p (int): Shows the 99th percentile of all vSphere hosts over all hours in the current date for all organizations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -294,3 +417,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_summary_date_org.py b/src/datadog_api_client/v1/model/usage_summary_date_org.py index 2f51715ef9..12cf31b53f 100644 --- a/src/datadog_api_client/v1/model/usage_summary_date_org.py +++ b/src/datadog_api_client/v1/model/usage_summary_date_org.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSummaryDateOrg(ModelNormal): @@ -162,8 +164,130 @@ def discriminator(): "vsphere_host_top99p": "vsphere_host_top99p", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSummaryDateOrg - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_host_top99p (int): Shows the 99th percentile of all agent hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + apm_azure_app_service_host_top99p (int): Shows the 99th percentile of all Azure app services using APM over all hours in the current date for the given org.. [optional] # noqa: E501 + apm_host_top99p (int): Shows the 99th percentile of all distinct APM hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + audit_logs_lines_indexed_sum (int): Shows the sum of all audit logs lines indexed over all hours in the current date for the given org.. [optional] # noqa: E501 + aws_host_top99p (int): Shows the 99th percentile of all AWS hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + aws_lambda_func_count (int): Shows the sum of all AWS Lambda invocations over all hours in the current date for the given org.. [optional] # noqa: E501 + aws_lambda_invocations_sum (int): Shows the sum of all AWS Lambda invocations over all hours in the current date for the given org.. [optional] # noqa: E501 + azure_app_service_top99p (int): Shows the 99th percentile of all Azure app services over all hours in the current date for the given org.. [optional] # noqa: E501 + billable_ingested_bytes_sum (int): Shows the sum of all log bytes ingested over all hours in the current date for the given org.. [optional] # noqa: E501 + container_avg (int): Shows the average of all distinct containers over all hours in the current date for the given org.. [optional] # noqa: E501 + container_hwm (int): Shows the high-water mark of all distinct containers over all hours in the current date for the given org.. [optional] # noqa: E501 + cspm_container_avg (int): Shows the average number of Cloud Security Posture Management containers over all hours in the current date for the given org.. [optional] # noqa: E501 + cspm_container_hwm (int): Shows the high-water mark of Cloud Security Posture Management containers over all hours in the current date for the given org.. [optional] # noqa: E501 + cspm_host_top99p (int): Shows the 99th percentile of all Cloud Security Posture Management hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + custom_ts_avg (int): Shows the average number of distinct custom metrics over all hours in the current date for the given org.. [optional] # noqa: E501 + cws_container_count_avg (int): Shows the average of all distinct Cloud Workload Security containers over all hours in the current date for the given org.. [optional] # noqa: E501 + cws_host_top99p (int): Shows the 99th percentile of all Cloud Workload Security hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + fargate_tasks_count_avg (int): The average task count for Fargate.. [optional] # noqa: E501 + fargate_tasks_count_hwm (int): Shows the high-water mark of all Fargate tasks over all hours in the current date for the given org.. [optional] # noqa: E501 + gcp_host_top99p (int): Shows the 99th percentile of all GCP hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + heroku_host_top99p (int): Shows the 99th percentile of all Heroku dynos over all hours in the current date for the given org.. [optional] # noqa: E501 + id (str): The organization id.. [optional] # noqa: E501 + incident_management_monthly_active_users_hwm (int): Shows the high-water mark of incident management monthly active users over all hours in the current date for the given org.. [optional] # noqa: E501 + indexed_events_count_sum (int): Shows the sum of all log events indexed over all hours in the current date for the given org.. [optional] # noqa: E501 + infra_host_top99p (int): Shows the 99th percentile of all distinct infrastructure hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + ingested_events_bytes_sum (int): Shows the sum of all log bytes ingested over all hours in the current date for the given org.. [optional] # noqa: E501 + iot_device_agg_sum (int): Shows the sum of all IoT devices over all hours in the current date for the given org.. [optional] # noqa: E501 + iot_device_top99p_sum (int): Shows the 99th percentile of all IoT devices over all hours in the current date for the given org.. [optional] # noqa: E501 + mobile_rum_session_count_android_sum (int): Shows the sum of all mobile RUM Sessions on Android over all hours in the current date for the given org.. [optional] # noqa: E501 + mobile_rum_session_count_ios_sum (int): Shows the sum of all mobile RUM Sessions on iOS over all hours in the current date for the given org.. [optional] # noqa: E501 + mobile_rum_session_count_sum (int): Shows the sum of all mobile RUM Sessions over all hours in the current date for the given org.. [optional] # noqa: E501 + name (str): The organization name.. [optional] # noqa: E501 + netflow_indexed_events_count_sum (int): Shows the sum of all Network flows indexed over all hours in the current date for the given org.. [optional] # noqa: E501 + npm_host_top99p (int): Shows the 99th percentile of all distinct Networks hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + opentelemetry_host_top99p (int): Shows the 99th percentile of all hosts reported by the Datadog exporter for the OpenTelemetry Collector over all hours in the current date for the given org.. [optional] # noqa: E501 + profiling_host_top99p (int): Shows the 99th percentile of all profiled hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + public_id (str): The organization public id.. [optional] # noqa: E501 + rum_session_count_sum (int): Shows the sum of all browser RUM Sessions over all hours in the current date for the given org.. [optional] # noqa: E501 + rum_total_session_count_sum (int): Shows the sum of RUM Sessions (browser and mobile) over all hours in the current date for the given org.. [optional] # noqa: E501 + synthetics_browser_check_calls_count_sum (int): Shows the sum of all Synthetic browser tests over all hours in the current date for the given org.. [optional] # noqa: E501 + synthetics_check_calls_count_sum (int): Shows the sum of all Synthetic API tests over all hours in the current date for the given org.. [optional] # noqa: E501 + trace_search_indexed_events_count_sum (int): Shows the sum of all Indexed Spans indexed over all hours in the current date for the given org.. [optional] # noqa: E501 + twol_ingested_events_bytes_sum (int): Shows the sum of all tracing without limits bytes ingested over all hours in the current date for the given org.. [optional] # noqa: E501 + vsphere_host_top99p (int): Shows the 99th percentile of all vSphere hosts over all hours in the current date for the given org.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -290,3 +414,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_summary_response.py b/src/datadog_api_client/v1/model/usage_summary_response.py index 720c3ab3dc..f2e8704c81 100644 --- a/src/datadog_api_client/v1/model/usage_summary_response.py +++ b/src/datadog_api_client/v1/model/usage_summary_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -187,8 +189,138 @@ def discriminator(): "vsphere_host_top99p_sum": "vsphere_host_top99p_sum", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSummaryResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_host_top99p_sum (int): Shows the 99th percentile of all agent hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + apm_azure_app_service_host_top99p_sum (int): Shows the 99th percentile of all Azure app services using APM over all hours in the current months all organizations.. [optional] # noqa: E501 + apm_host_top99p_sum (int): Shows the 99th percentile of all distinct APM hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + audit_logs_lines_indexed_agg_sum (int): Shows the sum of all audit logs lines indexed over all hours in the current months for all organizations.. [optional] # noqa: E501 + aws_host_top99p_sum (int): Shows the 99th percentile of all AWS hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + aws_lambda_func_count (int): Shows the average of the number of functions that executed 1 or more times each hour in the current months for all organizations.. [optional] # noqa: E501 + aws_lambda_invocations_sum (int): Shows the sum of all AWS Lambda invocations over all hours in the current months for all organizations.. [optional] # noqa: E501 + azure_app_service_top99p_sum (int): Shows the 99th percentile of all Azure app services over all hours in the current months for all organizations.. [optional] # noqa: E501 + azure_host_top99p_sum (int): Shows the 99th percentile of all Azure hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + billable_ingested_bytes_agg_sum (int): Shows the sum of all log bytes ingested over all hours in the current months for all organizations.. [optional] # noqa: E501 + container_avg_sum (int): Shows the average of all distinct containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + container_hwm_sum (int): Shows the sum of the high-water marks of all distinct containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + cspm_container_avg_sum (int): Shows the average number of Cloud Security Posture Management containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + cspm_container_hwm_sum (int): Shows the sum of the the high-water marks of Cloud Security Posture Management containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + cspm_host_top99p_sum (int): Shows the 99th percentile of all Cloud Security Posture Management hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + custom_ts_sum (int): Shows the average number of distinct custom metrics over all hours in the current months for all organizations.. [optional] # noqa: E501 + cws_containers_avg_sum (int): Shows the average of all distinct Cloud Workload Security containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + cws_host_top99p_sum (int): Shows the 99th percentile of all Cloud Workload Security hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + end_date (datetime): Shows the last date of usage in the current months for all organizations.. [optional] # noqa: E501 + fargate_tasks_count_avg_sum (int): Shows the average of all Fargate tasks over all hours in the current months for all organizations.. [optional] # noqa: E501 + fargate_tasks_count_hwm_sum (int): Shows the sum of the high-water marks of all Fargate tasks over all hours in the current months for all organizations.. [optional] # noqa: E501 + gcp_host_top99p_sum (int): Shows the 99th percentile of all GCP hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + heroku_host_top99p_sum (int): Shows the 99th percentile of all Heroku dynos over all hours in the current months for all organizations.. [optional] # noqa: E501 + incident_management_monthly_active_users_hwm_sum (int): Shows sum of the the high-water marks of incident management monthly active users in the current months for all organizations.. [optional] # noqa: E501 + indexed_events_count_agg_sum (int): Shows the sum of all log events indexed over all hours in the current months for all organizations.. [optional] # noqa: E501 + infra_host_top99p_sum (int): Shows the 99th percentile of all distinct infrastructure hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + ingested_events_bytes_agg_sum (int): Shows the sum of all log bytes ingested over all hours in the current months for all organizations.. [optional] # noqa: E501 + iot_device_agg_sum (int): Shows the sum of all IoT devices over all hours in the current months for all organizations.. [optional] # noqa: E501 + iot_device_top99p_sum (int): Shows the 99th percentile of all IoT devices over all hours in the current months of all organizations.. [optional] # noqa: E501 + last_updated (datetime): Shows the the most recent hour in the current months for all organizations for which all usages were calculated.. [optional] # noqa: E501 + live_indexed_events_agg_sum (int): Shows the sum of all live logs indexed over all hours in the current months for all organizations (data available as of December 1, 2020).. [optional] # noqa: E501 + live_ingested_bytes_agg_sum (int): Shows the sum of all live logs bytes ingested over all hours in the current months for all organizations (data available as of December 1, 2020).. [optional] # noqa: E501 + logs_by_retention (LogsByRetention): [optional] # noqa: E501 + mobile_rum_session_count_agg_sum (int): Shows the sum of all mobile RUM Sessions over all hours in the current months for all organizations.. [optional] # noqa: E501 + mobile_rum_session_count_android_agg_sum (int): Shows the sum of all mobile RUM Sessions on Android over all hours in the current months for all organizations.. [optional] # noqa: E501 + mobile_rum_session_count_ios_agg_sum (int): Shows the sum of all mobile RUM Sessions on iOS over all hours in the current months for all organizations.. [optional] # noqa: E501 + netflow_indexed_events_count_agg_sum (int): Shows the sum of all Network flows indexed over all hours in the current months for all organizations.. [optional] # noqa: E501 + npm_host_top99p_sum (int): Shows the 99th percentile of all distinct Networks hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + opentelemetry_host_top99p_sum (int): Shows the 99th percentile of all hosts reported by the Datadog exporter for the OpenTelemetry Collector over all hours in the current months for all organizations.. [optional] # noqa: E501 + profiling_container_agent_count_avg (int): Shows the average number of profiled containers over all hours in the current months for all organizations.. [optional] # noqa: E501 + profiling_host_count_top99p_sum (int): Shows the 99th percentile of all profiled hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + rehydrated_indexed_events_agg_sum (int): Shows the sum of all rehydrated logs indexed over all hours in the current months for all organizations (data available as of December 1, 2020).. [optional] # noqa: E501 + rehydrated_ingested_bytes_agg_sum (int): Shows the sum of all rehydrated logs bytes ingested over all hours in the current months for all organizations (data available as of December 1, 2020).. [optional] # noqa: E501 + rum_session_count_agg_sum (int): Shows the sum of all browser RUM Sessions over all hours in the current months for all organizations.. [optional] # noqa: E501 + rum_total_session_count_agg_sum (int): Shows the sum of RUM Sessions (browser and mobile) over all hours in the current months for all organizations.. [optional] # noqa: E501 + start_date (datetime): Shows the first date of usage in the current months for all organizations.. [optional] # noqa: E501 + synthetics_browser_check_calls_count_agg_sum (int): Shows the sum of all Synthetic browser tests over all hours in the current months for all organizations.. [optional] # noqa: E501 + synthetics_check_calls_count_agg_sum (int): Shows the sum of all Synthetic API tests over all hours in the current months for all organizations.. [optional] # noqa: E501 + trace_search_indexed_events_count_agg_sum (int): Shows the sum of all Indexed Spans indexed over all hours in the current months for all organizations.. [optional] # noqa: E501 + twol_ingested_events_bytes_agg_sum (int): Shows the sum of all tracing without limits bytes ingested over all hours in the current months for all organizations.. [optional] # noqa: E501 + usage ([UsageSummaryDate]): An array of objects regarding hourly usage.. [optional] # noqa: E501 + vsphere_host_top99p_sum (int): Shows the 99th percentile of all vSphere hosts over all hours in the current months for all organizations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -323,3 +455,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_api_hour.py b/src/datadog_api_client/v1/model/usage_synthetics_api_hour.py index 66676158b4..f593b616b7 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_api_hour.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_api_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSyntheticsAPIHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsAPIHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check_calls_count (int): Contains the number of Synthetics API tests run.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_api_response.py b/src/datadog_api_client/v1/model/usage_synthetics_api_response.py index 79a313c81b..d6ed6314d7 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_api_response.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_api_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsAPIResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageSyntheticsAPIHour]): Get hourly usage for Synthetics API tests.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_browser_hour.py b/src/datadog_api_client/v1/model/usage_synthetics_browser_hour.py index 6cdfd3dadc..d1195230ab 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_browser_hour.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_browser_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSyntheticsBrowserHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsBrowserHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + browser_check_calls_count (int): Contains the number of Synthetics Browser tests run.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_browser_response.py b/src/datadog_api_client/v1/model/usage_synthetics_browser_response.py index 5c6282f2da..5b9d8a5c30 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_browser_response.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_browser_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsBrowserResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageSyntheticsBrowserHour]): Get hourly usage for Synthetics Browser tests.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_hour.py b/src/datadog_api_client/v1/model/usage_synthetics_hour.py index 4d6173b578..46f5c6595b 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_hour.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageSyntheticsHour(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "hour": "hour", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + check_calls_count (int): Contains the number of Synthetics API tests run.. [optional] # noqa: E501 + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_synthetics_response.py b/src/datadog_api_client/v1/model/usage_synthetics_response.py index 285ded605f..93a4ff8f54 100644 --- a/src/datadog_api_client/v1/model/usage_synthetics_response.py +++ b/src/datadog_api_client/v1/model/usage_synthetics_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageSyntheticsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageSyntheticsHour]): Array with the number of hourly Synthetics test run for a given organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_timeseries_hour.py b/src/datadog_api_client/v1/model/usage_timeseries_hour.py index 91c680eabf..6e6bf0f6ba 100644 --- a/src/datadog_api_client/v1/model/usage_timeseries_hour.py +++ b/src/datadog_api_client/v1/model/usage_timeseries_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UsageTimeseriesHour(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "num_custom_timeseries": "num_custom_timeseries", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageTimeseriesHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + hour (datetime): The hour for the usage.. [optional] # noqa: E501 + num_custom_input_timeseries (int): Contains the number of custom metrics that are inputs for aggregations (metric configured is custom).. [optional] # noqa: E501 + num_custom_output_timeseries (int): Contains the number of custom metrics that are outputs for aggregations (metric configured is custom).. [optional] # noqa: E501 + num_custom_timeseries (int): Contains the number of non-aggregation custom metrics.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_timeseries_response.py b/src/datadog_api_client/v1/model/usage_timeseries_response.py index cb42ce640b..9cc9b36098 100644 --- a/src/datadog_api_client/v1/model/usage_timeseries_response.py +++ b/src/datadog_api_client/v1/model/usage_timeseries_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageTimeseriesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + usage ([UsageTimeseriesHour]): An array of objects regarding hourly usage of timeseries.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_top_avg_metrics_hour.py b/src/datadog_api_client/v1/model/usage_top_avg_metrics_hour.py index c325bc4587..3ce55f2ca9 100644 --- a/src/datadog_api_client/v1/model/usage_top_avg_metrics_hour.py +++ b/src/datadog_api_client/v1/model/usage_top_avg_metrics_hour.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,90 @@ def discriminator(): "metric_name": "metric_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageTopAvgMetricsHour - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + avg_metric_hour (int): Average number of timeseries per hour in which the metric occurs.. [optional] # noqa: E501 + max_metric_hour (int): Maximum number of timeseries per hour in which the metric occurs.. [optional] # noqa: E501 + metric_category (UsageMetricCategory): [optional] # noqa: E501 + metric_name (str): Contains the custom metric name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_top_avg_metrics_metadata.py b/src/datadog_api_client/v1/model/usage_top_avg_metrics_metadata.py index e99a739b55..8cb4c4c3ed 100644 --- a/src/datadog_api_client/v1/model/usage_top_avg_metrics_metadata.py +++ b/src/datadog_api_client/v1/model/usage_top_avg_metrics_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,89 @@ def discriminator(): "pagination": "pagination", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageTopAvgMetricsMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + day (datetime): The day value from the user request that contains the returned usage data. (If day was used the request). [optional] # noqa: E501 + month (datetime): The month value from the user request that contains the returned usage data. (If month was used the request). [optional] # noqa: E501 + pagination (UsageAttributionPagination): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +257,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/usage_top_avg_metrics_response.py b/src/datadog_api_client/v1/model/usage_top_avg_metrics_response.py index 33c89070a3..3de5b5357d 100644 --- a/src/datadog_api_client/v1/model/usage_top_avg_metrics_response.py +++ b/src/datadog_api_client/v1/model/usage_top_avg_metrics_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "usage": "usage", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsageTopAvgMetricsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + metadata (UsageTopAvgMetricsMetadata): [optional] # noqa: E501 + usage ([UsageTopAvgMetricsHour]): Number of hourly recorded custom metrics for a given organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/user.py b/src/datadog_api_client/v1/model/user.py index da5922cb90..cb1134e230 100644 --- a/src/datadog_api_client/v1/model/user.py +++ b/src/datadog_api_client/v1/model/user.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,96 @@ def discriminator(): "verified": "verified", # noqa: E501 } + read_only_vars = { + "icon", # noqa: E501 + "verified", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """User - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + access_role (AccessRole): [optional] # noqa: E501 + disabled (bool): The new disabled status of the user.. [optional] # noqa: E501 + email (str): The new email of the user.. [optional] # noqa: E501 + handle (str): The user handle, must be a valid email.. [optional] # noqa: E501 + icon (str): Gravatar icon associated to the user.. [optional] # noqa: E501 + name (str): The name of the user.. [optional] # noqa: E501 + verified (bool): Whether or not the user logged in Datadog at least once.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +276,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/user_disable_response.py b/src/datadog_api_client/v1/model/user_disable_response.py index 0bdafef6d9..46f493c787 100644 --- a/src/datadog_api_client/v1/model/user_disable_response.py +++ b/src/datadog_api_client/v1/model/user_disable_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class UserDisableResponse(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "message": "message", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserDisableResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + message (str): Information pertaining to a user disabled for a given organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/user_list_response.py b/src/datadog_api_client/v1/model/user_list_response.py index cd39220a75..cefe696998 100644 --- a/src/datadog_api_client/v1/model/user_list_response.py +++ b/src/datadog_api_client/v1/model/user_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "users": "users", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + users ([User]): Array of users.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/user_response.py b/src/datadog_api_client/v1/model/user_response.py index 4707f48e91..8cb7fe7b17 100644 --- a/src/datadog_api_client/v1/model/user_response.py +++ b/src/datadog_api_client/v1/model/user_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "user": "user", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + user (User): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget.py b/src/datadog_api_client/v1/model/widget.py index 07802feff5..25b187e837 100644 --- a/src/datadog_api_client/v1/model/widget.py +++ b/src/datadog_api_client/v1/model/widget.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,92 @@ def discriminator(): "layout": "layout", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, definition, *args, **kwargs): # noqa: E501 + """Widget - a model defined in OpenAPI + + Args: + definition (WidgetDefinition): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (int): ID of the widget.. [optional] # noqa: E501 + layout (WidgetLayout): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.definition = definition + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +265,8 @@ def __init__(self, definition, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_aggregator.py b/src/datadog_api_client/v1/model/widget_aggregator.py index e799ceaca3..b729a6604a 100644 --- a/src/datadog_api_client/v1/model/widget_aggregator.py +++ b/src/datadog_api_client/v1/model/widget_aggregator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetAggregator(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetAggregator - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Aggregator used for the request.., must be one of ["avg", "last", "max", "min", "sum", ] # noqa: E501 + + Keyword Args: + value (str): Aggregator used for the request.., must be one of ["avg", "last", "max", "min", "sum", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_axis.py b/src/datadog_api_client/v1/model/widget_axis.py index fa30de5274..3e1d78684f 100644 --- a/src/datadog_api_client/v1/model/widget_axis.py +++ b/src/datadog_api_client/v1/model/widget_axis.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetAxis(ModelNormal): @@ -84,8 +86,91 @@ def discriminator(): "scale": "scale", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetAxis - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_zero (bool): True includes zero.. [optional] # noqa: E501 + label (str): The label of the axis to display on the graph.. [optional] # noqa: E501 + max (str): Specifies the maximum value to show on the y-axis. It takes a number, or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + min (str): Specifies minimum value to show on the y-axis. It takes a number, or auto for default behavior.. [optional] if omitted the server will use the default value of "auto" # noqa: E501 + scale (str): Specifies the scale type. Possible values are `linear`, `log`, `sqrt`, `pow##` (e.g. `pow2`, `pow0.5` etc.).. [optional] if omitted the server will use the default value of "linear" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_change_type.py b/src/datadog_api_client/v1/model/widget_change_type.py index b5e6fa6693..b49cbae6ea 100644 --- a/src/datadog_api_client/v1/model/widget_change_type.py +++ b/src/datadog_api_client/v1/model/widget_change_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetChangeType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetChangeType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Show the absolute or the relative change.., must be one of ["absolute", "relative", ] # noqa: E501 + + Keyword Args: + value (str): Show the absolute or the relative change.., must be one of ["absolute", "relative", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_color_preference.py b/src/datadog_api_client/v1/model/widget_color_preference.py index 2d62b3de5a..3992f02299 100644 --- a/src/datadog_api_client/v1/model/widget_color_preference.py +++ b/src/datadog_api_client/v1/model/widget_color_preference.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetColorPreference(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetColorPreference - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Which color to use on the widget.., must be one of ["background", "text", ] # noqa: E501 + + Keyword Args: + value (str): Which color to use on the widget.., must be one of ["background", "text", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_comparator.py b/src/datadog_api_client/v1/model/widget_comparator.py index bd92a8ce7e..7515d0cd35 100644 --- a/src/datadog_api_client/v1/model/widget_comparator.py +++ b/src/datadog_api_client/v1/model/widget_comparator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetComparator(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetComparator - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Comparator to apply.., must be one of [">", ">=", "<", "<=", ] # noqa: E501 + + Keyword Args: + value (str): Comparator to apply.., must be one of [">", ">=", "<", "<=", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_compare_to.py b/src/datadog_api_client/v1/model/widget_compare_to.py index 2f635f5e69..db49199c86 100644 --- a/src/datadog_api_client/v1/model/widget_compare_to.py +++ b/src/datadog_api_client/v1/model/widget_compare_to.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetCompareTo(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetCompareTo - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Timeframe used for the change comparison.., must be one of ["hour_before", "day_before", "week_before", "month_before", ] # noqa: E501 + + Keyword Args: + value (str): Timeframe used for the change comparison.., must be one of ["hour_before", "day_before", "week_before", "month_before", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_conditional_format.py b/src/datadog_api_client/v1/model/widget_conditional_format.py index 5623492617..bb3e553157 100644 --- a/src/datadog_api_client/v1/model/widget_conditional_format.py +++ b/src/datadog_api_client/v1/model/widget_conditional_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -101,8 +103,100 @@ def discriminator(): "timeframe": "timeframe", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, comparator, palette, value, *args, **kwargs): # noqa: E501 + """WidgetConditionalFormat - a model defined in OpenAPI + + Args: + comparator (WidgetComparator): + palette (WidgetPalette): + value (float): Value for the comparator. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + custom_bg_color (str): Color palette to apply to the background, same values available as palette.. [optional] # noqa: E501 + custom_fg_color (str): Color palette to apply to the foreground, same values available as palette.. [optional] # noqa: E501 + hide_value (bool): True hides values.. [optional] # noqa: E501 + image_url (str): Displays an image as the background.. [optional] # noqa: E501 + metric (str): Metric from the request to correlate this conditional format with.. [optional] # noqa: E501 + timeframe (str): Defines the displayed timeframe.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.comparator = comparator + self.palette = palette + self.value = value + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -199,3 +293,8 @@ def __init__(self, comparator, palette, value, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_custom_link.py b/src/datadog_api_client/v1/model/widget_custom_link.py index 03129ae8f0..bfe0bc0512 100644 --- a/src/datadog_api_client/v1/model/widget_custom_link.py +++ b/src/datadog_api_client/v1/model/widget_custom_link.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetCustomLink(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "override_label": "override_label", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetCustomLink - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_hidden (bool): The flag for toggling context menu link visibility.. [optional] # noqa: E501 + label (str): The label for the custom link URL. Keep the label short and descriptive. Use metrics and tags as variables.. [optional] # noqa: E501 + link (str): The URL of the custom link. URL must include `http` or `https`. A relative URL must start with `/`.. [optional] # noqa: E501 + override_label (str): The label ID that refers to a context menu link. Can be `logs`, `hosts`, `traces`, `profiles`, `processes`, `containers`, or `rum`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_definition.py b/src/datadog_api_client/v1/model/widget_definition.py index ede3fac85a..8ff33ef2d6 100644 --- a/src/datadog_api_client/v1/model/widget_definition.py +++ b/src/datadog_api_client/v1/model/widget_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -186,24 +188,7 @@ class WidgetDefinition(ModelComposed): }, } - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -225,6 +210,181 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetDefinition - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + time (WidgetTime): [optional] # noqa: E501 + title (str): Title of the widget.. [optional] # noqa: E501 + title_align (WidgetTextAlign): [optional] # noqa: E501 + title_size (str): Size of the title.. [optional] # noqa: E501 + precision (int): Number of decimals to show. If not defined, the widget uses the raw value.. [optional] # noqa: E501 + text_align (WidgetTextAlign): [optional] # noqa: E501 + unit (str): Unit to display with the value.. [optional] # noqa: E501 + custom_links ([WidgetCustomLink]): List of custom links.. [optional] # noqa: E501 + group ([str]): List of tag prefixes to group by.. [optional] # noqa: E501 + tags ([str]): List of tags used to filter the groups reporting a cluster check.. [optional] # noqa: E501 + legend_size (str): Available legend sizes for a widget. Should be one of \"0\", \"2\", \"4\", \"8\", \"16\", or \"auto\".. [optional] # noqa: E501 + markers ([WidgetMarker]): List of markers.. [optional] # noqa: E501 + show_legend (bool): Whether or not to display the legend on this widget.. [optional] # noqa: E501 + xaxis (WidgetAxis): [optional] # noqa: E501 + yaxis (WidgetAxis): [optional] # noqa: E501 + event_size (WidgetEventSize): [optional] # noqa: E501 + tags_execution (str): The execution method for multi-value filters. Can be either and or or.. [optional] # noqa: E501 + color (str): Color of the text.. [optional] # noqa: E501 + font_size (str): Size of the text.. [optional] # noqa: E501 + background_color (str): Background color of the note.. [optional] # noqa: E501 + banner_img (str): URL of image to display as a banner for the group.. [optional] # noqa: E501 + show_title (bool): Whether to show the title or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + events ([WidgetEvent]): List of widget events.. [optional] # noqa: E501 + no_group_hosts (bool): Whether to show the hosts that don’t fit in a group.. [optional] # noqa: E501 + no_metric_hosts (bool): Whether to show the hosts with no metrics.. [optional] # noqa: E501 + node_type (WidgetNodeType): [optional] # noqa: E501 + notes (str): Notes on the title.. [optional] # noqa: E501 + scope ([str]): List of tags used to filter the map.. [optional] # noqa: E501 + has_background (bool): Whether to display a background or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + has_border (bool): Whether to display a border or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + horizontal_align (WidgetHorizontalAlign): [optional] # noqa: E501 + margin (WidgetMargin): [optional] # noqa: E501 + sizing (WidgetImageSizing): [optional] # noqa: E501 + url_dark_theme (str): URL of the image in dark mode.. [optional] # noqa: E501 + vertical_align (WidgetVerticalAlign): [optional] # noqa: E501 + columns ([str]): Which columns to display on the widget.. [optional] # noqa: E501 + indexes ([str]): An array of index names to query in the stream. Use [] to query all indexes at once.. [optional] # noqa: E501 + logset (str): ID of the log set to use.. [optional] # noqa: E501 + message_display (WidgetMessageDisplay): [optional] # noqa: E501 + show_date_column (bool): Whether to show the date column or not. [optional] # noqa: E501 + show_message_column (bool): Whether to show the message column or not. [optional] # noqa: E501 + sort (WidgetMonitorSummarySort): [optional] # noqa: E501 + color_preference (WidgetColorPreference): [optional] # noqa: E501 + count (int): The number of monitors to display.. [optional] # noqa: E501 + display_format (WidgetServiceSummaryDisplayFormat): [optional] # noqa: E501 + hide_zero_counts (bool): Whether to show counts of 0 or not.. [optional] # noqa: E501 + show_last_triggered (bool): Whether to show the time that has elapsed since the monitor/group triggered.. [optional] # noqa: E501 + start (int): The start of the list. Typically 0.. [optional] # noqa: E501 + summary_type (WidgetSummaryType): [optional] # noqa: E501 + has_padding (bool): Whether to add padding or not.. [optional] if omitted the server will use the default value of True # noqa: E501 + show_tick (bool): Whether to show a tick or not.. [optional] # noqa: E501 + tick_edge (WidgetTickEdge): [optional] # noqa: E501 + tick_pos (str): Where to position the tick on an edge.. [optional] # noqa: E501 + autoscale (bool): Whether to use auto-scaling or not.. [optional] # noqa: E501 + custom_unit (str): Display a unit of your choice on the widget.. [optional] # noqa: E501 + color_by_groups ([str]): List of groups used for colors.. [optional] # noqa: E501 + global_time_target (str): Defined global time target.. [optional] # noqa: E501 + show_error_budget (bool): Defined error budget.. [optional] # noqa: E501 + slo_id (str): ID of the SLO displayed.. [optional] # noqa: E501 + time_windows ([WidgetTimeWindows]): Times being monitored.. [optional] # noqa: E501 + view_mode (WidgetViewMode): [optional] # noqa: E501 + show_breakdown (bool): Whether to show the latency breakdown or not.. [optional] # noqa: E501 + show_distribution (bool): Whether to show the latency distribution or not.. [optional] # noqa: E501 + show_errors (bool): Whether to show the error metrics or not.. [optional] # noqa: E501 + show_hits (bool): Whether to show the hits metrics or not.. [optional] # noqa: E501 + show_latency (bool): Whether to show the latency metrics or not.. [optional] # noqa: E501 + show_resource_list (bool): Whether to show the resource list or not.. [optional] # noqa: E501 + size_format (WidgetSizeFormat): [optional] # noqa: E501 + has_search_bar (TableWidgetHasSearchBar): [optional] # noqa: E501 + legend_columns ([TimeseriesWidgetLegendColumn]): Columns displayed in the legend.. [optional] # noqa: E501 + legend_layout (TimeseriesWidgetLegendLayout): [optional] # noqa: E501 + right_yaxis (WidgetAxis): [optional] # noqa: E501 + alert_id (str): ID of the alert to use in the widget.. [optional] # noqa: E501 + type (ListStreamWidgetDefinitionType): [optional] # noqa: E501 + viz_type (WidgetVizType): [optional] # noqa: E501 + requests ([ListStreamWidgetRequest]): Request payload used to query items.. [optional] # noqa: E501 + check (str): Name of the check to use in the widget.. [optional] # noqa: E501 + group_by (TreeMapGroupBy): [optional] # noqa: E501 + grouping (WidgetGrouping): [optional] # noqa: E501 + query (str): Query to filter the monitors with.. [optional] # noqa: E501 + text (str): Text to display.. [optional] # noqa: E501 + style (HostMapWidgetDefinitionStyle): [optional] # noqa: E501 + view (GeomapWidgetDefinitionView): [optional] # noqa: E501 + layout_type (WidgetLayoutType): [optional] # noqa: E501 + widgets ([Widget]): List of widget groups.. [optional] # noqa: E501 + url (str): URL of the image.. [optional] # noqa: E501 + content (str): Content of the note.. [optional] # noqa: E501 + view_type (str): Type of view displayed by the widget.. [optional] if omitted the server will use the default value of "detail" # noqa: E501 + filters ([str]): Your environment and primary tag (or * if enabled for your account).. [optional] # noqa: E501 + service (str): APM service.. [optional] # noqa: E501 + env (str): APM environment.. [optional] # noqa: E501 + span_name (str): APM span name.. [optional] # noqa: E501 + color_by (TreeMapColorBy): [optional] # noqa: E501 + size_by (TreeMapSizeBy): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -401,28 +561,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v1/model/widget_display_type.py b/src/datadog_api_client/v1/model/widget_display_type.py index 3e95b34337..c27157c9ca 100644 --- a/src/datadog_api_client/v1/model/widget_display_type.py +++ b/src/datadog_api_client/v1/model/widget_display_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetDisplayType(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetDisplayType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of display to use for the request.., must be one of ["area", "bars", "line", ] # noqa: E501 + + Keyword Args: + value (str): Type of display to use for the request.., must be one of ["area", "bars", "line", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_event.py b/src/datadog_api_client/v1/model/widget_event.py index 044f12aac3..6e08132ca9 100644 --- a/src/datadog_api_client/v1/model/widget_event.py +++ b/src/datadog_api_client/v1/model/widget_event.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetEvent(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "tags_execution": "tags_execution", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, q, *args, **kwargs): # noqa: E501 + """WidgetEvent - a model defined in OpenAPI + + Args: + q (str): Query definition. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tags_execution (str): The execution method for multi-value filters.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.q = q + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +252,8 @@ def __init__(self, q, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_event_size.py b/src/datadog_api_client/v1/model/widget_event_size.py index 432ccabc10..9861792e72 100644 --- a/src/datadog_api_client/v1/model/widget_event_size.py +++ b/src/datadog_api_client/v1/model/widget_event_size.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetEventSize(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetEventSize - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Size to use to display an event.., must be one of ["s", "l", ] # noqa: E501 + + Keyword Args: + value (str): Size to use to display an event.., must be one of ["s", "l", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_field_sort.py b/src/datadog_api_client/v1/model/widget_field_sort.py index 0306f181ec..9b17701c9a 100644 --- a/src/datadog_api_client/v1/model/widget_field_sort.py +++ b/src/datadog_api_client/v1/model/widget_field_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "order": "order", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, column, order, *args, **kwargs): # noqa: E501 + """WidgetFieldSort - a model defined in OpenAPI + + Args: + column (str): Facet path for the column + order (WidgetSort): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.column = column + self.order = order + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, column, order, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_formula.py b/src/datadog_api_client/v1/model/widget_formula.py index 40f5c90305..c01d493e24 100644 --- a/src/datadog_api_client/v1/model/widget_formula.py +++ b/src/datadog_api_client/v1/model/widget_formula.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,94 @@ def discriminator(): "limit": "limit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, formula, *args, **kwargs): # noqa: E501 + """WidgetFormula - a model defined in OpenAPI + + Args: + formula (str): String expression built from queries, formulas, and functions. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + alias (str): Expression alias.. [optional] # noqa: E501 + cell_display_mode (TableWidgetCellDisplayMode): [optional] # noqa: E501 + conditional_formats ([WidgetConditionalFormat]): List of conditional formats.. [optional] # noqa: E501 + limit (WidgetFormulaLimit): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.formula = formula + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -187,3 +275,8 @@ def __init__(self, formula, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_formula_limit.py b/src/datadog_api_client/v1/model/widget_formula_limit.py index 8ff496dc06..703857682a 100644 --- a/src/datadog_api_client/v1/model/widget_formula_limit.py +++ b/src/datadog_api_client/v1/model/widget_formula_limit.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "order": "order", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetFormulaLimit - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + count (int): Number of results to return.. [optional] # noqa: E501 + order (QuerySortOrder): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_grouping.py b/src/datadog_api_client/v1/model/widget_grouping.py index d1e4b62798..00c842b50c 100644 --- a/src/datadog_api_client/v1/model/widget_grouping.py +++ b/src/datadog_api_client/v1/model/widget_grouping.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetGrouping(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetGrouping - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The kind of grouping to use.., must be one of ["check", "cluster", ] # noqa: E501 + + Keyword Args: + value (str): The kind of grouping to use.., must be one of ["check", "cluster", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_horizontal_align.py b/src/datadog_api_client/v1/model/widget_horizontal_align.py index 7173a462e8..47ee82c22c 100644 --- a/src/datadog_api_client/v1/model/widget_horizontal_align.py +++ b/src/datadog_api_client/v1/model/widget_horizontal_align.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetHorizontalAlign(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetHorizontalAlign - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Horizontal alignment.., must be one of ["center", "left", "right", ] # noqa: E501 + + Keyword Args: + value (str): Horizontal alignment.., must be one of ["center", "left", "right", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_image_sizing.py b/src/datadog_api_client/v1/model/widget_image_sizing.py index a3e521b54d..fadd3d1d01 100644 --- a/src/datadog_api_client/v1/model/widget_image_sizing.py +++ b/src/datadog_api_client/v1/model/widget_image_sizing.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetImageSizing(ModelSimple): @@ -81,6 +83,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -184,3 +188,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetImageSizing - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): How to size the image on the widget. The values are based on the image `object-fit` CSS properties. **Note**: `zoom`, `fit` and `center` values are deprecated.., must be one of ["fill", "contain", "cover", "none", "scale-down", "zoom", "fit", "center", ] # noqa: E501 + + Keyword Args: + value (str): How to size the image on the widget. The values are based on the image `object-fit` CSS properties. **Note**: `zoom`, `fit` and `center` values are deprecated.., must be one of ["fill", "contain", "cover", "none", "scale-down", "zoom", "fit", "center", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_layout.py b/src/datadog_api_client/v1/model/widget_layout.py index d03a70e793..aa56219720 100644 --- a/src/datadog_api_client/v1/model/widget_layout.py +++ b/src/datadog_api_client/v1/model/widget_layout.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetLayout(ModelNormal): @@ -97,8 +99,97 @@ def discriminator(): "is_column_break": "is_column_break", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, height, width, x, y, *args, **kwargs): # noqa: E501 + """WidgetLayout - a model defined in OpenAPI + + Args: + height (int): The height of the widget. Should be a non-negative integer. + width (int): The width of the widget. Should be a non-negative integer. + x (int): The position of the widget on the x (horizontal) axis. Should be a non-negative integer. + y (int): The position of the widget on the y (vertical) axis. Should be a non-negative integer. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + is_column_break (bool): Whether the widget should be the first one on the second column in high density or not. **Note**: Only for the **new dashboard layout** and only one widget in the dashboard should have this property set to `true`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.height = height + self.width = width + self.x = x + self.y = y + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +283,8 @@ def __init__(self, height, width, x, y, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_layout_type.py b/src/datadog_api_client/v1/model/widget_layout_type.py index 43aa326c27..19c39732cb 100644 --- a/src/datadog_api_client/v1/model/widget_layout_type.py +++ b/src/datadog_api_client/v1/model/widget_layout_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetLayoutType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetLayoutType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Layout type of the group.. if omitted defaults to "ordered", must be one of ["ordered", ] # noqa: E501 + + Keyword Args: + value (str): Layout type of the group.. if omitted defaults to "ordered", must be one of ["ordered", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "ordered" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_line_type.py b/src/datadog_api_client/v1/model/widget_line_type.py index 0725b6e6ab..bd8ffc5609 100644 --- a/src/datadog_api_client/v1/model/widget_line_type.py +++ b/src/datadog_api_client/v1/model/widget_line_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetLineType(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetLineType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of lines displayed.., must be one of ["dashed", "dotted", "solid", ] # noqa: E501 + + Keyword Args: + value (str): Type of lines displayed.., must be one of ["dashed", "dotted", "solid", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_line_width.py b/src/datadog_api_client/v1/model/widget_line_width.py index 8716877ea8..3049fa1a2e 100644 --- a/src/datadog_api_client/v1/model/widget_line_width.py +++ b/src/datadog_api_client/v1/model/widget_line_width.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetLineWidth(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetLineWidth - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Width of line displayed.., must be one of ["normal", "thick", "thin", ] # noqa: E501 + + Keyword Args: + value (str): Width of line displayed.., must be one of ["normal", "thick", "thin", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_live_span.py b/src/datadog_api_client/v1/model/widget_live_span.py index a729c0f638..fa7cb3237e 100644 --- a/src/datadog_api_client/v1/model/widget_live_span.py +++ b/src/datadog_api_client/v1/model/widget_live_span.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetLiveSpan(ModelSimple): @@ -88,6 +90,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -191,3 +195,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetLiveSpan - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The available timeframes depend on the widget you are using.., must be one of ["1m", "5m", "10m", "15m", "30m", "1h", "4h", "1d", "2d", "1w", "1mo", "3mo", "6mo", "1y", "alert", ] # noqa: E501 + + Keyword Args: + value (str): The available timeframes depend on the widget you are using.., must be one of ["1m", "5m", "10m", "15m", "30m", "1h", "4h", "1d", "2d", "1w", "1mo", "3mo", "6mo", "1y", "alert", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_margin.py b/src/datadog_api_client/v1/model/widget_margin.py index a6f22206d0..e4337c846b 100644 --- a/src/datadog_api_client/v1/model/widget_margin.py +++ b/src/datadog_api_client/v1/model/widget_margin.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetMargin(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetMargin - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Size of the margins around the image. **Note**: `small` and `large` values are deprecated.., must be one of ["sm", "md", "lg", "small", "large", ] # noqa: E501 + + Keyword Args: + value (str): Size of the margins around the image. **Note**: `small` and `large` values are deprecated.., must be one of ["sm", "md", "lg", "small", "large", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_marker.py b/src/datadog_api_client/v1/model/widget_marker.py index c4eb04f0d7..00ab5d693d 100644 --- a/src/datadog_api_client/v1/model/widget_marker.py +++ b/src/datadog_api_client/v1/model/widget_marker.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetMarker(ModelNormal): @@ -82,8 +84,93 @@ def discriminator(): "time": "time", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, value, *args, **kwargs): # noqa: E501 + """WidgetMarker - a model defined in OpenAPI + + Args: + value (str): Value to apply. Can be a single value y = 15 or a range of values 0 < y < 10. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + display_type (str): Combination of: - A severity error, warning, ok, or info - A line type: dashed, solid, or bold In this case of a Distribution widget, this can be set to be `x_axis_percentile`. . [optional] # noqa: E501 + label (str): Label to display over the marker.. [optional] # noqa: E501 + time (str): Timestamp for the widget.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.value = value + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +260,8 @@ def __init__(self, value, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_message_display.py b/src/datadog_api_client/v1/model/widget_message_display.py index 76f19637d5..74870b9c34 100644 --- a/src/datadog_api_client/v1/model/widget_message_display.py +++ b/src/datadog_api_client/v1/model/widget_message_display.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetMessageDisplay(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetMessageDisplay - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Amount of log lines to display., must be one of ["inline", "expanded-md", "expanded-lg", ] # noqa: E501 + + Keyword Args: + value (str): Amount of log lines to display., must be one of ["inline", "expanded-md", "expanded-lg", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_monitor_summary_display_format.py b/src/datadog_api_client/v1/model/widget_monitor_summary_display_format.py index 950b21c74c..9bd4997fdd 100644 --- a/src/datadog_api_client/v1/model/widget_monitor_summary_display_format.py +++ b/src/datadog_api_client/v1/model/widget_monitor_summary_display_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetMonitorSummaryDisplayFormat(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetMonitorSummaryDisplayFormat - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): What to display on the widget.., must be one of ["counts", "countsAndList", "list", ] # noqa: E501 + + Keyword Args: + value (str): What to display on the widget.., must be one of ["counts", "countsAndList", "list", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_monitor_summary_sort.py b/src/datadog_api_client/v1/model/widget_monitor_summary_sort.py index 759029a905..0a3563a444 100644 --- a/src/datadog_api_client/v1/model/widget_monitor_summary_sort.py +++ b/src/datadog_api_client/v1/model/widget_monitor_summary_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetMonitorSummarySort(ModelSimple): @@ -88,6 +90,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -191,3 +195,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetMonitorSummarySort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Widget sorting methods.., must be one of ["name", "group", "status", "tags", "triggered", "group,asc", "group,desc", "name,asc", "name,desc", "status,asc", "status,desc", "tags,asc", "tags,desc", "triggered,asc", "triggered,desc", ] # noqa: E501 + + Keyword Args: + value (str): Widget sorting methods.., must be one of ["name", "group", "status", "tags", "triggered", "group,asc", "group,desc", "name,asc", "name,desc", "status,asc", "status,desc", "tags,asc", "tags,desc", "triggered,asc", "triggered,desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_node_type.py b/src/datadog_api_client/v1/model/widget_node_type.py index ce05e0db80..23d7479b00 100644 --- a/src/datadog_api_client/v1/model/widget_node_type.py +++ b/src/datadog_api_client/v1/model/widget_node_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetNodeType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetNodeType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Which type of node to use in the map.., must be one of ["host", "container", ] # noqa: E501 + + Keyword Args: + value (str): Which type of node to use in the map.., must be one of ["host", "container", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_order_by.py b/src/datadog_api_client/v1/model/widget_order_by.py index 49e4d2896d..cb5bab5c6b 100644 --- a/src/datadog_api_client/v1/model/widget_order_by.py +++ b/src/datadog_api_client/v1/model/widget_order_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetOrderBy(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetOrderBy - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): What to order by.., must be one of ["change", "name", "present", "past", ] # noqa: E501 + + Keyword Args: + value (str): What to order by.., must be one of ["change", "name", "present", "past", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_palette.py b/src/datadog_api_client/v1/model/widget_palette.py index fbeac46414..3b588d1fad 100644 --- a/src/datadog_api_client/v1/model/widget_palette.py +++ b/src/datadog_api_client/v1/model/widget_palette.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetPalette(ModelSimple): @@ -92,6 +94,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -195,3 +199,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetPalette - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Color palette to apply.., must be one of ["blue", "custom_bg", "custom_image", "custom_text", "gray_on_white", "grey", "green", "orange", "red", "red_on_white", "white_on_gray", "white_on_green", "green_on_white", "white_on_red", "white_on_yellow", "yellow_on_white", "black_on_light_yellow", "black_on_light_green", "black_on_light_red", ] # noqa: E501 + + Keyword Args: + value (str): Color palette to apply.., must be one of ["blue", "custom_bg", "custom_image", "custom_text", "gray_on_white", "grey", "green", "orange", "red", "red_on_white", "white_on_gray", "white_on_green", "green_on_white", "white_on_red", "white_on_yellow", "yellow_on_white", "black_on_light_yellow", "black_on_light_green", "black_on_light_red", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_request_style.py b/src/datadog_api_client/v1/model/widget_request_style.py index d6c87ccd7c..3655879e27 100644 --- a/src/datadog_api_client/v1/model/widget_request_style.py +++ b/src/datadog_api_client/v1/model/widget_request_style.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "palette": "palette", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetRequestStyle - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + line_type (WidgetLineType): [optional] # noqa: E501 + line_width (WidgetLineWidth): [optional] # noqa: E501 + palette (str): Color palette to apply to the widget.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_service_summary_display_format.py b/src/datadog_api_client/v1/model/widget_service_summary_display_format.py index 73267a135f..a381d32aa2 100644 --- a/src/datadog_api_client/v1/model/widget_service_summary_display_format.py +++ b/src/datadog_api_client/v1/model/widget_service_summary_display_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetServiceSummaryDisplayFormat(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetServiceSummaryDisplayFormat - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Number of columns to display.., must be one of ["one_column", "two_column", "three_column", ] # noqa: E501 + + Keyword Args: + value (str): Number of columns to display.., must be one of ["one_column", "two_column", "three_column", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_size_format.py b/src/datadog_api_client/v1/model/widget_size_format.py index d240e61419..10685db4dc 100644 --- a/src/datadog_api_client/v1/model/widget_size_format.py +++ b/src/datadog_api_client/v1/model/widget_size_format.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetSizeFormat(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetSizeFormat - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Size of the widget.., must be one of ["small", "medium", "large", ] # noqa: E501 + + Keyword Args: + value (str): Size of the widget.., must be one of ["small", "medium", "large", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_sort.py b/src/datadog_api_client/v1/model/widget_sort.py index ddf89303db..3bd6e10404 100644 --- a/src/datadog_api_client/v1/model/widget_sort.py +++ b/src/datadog_api_client/v1/model/widget_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetSort(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Widget sorting methods.., must be one of ["asc", "desc", ] # noqa: E501 + + Keyword Args: + value (str): Widget sorting methods.., must be one of ["asc", "desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_style.py b/src/datadog_api_client/v1/model/widget_style.py index 260ae79c70..53b02b6fe3 100644 --- a/src/datadog_api_client/v1/model/widget_style.py +++ b/src/datadog_api_client/v1/model/widget_style.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetStyle(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "palette": "palette", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetStyle - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + palette (str): Color palette to apply to the widget.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_summary_type.py b/src/datadog_api_client/v1/model/widget_summary_type.py index 6ffb77c9b7..a9c10c519b 100644 --- a/src/datadog_api_client/v1/model/widget_summary_type.py +++ b/src/datadog_api_client/v1/model/widget_summary_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetSummaryType(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetSummaryType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Which summary type should be used.., must be one of ["monitors", "groups", "combined", ] # noqa: E501 + + Keyword Args: + value (str): Which summary type should be used.., must be one of ["monitors", "groups", "combined", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_text_align.py b/src/datadog_api_client/v1/model/widget_text_align.py index 66e95b7530..f7385c7ea9 100644 --- a/src/datadog_api_client/v1/model/widget_text_align.py +++ b/src/datadog_api_client/v1/model/widget_text_align.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetTextAlign(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetTextAlign - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): How to align the text on the widget.., must be one of ["center", "left", "right", ] # noqa: E501 + + Keyword Args: + value (str): How to align the text on the widget.., must be one of ["center", "left", "right", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_tick_edge.py b/src/datadog_api_client/v1/model/widget_tick_edge.py index 2929f417e7..4efea9a155 100644 --- a/src/datadog_api_client/v1/model/widget_tick_edge.py +++ b/src/datadog_api_client/v1/model/widget_tick_edge.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetTickEdge(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetTickEdge - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Define how you want to align the text on the widget.., must be one of ["bottom", "left", "right", "top", ] # noqa: E501 + + Keyword Args: + value (str): Define how you want to align the text on the widget.., must be one of ["bottom", "left", "right", "top", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_time.py b/src/datadog_api_client/v1/model/widget_time.py index ceeb7c22c3..71c76d9000 100644 --- a/src/datadog_api_client/v1/model/widget_time.py +++ b/src/datadog_api_client/v1/model/widget_time.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "live_span": "live_span", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """WidgetTime - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + live_span (WidgetLiveSpan): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v1/model/widget_time_windows.py b/src/datadog_api_client/v1/model/widget_time_windows.py index 07319e8b77..5895300004 100644 --- a/src/datadog_api_client/v1/model/widget_time_windows.py +++ b/src/datadog_api_client/v1/model/widget_time_windows.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetTimeWindows(ModelSimple): @@ -81,6 +83,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -184,3 +188,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetTimeWindows - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Define a time window.., must be one of ["7d", "30d", "90d", "week_to_date", "previous_week", "month_to_date", "previous_month", "global_time", ] # noqa: E501 + + Keyword Args: + value (str): Define a time window.., must be one of ["7d", "30d", "90d", "week_to_date", "previous_week", "month_to_date", "previous_month", "global_time", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_vertical_align.py b/src/datadog_api_client/v1/model/widget_vertical_align.py index 3ad2d229bc..3d8f3378a3 100644 --- a/src/datadog_api_client/v1/model/widget_vertical_align.py +++ b/src/datadog_api_client/v1/model/widget_vertical_align.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetVerticalAlign(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetVerticalAlign - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Vertical alignment.., must be one of ["center", "top", "bottom", ] # noqa: E501 + + Keyword Args: + value (str): Vertical alignment.., must be one of ["center", "top", "bottom", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_view_mode.py b/src/datadog_api_client/v1/model/widget_view_mode.py index 00667c5595..adc6fd07e5 100644 --- a/src/datadog_api_client/v1/model/widget_view_mode.py +++ b/src/datadog_api_client/v1/model/widget_view_mode.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetViewMode(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetViewMode - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Define how you want the SLO to be displayed.., must be one of ["overall", "component", "both", ] # noqa: E501 + + Keyword Args: + value (str): Define how you want the SLO to be displayed.., must be one of ["overall", "component", "both", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model/widget_viz_type.py b/src/datadog_api_client/v1/model/widget_viz_type.py index c4f56bcad3..db943febd7 100644 --- a/src/datadog_api_client/v1/model/widget_viz_type.py +++ b/src/datadog_api_client/v1/model/widget_viz_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v1.exceptions import ApiAttributeError class WidgetVizType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """WidgetVizType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Whether to display the Alert Graph as a timeseries or a top list.., must be one of ["timeseries", "toplist", ] # noqa: E501 + + Keyword Args: + value (str): Whether to display the Alert Graph as a timeseries or a top list.., must be one of ["timeseries", "toplist", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v1/model_utils.py b/src/datadog_api_client/v1/model_utils.py index ab1e263b7a..908e063a10 100644 --- a/src/datadog_api_client/v1/model_utils.py +++ b/src/datadog_api_client/v1/model_utils.py @@ -24,9 +24,27 @@ file_type = io.IOBase +def convert_js_args_to_python_args(fn): + from functools import wraps + + @wraps(fn) + def wrapped_init(_self, *args, **kwargs): + """ + An attribute named `self` received from the api will conflicts with the reserved `self` + parameter of a class method. During generation, `self` attributes are mapped + to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. + """ + spec_property_naming = kwargs.get("_spec_property_naming", False) + if spec_property_naming: + kwargs = change_keys_js_to_python(kwargs, _self if isinstance(_self, type) else _self.__class__) + return fn(_self, *args, **kwargs) + + return wrapped_init + + class cached_property(object): # this caches the result of the function call for fn with no inputs - # use this as a decorator on fuction methods that you want converted + # use this as a decorator on function methods that you want converted # into cached properties result_key = "_results" @@ -249,6 +267,109 @@ def __new__(cls, *args, **kwargs): new_inst.__init__(*args, **kwargs) return new_inst + @classmethod + @convert_js_args_to_python_args + def _new_from_openapi_data(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + visited_composed_classes = kwargs.get("_visited_composed_classes", ()) + if cls.discriminator is None or cls in visited_composed_classes: + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: If Animal has a discriminator + # petType and we pass in "Dog", and the class Dog + # allOf includes Animal, we move through Animal + # once using the discriminator, and pick Dog. + # Then in the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return cls._from_openapi_data(*args, **kwargs) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get("_path_to_item", ()) + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class(cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get("_path_to_item", ()) + disc_prop_value = kwargs.get(discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return cls._from_openapi_data(*args, **kwargs) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = cls._composed_schemas.get("oneOf", ()) + cls._composed_schemas.get("anyOf", ()) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs["_visited_composed_classes"] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get("allOf") and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = cls._from_openapi_data(*args, **kwargs) + + new_inst = new_cls._new_from_openapi_data(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -396,22 +517,13 @@ def __setitem__(self, name, value): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get(name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__["_var_name_to_model_instances"][name] = model_instance - return None - - raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), [e for e in [self._path_to_item, name] if e] - ) + # Set attribute on composed instances + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__["_var_name_to_model_instances"][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -421,12 +533,12 @@ def get(self, name, default=None): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get(name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1102,17 +1214,17 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, configu ) if issubclass(model_class, ModelSimple): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) elif isinstance(model_data, list): if issubclass(model_class, ModelComposed) and allows_single_value_input(model_class): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) else: - return model_class(*model_data, **kw_args) + return model_class._new_from_openapi_data(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) - return model_class(**kw_args) + return model_class._new_from_openapi_data(**kw_args) elif isinstance(model_data, PRIMITIVE_TYPES): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) def deserialize_file(response_data, configuration, content_disposition=None): @@ -1405,20 +1517,34 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) + seen_json_attribute_names = set() + used_fallback_python_attribute_names = set() + py_to_json_map = {} for model_instance in model_instances: for attr, value in model_instance._data_store.items(): if serialize: # we use get here because additional property key names do not # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) + try: + attr = model_instance.attribute_map[attr] + py_to_json_map.update(model_instance.attribute_map) + seen_json_attribute_names.add(attr) + except KeyError: + used_fallback_python_attribute_names.add(attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types + if not value: + # empty list or None result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] else: - result[attr] = [model_to_dict(x, serialize=serialize) if x is not None else None for x in value] + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict( map( @@ -1434,6 +1560,16 @@ def model_to_dict(model_instance, serialize=True): result[attr] = model_to_dict(value, serialize=serialize) else: result[attr] = value + if serialize: + for python_key in used_fallback_python_attribute_names: + json_key = py_to_json_map.get(python_key) + if json_key is None: + continue + if python_key == json_key: + continue + json_key_assigned_no_need_for_python_key = json_key in seen_json_attribute_names + if json_key_assigned_no_need_for_python_key: + del result[python_key] return result @@ -1472,27 +1608,19 @@ def get_valid_classes_phrase(input_classes): return "is one of [{0}]".format(", ".join(all_class_names)) -def convert_js_args_to_python_args(fn): - from functools import wraps - - @wraps(fn) - def wrapped_init(self, *args, **kwargs): - spec_property_naming = kwargs.get("_spec_property_naming", False) - if spec_property_naming: - kwargs = change_keys_js_to_python(kwargs, self.__class__) - return fn(self, *args, **kwargs) - - return wrapped_init - - def get_allof_instances(self, model_args, constant_args): """ Args: self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1500,20 +1628,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas["allOf"]: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1568,30 +1684,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1646,24 +1741,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1675,46 +1754,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances(composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas["allOf"]: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1758,29 +1825,37 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] - # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances(self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = get_additional_properties_model_instances(composed_instances, self) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if ( - len(unused_args) > 0 - and len(additional_properties_model_instances) == 0 - and (self._configuration is None or not self._configuration.discard_unknown_keys) - ): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + # map variable names to composed_instances + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances - return [composed_instances, var_name_to_model_instances, additional_properties_model_instances, unused_args] + return [composed_instances, var_name_to_model_instances, additional_properties_model_instances, discarded_args] diff --git a/src/datadog_api_client/v1/openapi.yaml b/src/datadog_api_client/v1/openapi.yaml index 29b46291e4..75ab2eaae6 100644 --- a/src/datadog_api_client/v1/openapi.yaml +++ b/src/datadog_api_client/v1/openapi.yaml @@ -8792,9 +8792,8 @@ components: description: The associated assertion property. type: string target: - additionalProperties: false description: Value used by the operator. - type: object + nullable: false type: $ref: '#/components/schemas/SyntheticsAssertionType' required: diff --git a/src/datadog_api_client/v1/rest.py b/src/datadog_api_client/v1/rest.py index 9be4f97a9f..8fcf205758 100644 --- a/src/datadog_api_client/v1/rest.py +++ b/src/datadog_api_client/v1/rest.py @@ -140,15 +140,15 @@ def request( elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) - if "Content-Type" not in headers: - headers["Content-Type"] = "application/json" - try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests + if (method != "DELETE") and ("Content-Type" not in headers): + headers["Content-Type"] = "application/json" if query_params: url += "?" + urlencode(query_params) - if re.search("json", headers["Content-Type"], re.IGNORECASE): + if ("Content-Type" not in headers) or (re.search("json", headers["Content-Type"], re.IGNORECASE)): request_body = None if body is not None: request_body = json.dumps(body) diff --git a/src/datadog_api_client/v2/api_client.py b/src/datadog_api_client/v2/api_client.py index 49d85aa055..1421c12c5a 100644 --- a/src/datadog_api_client/v2/api_client.py +++ b/src/datadog_api_client/v2/api_client.py @@ -124,7 +124,7 @@ def __call_api( _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None, ): @@ -325,7 +325,7 @@ def call_api( _return_http_data_only: typing.Optional[bool] = None, collection_formats: typing.Optional[typing.Dict[str, str]] = None, _preload_content: bool = True, - _request_timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, _check_type: typing.Optional[bool] = None, ): @@ -689,7 +689,7 @@ def __init__(self, settings=None, params_map=None, root_map=None, headers_map=No "async_req": (bool,), "_host_index": (none_type, int), "_preload_content": (bool,), - "_request_timeout": (none_type, int, (int,), [int]), + "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), "_return_http_data_only": (bool,), "_check_input_type": (bool,), "_check_return_type": (bool,), diff --git a/src/datadog_api_client/v2/model/api_error_response.py b/src/datadog_api_client/v2/model/api_error_response.py index 5276fce214..ecd2c2fb77 100644 --- a/src/datadog_api_client/v2/model/api_error_response.py +++ b/src/datadog_api_client/v2/model/api_error_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class APIErrorResponse(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "errors": "errors", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, errors, *args, **kwargs): # noqa: E501 + """APIErrorResponse - a model defined in OpenAPI + + Args: + errors ([str]): A list of errors. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.errors = errors + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, errors, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_create_attributes.py b/src/datadog_api_client/v2/model/api_key_create_attributes.py index 84f7be0f17..6121eacdb0 100644 --- a/src/datadog_api_client/v2/model/api_key_create_attributes.py +++ b/src/datadog_api_client/v2/model/api_key_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class APIKeyCreateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """APIKeyCreateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the API key. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_create_data.py b/src/datadog_api_client/v2/model/api_key_create_data.py index 2bad07c8a5..e885bcbecc 100644 --- a/src/datadog_api_client/v2/model/api_key_create_data.py +++ b/src/datadog_api_client/v2/model/api_key_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """APIKeyCreateData - a model defined in OpenAPI + + Args: + attributes (APIKeyCreateAttributes): + type (APIKeysType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_create_request.py b/src/datadog_api_client/v2/model/api_key_create_request.py index 4019ced31d..0bd1b528e6 100644 --- a/src/datadog_api_client/v2/model/api_key_create_request.py +++ b/src/datadog_api_client/v2/model/api_key_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """APIKeyCreateRequest - a model defined in OpenAPI + + Args: + data (APIKeyCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_relationships.py b/src/datadog_api_client/v2/model/api_key_relationships.py index dbaf67b41d..eac88e1b9e 100644 --- a/src/datadog_api_client/v2/model/api_key_relationships.py +++ b/src/datadog_api_client/v2/model/api_key_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "modified_by": "modified_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """APIKeyRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_by (RelationshipToUser): [optional] # noqa: E501 + modified_by (RelationshipToUser): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_response.py b/src/datadog_api_client/v2/model/api_key_response.py index 21d6b546c4..bbbec6deb8 100644 --- a/src/datadog_api_client/v2/model/api_key_response.py +++ b/src/datadog_api_client/v2/model/api_key_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """APIKeyResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (FullAPIKey): [optional] # noqa: E501 + included ([APIKeyResponseIncludedItem]): Array of objects related to the API key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_response_included_item.py b/src/datadog_api_client/v2/model/api_key_response_included_item.py index dd9786e656..843fd9f5f4 100644 --- a/src/datadog_api_client/v2/model/api_key_response_included_item.py +++ b/src/datadog_api_client/v2/model/api_key_response_included_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class APIKeyResponseIncludedItem(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """APIKeyResponseIncludedItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserAttributes): [optional] # noqa: E501 + id (str): ID of the user.. [optional] # noqa: E501 + relationships (UserResponseRelationships): [optional] # noqa: E501 + type (UsersType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -187,28 +257,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/api_key_update_attributes.py b/src/datadog_api_client/v2/model/api_key_update_attributes.py index c28fcb8c62..97f344af85 100644 --- a/src/datadog_api_client/v2/model/api_key_update_attributes.py +++ b/src/datadog_api_client/v2/model/api_key_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class APIKeyUpdateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """APIKeyUpdateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the API key. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_update_data.py b/src/datadog_api_client/v2/model/api_key_update_data.py index f7096ddd23..44c87b87de 100644 --- a/src/datadog_api_client/v2/model/api_key_update_data.py +++ b/src/datadog_api_client/v2/model/api_key_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """APIKeyUpdateData - a model defined in OpenAPI + + Args: + attributes (APIKeyUpdateAttributes): + id (str): ID of the API key. + type (APIKeysType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_key_update_request.py b/src/datadog_api_client/v2/model/api_key_update_request.py index 079128690e..6382ec48e8 100644 --- a/src/datadog_api_client/v2/model/api_key_update_request.py +++ b/src/datadog_api_client/v2/model/api_key_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """APIKeyUpdateRequest - a model defined in OpenAPI + + Args: + data (APIKeyUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_keys_response.py b/src/datadog_api_client/v2/model/api_keys_response.py index f3c48866f3..e9168815b5 100644 --- a/src/datadog_api_client/v2/model/api_keys_response.py +++ b/src/datadog_api_client/v2/model/api_keys_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """APIKeysResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([PartialAPIKey]): Array of API keys.. [optional] # noqa: E501 + included ([APIKeyResponseIncludedItem]): Array of objects related to the API key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/api_keys_sort.py b/src/datadog_api_client/v2/model/api_keys_sort.py index 98ccfb4d08..a340b8283a 100644 --- a/src/datadog_api_client/v2/model/api_keys_sort.py +++ b/src/datadog_api_client/v2/model/api_keys_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class APIKeysSort(ModelSimple): @@ -81,6 +83,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """APIKeysSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Sorting options. if omitted defaults to "name", must be one of ["created_at", "-created_at", "last4", "-last4", "modified_at", "-modified_at", "name", "-name", ] # noqa: E501 + + Keyword Args: + value (str): Sorting options. if omitted defaults to "name", must be one of ["created_at", "-created_at", "last4", "-last4", "modified_at", "-modified_at", "name", "-name", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "name" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/api_keys_type.py b/src/datadog_api_client/v2/model/api_keys_type.py index ad96d68a3a..fdb5ba7dac 100644 --- a/src/datadog_api_client/v2/model/api_keys_type.py +++ b/src/datadog_api_client/v2/model/api_keys_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class APIKeysType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """APIKeysType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): API Keys resource type.. if omitted defaults to "api_keys", must be one of ["api_keys", ] # noqa: E501 + + Keyword Args: + value (str): API Keys resource type.. if omitted defaults to "api_keys", must be one of ["api_keys", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "api_keys" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/application_key_create_attributes.py b/src/datadog_api_client/v2/model/application_key_create_attributes.py index e55095371e..3194f30b3c 100644 --- a/src/datadog_api_client/v2/model/application_key_create_attributes.py +++ b/src/datadog_api_client/v2/model/application_key_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ApplicationKeyCreateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """ApplicationKeyCreateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the application key. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_create_data.py b/src/datadog_api_client/v2/model/application_key_create_data.py index 4b3422b7e8..47e97aaf83 100644 --- a/src/datadog_api_client/v2/model/application_key_create_data.py +++ b/src/datadog_api_client/v2/model/application_key_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """ApplicationKeyCreateData - a model defined in OpenAPI + + Args: + attributes (ApplicationKeyCreateAttributes): + type (ApplicationKeysType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_create_request.py b/src/datadog_api_client/v2/model/application_key_create_request.py index 2e6cc0a1d4..d8ad216e98 100644 --- a/src/datadog_api_client/v2/model/application_key_create_request.py +++ b/src/datadog_api_client/v2/model/application_key_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """ApplicationKeyCreateRequest - a model defined in OpenAPI + + Args: + data (ApplicationKeyCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_relationships.py b/src/datadog_api_client/v2/model/application_key_relationships.py index ca9d606f73..26bc64d6e3 100644 --- a/src/datadog_api_client/v2/model/application_key_relationships.py +++ b/src/datadog_api_client/v2/model/application_key_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "created_by": "created_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKeyRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_by (RelationshipToUser): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_response.py b/src/datadog_api_client/v2/model/application_key_response.py index c76cd066e5..ecc82fc1b0 100644 --- a/src/datadog_api_client/v2/model/application_key_response.py +++ b/src/datadog_api_client/v2/model/application_key_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKeyResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (FullApplicationKey): [optional] # noqa: E501 + included ([ApplicationKeyResponseIncludedItem]): Array of objects related to the application key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_response_included_item.py b/src/datadog_api_client/v2/model/application_key_response_included_item.py index 320eefc040..105342e2cf 100644 --- a/src/datadog_api_client/v2/model/application_key_response_included_item.py +++ b/src/datadog_api_client/v2/model/application_key_response_included_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -64,24 +66,7 @@ class ApplicationKeyResponseIncludedItem(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -103,6 +88,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ApplicationKeyResponseIncludedItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (RoleAttributes): [optional] # noqa: E501 + id (str): ID of the role.. [optional] # noqa: E501 + relationships (RoleResponseRelationships): [optional] # noqa: E501 + type (RolesType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -189,28 +259,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/application_key_update_attributes.py b/src/datadog_api_client/v2/model/application_key_update_attributes.py index b49b5d732d..7259081fbc 100644 --- a/src/datadog_api_client/v2/model/application_key_update_attributes.py +++ b/src/datadog_api_client/v2/model/application_key_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ApplicationKeyUpdateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """ApplicationKeyUpdateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the application key. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_update_data.py b/src/datadog_api_client/v2/model/application_key_update_data.py index 678d4f17da..77eb43fd2f 100644 --- a/src/datadog_api_client/v2/model/application_key_update_data.py +++ b/src/datadog_api_client/v2/model/application_key_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """ApplicationKeyUpdateData - a model defined in OpenAPI + + Args: + attributes (ApplicationKeyUpdateAttributes): + id (str): ID of the application key. + type (ApplicationKeysType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_key_update_request.py b/src/datadog_api_client/v2/model/application_key_update_request.py index f685fa69ea..16dc9adefc 100644 --- a/src/datadog_api_client/v2/model/application_key_update_request.py +++ b/src/datadog_api_client/v2/model/application_key_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """ApplicationKeyUpdateRequest - a model defined in OpenAPI + + Args: + data (ApplicationKeyUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/application_keys_sort.py b/src/datadog_api_client/v2/model/application_keys_sort.py index b7d20dcdb7..005606576a 100644 --- a/src/datadog_api_client/v2/model/application_keys_sort.py +++ b/src/datadog_api_client/v2/model/application_keys_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ApplicationKeysSort(ModelSimple): @@ -79,6 +81,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ApplicationKeysSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Sorting options. if omitted defaults to "name", must be one of ["created_at", "-created_at", "last4", "-last4", "name", "-name", ] # noqa: E501 + + Keyword Args: + value (str): Sorting options. if omitted defaults to "name", must be one of ["created_at", "-created_at", "last4", "-last4", "name", "-name", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "name" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/application_keys_type.py b/src/datadog_api_client/v2/model/application_keys_type.py index ce6172e1ca..662db133bc 100644 --- a/src/datadog_api_client/v2/model/application_keys_type.py +++ b/src/datadog_api_client/v2/model/application_keys_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ApplicationKeysType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ApplicationKeysType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Application Keys resource type.. if omitted defaults to "application_keys", must be one of ["application_keys", ] # noqa: E501 + + Keyword Args: + value (str): Application Keys resource type.. if omitted defaults to "application_keys", must be one of ["application_keys", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "application_keys" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/creator.py b/src/datadog_api_client/v2/model/creator.py index e62ca29049..ac7a388a17 100644 --- a/src/datadog_api_client/v2/model/creator.py +++ b/src/datadog_api_client/v2/model/creator.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class Creator(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Creator - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + email (str): Email of the creator.. [optional] # noqa: E501 + handle (str): Handle of the creator.. [optional] # noqa: E501 + name (str): Name of the creator.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_add_items_request.py b/src/datadog_api_client/v2/model/dashboard_list_add_items_request.py index 3aaa7c8c2a..78bab4aaf3 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_add_items_request.py +++ b/src/datadog_api_client/v2/model/dashboard_list_add_items_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboards": "dashboards", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListAddItemsRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboards ([DashboardListItemRequest]): List of dashboards to add the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_add_items_response.py b/src/datadog_api_client/v2/model/dashboard_list_add_items_response.py index 595fb2104c..5e0272856a 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_add_items_response.py +++ b/src/datadog_api_client/v2/model/dashboard_list_add_items_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "added_dashboards_to_list": "added_dashboards_to_list", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListAddItemsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + added_dashboards_to_list ([DashboardListItemResponse]): List of dashboards added to the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_delete_items_request.py b/src/datadog_api_client/v2/model/dashboard_list_delete_items_request.py index 1a2fa34abd..ef5b99b6ba 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_delete_items_request.py +++ b/src/datadog_api_client/v2/model/dashboard_list_delete_items_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboards": "dashboards", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListDeleteItemsRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboards ([DashboardListItemRequest]): List of dashboards to delete from the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_delete_items_response.py b/src/datadog_api_client/v2/model/dashboard_list_delete_items_response.py index c2d3b7116e..88c54245a9 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_delete_items_response.py +++ b/src/datadog_api_client/v2/model/dashboard_list_delete_items_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "deleted_dashboards_from_list": "deleted_dashboards_from_list", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListDeleteItemsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + deleted_dashboards_from_list ([DashboardListItemResponse]): List of dashboards deleted from the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_item.py b/src/datadog_api_client/v2/model/dashboard_list_item.py index c48a6c97fa..e5ddd96e6c 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_item.py +++ b/src/datadog_api_client/v2/model/dashboard_list_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,112 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "icon", # noqa: E501 + "is_favorite", # noqa: E501 + "is_read_only", # noqa: E501 + "is_shared", # noqa: E501 + "modified", # noqa: E501 + "popularity", # noqa: E501 + "title", # noqa: E501 + "url", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """DashboardListItem - a model defined in OpenAPI + + Args: + id (str): ID of the dashboard. + type (DashboardType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + author (Creator): [optional] # noqa: E501 + created (datetime): Date of creation of the dashboard.. [optional] # noqa: E501 + icon (str): URL to the icon of the dashboard.. [optional] # noqa: E501 + is_favorite (bool): Whether or not the dashboard is in the favorites.. [optional] # noqa: E501 + is_read_only (bool): Whether or not the dashboard is read only.. [optional] # noqa: E501 + is_shared (bool): Whether the dashboard is publicly shared or not.. [optional] # noqa: E501 + modified (datetime): Date of last edition of the dashboard.. [optional] # noqa: E501 + popularity (int): Popularity of the dashboard.. [optional] # noqa: E501 + title (str): Title of the dashboard.. [optional] # noqa: E501 + url (str): URL path to the dashboard.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -211,3 +317,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_item_request.py b/src/datadog_api_client/v2/model/dashboard_list_item_request.py index 560d5449f3..cb8684a285 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_item_request.py +++ b/src/datadog_api_client/v2/model/dashboard_list_item_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """DashboardListItemRequest - a model defined in OpenAPI + + Args: + id (str): ID of the dashboard. + type (DashboardType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_item_response.py b/src/datadog_api_client/v2/model/dashboard_list_item_response.py index 7dabc424a2..cbb363aad3 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_item_response.py +++ b/src/datadog_api_client/v2/model/dashboard_list_item_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = { + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """DashboardListItemResponse - a model defined in OpenAPI + + Args: + id (str): ID of the dashboard. + type (DashboardType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -99,11 +187,9 @@ def discriminator(): ) @convert_js_args_to_python_args - def __init__(self, id, type, *args, **kwargs): # noqa: E501 + def __init__(self, type, *args, **kwargs): # noqa: E501 """DashboardListItemResponse - a model defined in OpenAPI - Args: - id (str): ID of the dashboard. type (DashboardType): Keyword Args: @@ -163,7 +249,6 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - self.id = id self.type = type for var_name, var_value in kwargs.items(): if ( @@ -175,3 +260,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_items.py b/src/datadog_api_client/v2/model/dashboard_list_items.py index 6472cb669a..9df7ee6e68 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_items.py +++ b/src/datadog_api_client/v2/model/dashboard_list_items.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,93 @@ def discriminator(): "total": "total", # noqa: E501 } + read_only_vars = { + "total", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, dashboards, *args, **kwargs): # noqa: E501 + """DashboardListItems - a model defined in OpenAPI + + Args: + dashboards ([DashboardListItem]): List of dashboards in the dashboard list. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total (int): Number of dashboards in the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.dashboards = dashboards + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +261,8 @@ def __init__(self, dashboards, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_update_items_request.py b/src/datadog_api_client/v2/model/dashboard_list_update_items_request.py index 81a19d7bbe..3875b37a6d 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_update_items_request.py +++ b/src/datadog_api_client/v2/model/dashboard_list_update_items_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboards": "dashboards", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListUpdateItemsRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboards ([DashboardListItemRequest]): List of dashboards to update the dashboard list to.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_list_update_items_response.py b/src/datadog_api_client/v2/model/dashboard_list_update_items_response.py index b40cd87da8..bfc7fbe0fc 100644 --- a/src/datadog_api_client/v2/model/dashboard_list_update_items_response.py +++ b/src/datadog_api_client/v2/model/dashboard_list_update_items_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "dashboards": "dashboards", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """DashboardListUpdateItemsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + dashboards ([DashboardListItemResponse]): List of dashboards in the dashboard list.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/dashboard_type.py b/src/datadog_api_client/v2/model/dashboard_type.py index e853d56c88..6536eee0b0 100644 --- a/src/datadog_api_client/v2/model/dashboard_type.py +++ b/src/datadog_api_client/v2/model/dashboard_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class DashboardType(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """DashboardType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of the dashboard.., must be one of ["custom_timeboard", "custom_screenboard", "integration_screenboard", "integration_timeboard", "host_timeboard", ] # noqa: E501 + + Keyword Args: + value (str): The type of the dashboard.., must be one of ["custom_timeboard", "custom_screenboard", "integration_screenboard", "integration_timeboard", "host_timeboard", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/full_api_key.py b/src/datadog_api_client/v2/model/full_api_key.py index baaa1e3693..a851357ec4 100644 --- a/src/datadog_api_client/v2/model/full_api_key.py +++ b/src/datadog_api_client/v2/model/full_api_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """FullAPIKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (FullAPIKeyAttributes): [optional] # noqa: E501 + id (str): ID of the API key.. [optional] # noqa: E501 + relationships (APIKeyRelationships): [optional] # noqa: E501 + type (APIKeysType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/full_api_key_attributes.py b/src/datadog_api_client/v2/model/full_api_key_attributes.py index d516927874..ab22122212 100644 --- a/src/datadog_api_client/v2/model/full_api_key_attributes.py +++ b/src/datadog_api_client/v2/model/full_api_key_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class FullAPIKeyAttributes(ModelNormal): @@ -89,8 +91,96 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "key", # noqa: E501 + "last4", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """FullAPIKeyAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (str): Creation date of the API key.. [optional] # noqa: E501 + key (str): The API key.. [optional] # noqa: E501 + last4 (str): The last four characters of the API key.. [optional] # noqa: E501 + modified_at (str): Date the API key was last modified.. [optional] # noqa: E501 + name (str): Name of the API key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +268,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/full_application_key.py b/src/datadog_api_client/v2/model/full_application_key.py index b78ea8a2b2..db67d7c4e1 100644 --- a/src/datadog_api_client/v2/model/full_application_key.py +++ b/src/datadog_api_client/v2/model/full_application_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """FullApplicationKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (FullApplicationKeyAttributes): [optional] # noqa: E501 + id (str): ID of the application key.. [optional] # noqa: E501 + relationships (ApplicationKeyRelationships): [optional] # noqa: E501 + type (ApplicationKeysType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/full_application_key_attributes.py b/src/datadog_api_client/v2/model/full_application_key_attributes.py index b8371f63d4..8c8b146fc3 100644 --- a/src/datadog_api_client/v2/model/full_application_key_attributes.py +++ b/src/datadog_api_client/v2/model/full_application_key_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class FullApplicationKeyAttributes(ModelNormal): @@ -87,8 +89,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "key", # noqa: E501 + "last4", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """FullApplicationKeyAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (str): Creation date of the application key.. [optional] # noqa: E501 + key (str): The application key.. [optional] # noqa: E501 + last4 (str): The last four characters of the application key.. [optional] # noqa: E501 + name (str): Name of the application key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_create_attributes.py b/src/datadog_api_client/v2/model/incident_create_attributes.py index ecbcea7bc5..c9bd887685 100644 --- a/src/datadog_api_client/v2/model/incident_create_attributes.py +++ b/src/datadog_api_client/v2/model/incident_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,95 @@ def discriminator(): "notification_handles": "notification_handles", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, customer_impacted, title, *args, **kwargs): # noqa: E501 + """IncidentCreateAttributes - a model defined in OpenAPI + + Args: + customer_impacted (bool): A flag indicating whether the incident caused customer impact. + title (str): The title of the incident, which summarizes what happened. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + fields ({str: (IncidentFieldAttributes,)}): A condensed view of the user-defined fields for which to create initial selections.. [optional] # noqa: E501 + initial_timeline_cells ([IncidentTimelineCellCreateAttributes]): An array of initial timeline cells to be placed at the beginning of the incident timeline.. [optional] # noqa: E501 + notification_handles ([str]): Notification handles that will be notified of the incident at creation.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.customer_impacted = customer_impacted + self.title = title + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +277,8 @@ def __init__(self, customer_impacted, title, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_create_data.py b/src/datadog_api_client/v2/model/incident_create_data.py index 4af769e630..9f083a2c09 100644 --- a/src/datadog_api_client/v2/model/incident_create_data.py +++ b/src/datadog_api_client/v2/model/incident_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """IncidentCreateData - a model defined in OpenAPI + + Args: + attributes (IncidentCreateAttributes): + type (IncidentType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + relationships (IncidentCreateRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_create_relationships.py b/src/datadog_api_client/v2/model/incident_create_relationships.py index 94f9aaf16a..0d6779b833 100644 --- a/src/datadog_api_client/v2/model/incident_create_relationships.py +++ b/src/datadog_api_client/v2/model/incident_create_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "commander": "commander", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, commander, *args, **kwargs): # noqa: E501 + """IncidentCreateRelationships - a model defined in OpenAPI + + Args: + commander (RelationshipToUser): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.commander = commander + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, commander, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_create_request.py b/src/datadog_api_client/v2/model/incident_create_request.py index 2d77d779c6..51e108edef 100644 --- a/src/datadog_api_client/v2/model/incident_create_request.py +++ b/src/datadog_api_client/v2/model/incident_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentCreateRequest - a model defined in OpenAPI + + Args: + data (IncidentCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_field_attributes.py b/src/datadog_api_client/v2/model/incident_field_attributes.py index fbd79c96f5..3d5a0151d8 100644 --- a/src/datadog_api_client/v2/model/incident_field_attributes.py +++ b/src/datadog_api_client/v2/model/incident_field_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class IncidentFieldAttributes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,89 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentFieldAttributes - a model defined in OpenAPI + + Keyword Args: + type (IncidentFieldAttributesValueType): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + value ([str]): The multiple values selected for this field.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -116,13 +184,11 @@ def discriminator(): ) @convert_js_args_to_python_args - def __init__(self, type, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """IncidentFieldAttributes - a model defined in OpenAPI - Args: - type (IncidentFieldAttributesValueType): - Keyword Args: + type (IncidentFieldAttributesValueType): _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -187,30 +253,11 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = { - "type": type, - } - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/incident_field_attributes_multiple_value.py b/src/datadog_api_client/v2/model/incident_field_attributes_multiple_value.py index 46b4970b79..92de46e992 100644 --- a/src/datadog_api_client/v2/model/incident_field_attributes_multiple_value.py +++ b/src/datadog_api_client/v2/model/incident_field_attributes_multiple_value.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentFieldAttributesMultipleValue - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + type (IncidentFieldAttributesValueType): [optional] # noqa: E501 + value ([str]): The multiple values selected for this field.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_field_attributes_single_value.py b/src/datadog_api_client/v2/model/incident_field_attributes_single_value.py index c8ccad1f05..4478aaa571 100644 --- a/src/datadog_api_client/v2/model/incident_field_attributes_single_value.py +++ b/src/datadog_api_client/v2/model/incident_field_attributes_single_value.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentFieldAttributesSingleValue - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + type (IncidentFieldAttributesSingleValueType): [optional] # noqa: E501 + value (str): The single value selected for this field.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_field_attributes_single_value_type.py b/src/datadog_api_client/v2/model/incident_field_attributes_single_value_type.py index fbca963cd4..0a86063842 100644 --- a/src/datadog_api_client/v2/model/incident_field_attributes_single_value_type.py +++ b/src/datadog_api_client/v2/model/incident_field_attributes_single_value_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentFieldAttributesSingleValueType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentFieldAttributesSingleValueType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the single value field definitions.. if omitted defaults to "dropdown", must be one of ["dropdown", "textbox", ] # noqa: E501 + + Keyword Args: + value (str): Type of the single value field definitions.. if omitted defaults to "dropdown", must be one of ["dropdown", "textbox", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "dropdown" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_field_attributes_value_type.py b/src/datadog_api_client/v2/model/incident_field_attributes_value_type.py index b101445245..dc3b7ad279 100644 --- a/src/datadog_api_client/v2/model/incident_field_attributes_value_type.py +++ b/src/datadog_api_client/v2/model/incident_field_attributes_value_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentFieldAttributesValueType(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -176,3 +180,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentFieldAttributesValueType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the single value field definitions.. if omitted defaults to "multiselect", must be one of ["multiselect", "textarray", "metrictag", "autocomplete", ] # noqa: E501 + + Keyword Args: + value (str): Type of the single value field definitions.. if omitted defaults to "multiselect", must be one of ["multiselect", "textarray", "metrictag", "autocomplete", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "multiselect" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_integration_metadata_type.py b/src/datadog_api_client/v2/model/incident_integration_metadata_type.py index 0564bde03e..cdb18639c9 100644 --- a/src/datadog_api_client/v2/model/incident_integration_metadata_type.py +++ b/src/datadog_api_client/v2/model/incident_integration_metadata_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentIntegrationMetadataType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentIntegrationMetadataType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Integration metadata resource type.. if omitted defaults to "incident_integrations", must be one of ["incident_integrations", ] # noqa: E501 + + Keyword Args: + value (str): Integration metadata resource type.. if omitted defaults to "incident_integrations", must be one of ["incident_integrations", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "incident_integrations" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_postmortem_type.py b/src/datadog_api_client/v2/model/incident_postmortem_type.py index d7e6f9578d..188510145e 100644 --- a/src/datadog_api_client/v2/model/incident_postmortem_type.py +++ b/src/datadog_api_client/v2/model/incident_postmortem_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentPostmortemType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentPostmortemType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Incident postmortem resource type.. if omitted defaults to "incident_postmortems", must be one of ["incident_postmortems", ] # noqa: E501 + + Keyword Args: + value (str): Incident postmortem resource type.. if omitted defaults to "incident_postmortems", must be one of ["incident_postmortems", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "incident_postmortems" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_related_object.py b/src/datadog_api_client/v2/model/incident_related_object.py index 02ebbc49a6..718e30f503 100644 --- a/src/datadog_api_client/v2/model/incident_related_object.py +++ b/src/datadog_api_client/v2/model/incident_related_object.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentRelatedObject(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentRelatedObject - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Object related to an incident.. if omitted defaults to "users", must be one of ["users", ] # noqa: E501 + + Keyword Args: + value (str): Object related to an incident.. if omitted defaults to "users", must be one of ["users", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "users" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_response.py b/src/datadog_api_client/v2/model/incident_response.py index 7270031310..ead303c139 100644 --- a/src/datadog_api_client/v2/model/incident_response.py +++ b/src/datadog_api_client/v2/model/incident_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,93 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentResponse - a model defined in OpenAPI + + Args: + data (IncidentResponseData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentResponseIncludedItem]): Included related resources that the user requested.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +263,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_response_attributes.py b/src/datadog_api_client/v2/model/incident_response_attributes.py index f961aaac1f..67b0a115ac 100644 --- a/src/datadog_api_client/v2/model/incident_response_attributes.py +++ b/src/datadog_api_client/v2/model/incident_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -132,8 +134,115 @@ def discriminator(): "time_to_resolve": "time_to_resolve", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "customer_impact_duration", # noqa: E501 + "modified", # noqa: E501 + "time_to_detect", # noqa: E501 + "time_to_internal_response", # noqa: E501 + "time_to_repair", # noqa: E501 + "time_to_resolve", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, title, *args, **kwargs): # noqa: E501 + """IncidentResponseAttributes - a model defined in OpenAPI + + Args: + title (str): The title of the incident, which summarizes what happened. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Timestamp when the incident was created.. [optional] # noqa: E501 + customer_impact_duration (int): Length of the incident's customer impact in seconds. Equals the difference between `customer_impact_start` and `customer_impact_end`.. [optional] # noqa: E501 + customer_impact_end (datetime, none_type): Timestamp when customers were no longer impacted by the incident.. [optional] # noqa: E501 + customer_impact_scope (str, none_type): A summary of the impact customers experienced during the incident.. [optional] # noqa: E501 + customer_impact_start (datetime, none_type): Timestamp when customers began being impacted by the incident.. [optional] # noqa: E501 + customer_impacted (bool): A flag indicating whether the incident caused customer impact.. [optional] # noqa: E501 + detected (datetime, none_type): Timestamp when the incident was detected.. [optional] # noqa: E501 + fields ({str: (IncidentFieldAttributes,)}): A condensed view of the user-defined fields attached to incidents.. [optional] # noqa: E501 + modified (datetime): Timestamp when the incident was last modified.. [optional] # noqa: E501 + notification_handles ([str]): Notification handles that will be notified of the incident during update.. [optional] # noqa: E501 + postmortem_id (str): The UUID of the postmortem object attached to the incident.. [optional] # noqa: E501 + public_id (int): The monotonically increasing integer ID for the incident.. [optional] # noqa: E501 + resolved (datetime, none_type): Timestamp when the incident's state was set to resolved.. [optional] # noqa: E501 + time_to_detect (int): The amount of time in seconds to detect the incident. Equals the difference between `customer_impact_start` and `detected`.. [optional] # noqa: E501 + time_to_internal_response (int): The amount of time in seconds to call incident after detection. Equals the difference of `detected` and `created`.. [optional] # noqa: E501 + time_to_repair (int): The amount of time in seconds to resolve customer impact after detecting the issue. Equals the difference between `customer_impact_end` and `detected`.. [optional] # noqa: E501 + time_to_resolve (int): The amount of time in seconds to resolve the incident after it was created. Equals the difference between `created` and `resolved`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.title = title + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -237,3 +346,8 @@ def __init__(self, title, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_response_data.py b/src/datadog_api_client/v2/model/incident_response_data.py index 374bd49cbe..6b5cabc99f 100644 --- a/src/datadog_api_client/v2/model/incident_response_data.py +++ b/src/datadog_api_client/v2/model/incident_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,94 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """IncidentResponseData - a model defined in OpenAPI + + Args: + id (str): The incident's ID. + type (IncidentType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentResponseAttributes): [optional] # noqa: E501 + relationships (IncidentResponseRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +273,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_response_included_item.py b/src/datadog_api_client/v2/model/incident_response_included_item.py index bf80534792..2bfbe8594e 100644 --- a/src/datadog_api_client/v2/model/incident_response_included_item.py +++ b/src/datadog_api_client/v2/model/incident_response_included_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class IncidentResponseIncludedItem(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentResponseIncludedItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserAttributes): [optional] # noqa: E501 + id (str): ID of the user.. [optional] # noqa: E501 + relationships (UserResponseRelationships): [optional] # noqa: E501 + type (UsersType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -187,28 +257,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/incident_response_relationships.py b/src/datadog_api_client/v2/model/incident_response_relationships.py index 8b9d277d47..6398cb8cda 100644 --- a/src/datadog_api_client/v2/model/incident_response_relationships.py +++ b/src/datadog_api_client/v2/model/incident_response_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,91 @@ def discriminator(): "postmortem": "postmortem", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentResponseRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + commander_user (RelationshipToUser): [optional] # noqa: E501 + created_by_user (RelationshipToUser): [optional] # noqa: E501 + integrations (RelationshipToIncidentIntegrationMetadatas): [optional] # noqa: E501 + last_modified_by_user (RelationshipToUser): [optional] # noqa: E501 + postmortem (RelationshipToIncidentPostmortem): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +271,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_create_attributes.py b/src/datadog_api_client/v2/model/incident_service_create_attributes.py index 901ebe7bf3..e33a404b63 100644 --- a/src/datadog_api_client/v2/model/incident_service_create_attributes.py +++ b/src/datadog_api_client/v2/model/incident_service_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentServiceCreateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """IncidentServiceCreateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the incident service. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_create_data.py b/src/datadog_api_client/v2/model/incident_service_create_data.py index f630163043..adc3ef17f7 100644 --- a/src/datadog_api_client/v2/model/incident_service_create_data.py +++ b/src/datadog_api_client/v2/model/incident_service_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """IncidentServiceCreateData - a model defined in OpenAPI + + Args: + type (IncidentServiceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentServiceCreateAttributes): [optional] # noqa: E501 + relationships (IncidentServiceRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_create_request.py b/src/datadog_api_client/v2/model/incident_service_create_request.py index bffefd241d..2b510abbaa 100644 --- a/src/datadog_api_client/v2/model/incident_service_create_request.py +++ b/src/datadog_api_client/v2/model/incident_service_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentServiceCreateRequest - a model defined in OpenAPI + + Args: + data (IncidentServiceCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_included_items.py b/src/datadog_api_client/v2/model/incident_service_included_items.py index 440b7ffa5a..c1e727a659 100644 --- a/src/datadog_api_client/v2/model/incident_service_included_items.py +++ b/src/datadog_api_client/v2/model/incident_service_included_items.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class IncidentServiceIncludedItems(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentServiceIncludedItems - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserAttributes): [optional] # noqa: E501 + id (str): ID of the user.. [optional] # noqa: E501 + relationships (UserResponseRelationships): [optional] # noqa: E501 + type (UsersType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -187,28 +257,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/incident_service_relationships.py b/src/datadog_api_client/v2/model/incident_service_relationships.py index 3b04da2a1d..e799129dc7 100644 --- a/src/datadog_api_client/v2/model/incident_service_relationships.py +++ b/src/datadog_api_client/v2/model/incident_service_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "last_modified_by": "last_modified_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentServiceRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_by (RelationshipToUser): [optional] # noqa: E501 + last_modified_by (RelationshipToUser): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_response.py b/src/datadog_api_client/v2/model/incident_service_response.py index ce72f67632..a2b019de40 100644 --- a/src/datadog_api_client/v2/model/incident_service_response.py +++ b/src/datadog_api_client/v2/model/incident_service_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,93 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentServiceResponse - a model defined in OpenAPI + + Args: + data (IncidentServiceResponseData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentServiceIncludedItems]): Included objects from relationships.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +263,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_response_attributes.py b/src/datadog_api_client/v2/model/incident_service_response_attributes.py index 90518d4e1e..925fb21df4 100644 --- a/src/datadog_api_client/v2/model/incident_service_response_attributes.py +++ b/src/datadog_api_client/v2/model/incident_service_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentServiceResponseAttributes(ModelNormal): @@ -80,8 +82,92 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "modified", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentServiceResponseAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Timestamp of when the incident service was created.. [optional] # noqa: E501 + modified (datetime): Timestamp of when the incident service was modified.. [optional] # noqa: E501 + name (str): Name of the incident service.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_response_data.py b/src/datadog_api_client/v2/model/incident_service_response_data.py index 31ce01cc13..450a8609aa 100644 --- a/src/datadog_api_client/v2/model/incident_service_response_data.py +++ b/src/datadog_api_client/v2/model/incident_service_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,94 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """IncidentServiceResponseData - a model defined in OpenAPI + + Args: + id (str): The incident service's ID. + type (IncidentServiceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentServiceResponseAttributes): [optional] # noqa: E501 + relationships (IncidentServiceRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +273,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_type.py b/src/datadog_api_client/v2/model/incident_service_type.py index d070b7e8ab..4a440ddafd 100644 --- a/src/datadog_api_client/v2/model/incident_service_type.py +++ b/src/datadog_api_client/v2/model/incident_service_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentServiceType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentServiceType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Incident service resource type.. if omitted defaults to "services", must be one of ["services", ] # noqa: E501 + + Keyword Args: + value (str): Incident service resource type.. if omitted defaults to "services", must be one of ["services", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "services" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_service_update_attributes.py b/src/datadog_api_client/v2/model/incident_service_update_attributes.py index 9d110699d6..21f8da285c 100644 --- a/src/datadog_api_client/v2/model/incident_service_update_attributes.py +++ b/src/datadog_api_client/v2/model/incident_service_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentServiceUpdateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """IncidentServiceUpdateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the incident service. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_update_data.py b/src/datadog_api_client/v2/model/incident_service_update_data.py index 58fe87244f..3d5db1100f 100644 --- a/src/datadog_api_client/v2/model/incident_service_update_data.py +++ b/src/datadog_api_client/v2/model/incident_service_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """IncidentServiceUpdateData - a model defined in OpenAPI + + Args: + type (IncidentServiceType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentServiceUpdateAttributes): [optional] # noqa: E501 + id (str): The incident service's ID.. [optional] # noqa: E501 + relationships (IncidentServiceRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_service_update_request.py b/src/datadog_api_client/v2/model/incident_service_update_request.py index f9feea9490..7c42dc839a 100644 --- a/src/datadog_api_client/v2/model/incident_service_update_request.py +++ b/src/datadog_api_client/v2/model/incident_service_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentServiceUpdateRequest - a model defined in OpenAPI + + Args: + data (IncidentServiceUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_services_response.py b/src/datadog_api_client/v2/model/incident_services_response.py index 4684a3108e..00a9f40264 100644 --- a/src/datadog_api_client/v2/model/incident_services_response.py +++ b/src/datadog_api_client/v2/model/incident_services_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,94 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentServicesResponse - a model defined in OpenAPI + + Args: + data ([IncidentServiceResponseData]): An array of incident services. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentServiceIncludedItems]): Included related resources which the user requested.. [optional] # noqa: E501 + meta (IncidentServicesResponseMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_services_response_meta.py b/src/datadog_api_client/v2/model/incident_services_response_meta.py index 369a60f380..6e237ee126 100644 --- a/src/datadog_api_client/v2/model/incident_services_response_meta.py +++ b/src/datadog_api_client/v2/model/incident_services_response_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,87 @@ def discriminator(): "pagination": "pagination", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentServicesResponseMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + pagination (IncidentServicesResponseMetaPagination): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +251,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_services_response_meta_pagination.py b/src/datadog_api_client/v2/model/incident_services_response_meta_pagination.py index 9b9f362010..9d513b6cba 100644 --- a/src/datadog_api_client/v2/model/incident_services_response_meta_pagination.py +++ b/src/datadog_api_client/v2/model/incident_services_response_meta_pagination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentServicesResponseMetaPagination(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "size": "size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentServicesResponseMetaPagination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + next_offset (int): The index of the first element in the next page of results. Equal to page size added to the current offset.. [optional] # noqa: E501 + offset (int): The index of the first element in the results.. [optional] # noqa: E501 + size (int): Maximum size of pages to return.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_create_attributes.py b/src/datadog_api_client/v2/model/incident_team_create_attributes.py index 1bae890905..8db0562ae1 100644 --- a/src/datadog_api_client/v2/model/incident_team_create_attributes.py +++ b/src/datadog_api_client/v2/model/incident_team_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTeamCreateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """IncidentTeamCreateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the incident team. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_create_data.py b/src/datadog_api_client/v2/model/incident_team_create_data.py index 31579ac862..e2a913b17b 100644 --- a/src/datadog_api_client/v2/model/incident_team_create_data.py +++ b/src/datadog_api_client/v2/model/incident_team_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """IncidentTeamCreateData - a model defined in OpenAPI + + Args: + type (IncidentTeamType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentTeamCreateAttributes): [optional] # noqa: E501 + relationships (IncidentTeamRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_create_request.py b/src/datadog_api_client/v2/model/incident_team_create_request.py index 73f1016fb7..5055f397e6 100644 --- a/src/datadog_api_client/v2/model/incident_team_create_request.py +++ b/src/datadog_api_client/v2/model/incident_team_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentTeamCreateRequest - a model defined in OpenAPI + + Args: + data (IncidentTeamCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_included_items.py b/src/datadog_api_client/v2/model/incident_team_included_items.py index 5fd6ea8f62..e3de4b8eaf 100644 --- a/src/datadog_api_client/v2/model/incident_team_included_items.py +++ b/src/datadog_api_client/v2/model/incident_team_included_items.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class IncidentTeamIncludedItems(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTeamIncludedItems - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserAttributes): [optional] # noqa: E501 + id (str): ID of the user.. [optional] # noqa: E501 + relationships (UserResponseRelationships): [optional] # noqa: E501 + type (UsersType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -187,28 +257,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/incident_team_relationships.py b/src/datadog_api_client/v2/model/incident_team_relationships.py index 3f5b1fe3a5..ca043376b1 100644 --- a/src/datadog_api_client/v2/model/incident_team_relationships.py +++ b/src/datadog_api_client/v2/model/incident_team_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "last_modified_by": "last_modified_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTeamRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_by (RelationshipToUser): [optional] # noqa: E501 + last_modified_by (RelationshipToUser): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_response.py b/src/datadog_api_client/v2/model/incident_team_response.py index db44fac8c4..9ba3ad51e9 100644 --- a/src/datadog_api_client/v2/model/incident_team_response.py +++ b/src/datadog_api_client/v2/model/incident_team_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,93 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentTeamResponse - a model defined in OpenAPI + + Args: + data (IncidentTeamResponseData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentTeamIncludedItems]): Included objects from relationships.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +263,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_response_attributes.py b/src/datadog_api_client/v2/model/incident_team_response_attributes.py index 8f17606004..95bb589605 100644 --- a/src/datadog_api_client/v2/model/incident_team_response_attributes.py +++ b/src/datadog_api_client/v2/model/incident_team_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTeamResponseAttributes(ModelNormal): @@ -80,8 +82,92 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created", # noqa: E501 + "modified", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTeamResponseAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Timestamp of when the incident team was created.. [optional] # noqa: E501 + modified (datetime): Timestamp of when the incident team was modified.. [optional] # noqa: E501 + name (str): Name of the incident team.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_response_data.py b/src/datadog_api_client/v2/model/incident_team_response_data.py index c7b748f8d2..979fa12b49 100644 --- a/src/datadog_api_client/v2/model/incident_team_response_data.py +++ b/src/datadog_api_client/v2/model/incident_team_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTeamResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentTeamResponseAttributes): [optional] # noqa: E501 + id (str): The incident team's ID.. [optional] # noqa: E501 + relationships (IncidentTeamRelationships): [optional] # noqa: E501 + type (IncidentTeamType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_type.py b/src/datadog_api_client/v2/model/incident_team_type.py index 66c4dce34f..c3d75d45ee 100644 --- a/src/datadog_api_client/v2/model/incident_team_type.py +++ b/src/datadog_api_client/v2/model/incident_team_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTeamType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentTeamType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Incident Team resource type.. if omitted defaults to "teams", must be one of ["teams", ] # noqa: E501 + + Keyword Args: + value (str): Incident Team resource type.. if omitted defaults to "teams", must be one of ["teams", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "teams" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_team_update_attributes.py b/src/datadog_api_client/v2/model/incident_team_update_attributes.py index 1001c0dfcc..f804f1570c 100644 --- a/src/datadog_api_client/v2/model/incident_team_update_attributes.py +++ b/src/datadog_api_client/v2/model/incident_team_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTeamUpdateAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """IncidentTeamUpdateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the incident team. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_update_data.py b/src/datadog_api_client/v2/model/incident_team_update_data.py index b0feab36fe..24136ee993 100644 --- a/src/datadog_api_client/v2/model/incident_team_update_data.py +++ b/src/datadog_api_client/v2/model/incident_team_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """IncidentTeamUpdateData - a model defined in OpenAPI + + Args: + type (IncidentTeamType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentTeamUpdateAttributes): [optional] # noqa: E501 + id (str): The incident team's ID.. [optional] # noqa: E501 + relationships (IncidentTeamRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_team_update_request.py b/src/datadog_api_client/v2/model/incident_team_update_request.py index 1e221ed20e..cb9c743c81 100644 --- a/src/datadog_api_client/v2/model/incident_team_update_request.py +++ b/src/datadog_api_client/v2/model/incident_team_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentTeamUpdateRequest - a model defined in OpenAPI + + Args: + data (IncidentTeamUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_teams_response.py b/src/datadog_api_client/v2/model/incident_teams_response.py index 89630a1974..d72cd2a5a7 100644 --- a/src/datadog_api_client/v2/model/incident_teams_response.py +++ b/src/datadog_api_client/v2/model/incident_teams_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,94 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentTeamsResponse - a model defined in OpenAPI + + Args: + data ([IncidentTeamResponseData]): An array of incident teams. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentTeamIncludedItems]): Included related resources which the user requested.. [optional] # noqa: E501 + meta (IncidentServicesResponseMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_timeline_cell_create_attributes.py b/src/datadog_api_client/v2/model/incident_timeline_cell_create_attributes.py index 7b512f3057..f906d44407 100644 --- a/src/datadog_api_client/v2/model/incident_timeline_cell_create_attributes.py +++ b/src/datadog_api_client/v2/model/incident_timeline_cell_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -68,24 +70,7 @@ class IncidentTimelineCellCreateAttributes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -107,6 +92,90 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTimelineCellCreateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + important (bool): A flag indicating whether the timeline cell is important and should be highlighted.. [optional] if omitted the server will use the default value of False # noqa: E501 + cell_type (IncidentTimelineCellMarkdownContentType): [optional] # noqa: E501 + content (IncidentTimelineCellMarkdownCreateAttributesContent): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -192,28 +261,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_content_type.py b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_content_type.py index a3b5919a8a..91be5574bd 100644 --- a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_content_type.py +++ b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_content_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTimelineCellMarkdownContentType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentTimelineCellMarkdownContentType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Markdown timeline cell.. if omitted defaults to "markdown", must be one of ["markdown", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Markdown timeline cell.. if omitted defaults to "markdown", must be one of ["markdown", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "markdown" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes.py b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes.py index 7f4e976628..f6c520dbd8 100644 --- a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes.py +++ b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,93 @@ def discriminator(): "important": "important", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, cell_type, content, *args, **kwargs): # noqa: E501 + """IncidentTimelineCellMarkdownCreateAttributes - a model defined in OpenAPI + + Args: + cell_type (IncidentTimelineCellMarkdownContentType): + content (IncidentTimelineCellMarkdownCreateAttributesContent): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + important (bool): A flag indicating whether the timeline cell is important and should be highlighted.. [optional] if omitted the server will use the default value of False # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.cell_type = cell_type + self.content = content + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +273,8 @@ def __init__(self, cell_type, content, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes_content.py b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes_content.py index 3eb4556e6f..38bf5a962a 100644 --- a/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes_content.py +++ b/src/datadog_api_client/v2/model/incident_timeline_cell_markdown_create_attributes_content.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentTimelineCellMarkdownCreateAttributesContent(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "content": "content", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentTimelineCellMarkdownCreateAttributesContent - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + content (str): The Markdown content of the cell.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_type.py b/src/datadog_api_client/v2/model/incident_type.py index e0b76588bd..bc1efa3816 100644 --- a/src/datadog_api_client/v2/model/incident_type.py +++ b/src/datadog_api_client/v2/model/incident_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class IncidentType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """IncidentType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Incident resource type.. if omitted defaults to "incidents", must be one of ["incidents", ] # noqa: E501 + + Keyword Args: + value (str): Incident resource type.. if omitted defaults to "incidents", must be one of ["incidents", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "incidents" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/incident_update_attributes.py b/src/datadog_api_client/v2/model/incident_update_attributes.py index 48302162a7..058e20c28c 100644 --- a/src/datadog_api_client/v2/model/incident_update_attributes.py +++ b/src/datadog_api_client/v2/model/incident_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,95 @@ def discriminator(): "title": "title", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + customer_impact_end (datetime, none_type): Timestamp when customers were no longer impacted by the incident.. [optional] # noqa: E501 + customer_impact_scope (str): A summary of the impact customers experienced during the incident.. [optional] # noqa: E501 + customer_impact_start (datetime, none_type): Timestamp when customers began being impacted by the incident.. [optional] # noqa: E501 + customer_impacted (bool): A flag indicating whether the incident caused customer impact.. [optional] # noqa: E501 + detected (datetime, none_type): Timestamp when the incident was detected.. [optional] # noqa: E501 + fields ({str: (IncidentFieldAttributes,)}): A condensed view of the user-defined fields for which to update selections.. [optional] # noqa: E501 + notification_handles ([str]): Notification handles that will be notified of the incident during update.. [optional] # noqa: E501 + resolved (datetime, none_type): Timestamp when the incident's state was set to resolved.. [optional] # noqa: E501 + title (str): The title of the incident, which summarizes what happened.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -204,3 +293,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_update_data.py b/src/datadog_api_client/v2/model/incident_update_data.py index 0edaa00576..60af243320 100644 --- a/src/datadog_api_client/v2/model/incident_update_data.py +++ b/src/datadog_api_client/v2/model/incident_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,94 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """IncidentUpdateData - a model defined in OpenAPI + + Args: + id (str): The team's ID. + type (IncidentType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (IncidentUpdateAttributes): [optional] # noqa: E501 + relationships (IncidentUpdateRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +273,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_update_relationships.py b/src/datadog_api_client/v2/model/incident_update_relationships.py index 405c923379..44fffa1670 100644 --- a/src/datadog_api_client/v2/model/incident_update_relationships.py +++ b/src/datadog_api_client/v2/model/incident_update_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -97,8 +99,91 @@ def discriminator(): "postmortem": "postmortem", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """IncidentUpdateRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + commander_user (RelationshipToUser): [optional] # noqa: E501 + created_by_user (RelationshipToUser): [optional] # noqa: E501 + integrations (RelationshipToIncidentIntegrationMetadatas): [optional] # noqa: E501 + last_modified_by_user (RelationshipToUser): [optional] # noqa: E501 + postmortem (RelationshipToIncidentPostmortem): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -186,3 +271,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incident_update_request.py b/src/datadog_api_client/v2/model/incident_update_request.py index 2ace93b0f8..1441e1cf6d 100644 --- a/src/datadog_api_client/v2/model/incident_update_request.py +++ b/src/datadog_api_client/v2/model/incident_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentUpdateRequest - a model defined in OpenAPI + + Args: + data (IncidentUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/incidents_response.py b/src/datadog_api_client/v2/model/incidents_response.py index 4ab52a291d..ad2803fae7 100644 --- a/src/datadog_api_client/v2/model/incidents_response.py +++ b/src/datadog_api_client/v2/model/incidents_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,94 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = { + "included", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """IncidentsResponse - a model defined in OpenAPI + + Args: + data ([IncidentResponseData]): An array of incidents. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + included ([IncidentResponseIncludedItem]): Included related resources that the user requested.. [optional] # noqa: E501 + meta (IncidentServicesResponseMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/list_application_keys_response.py b/src/datadog_api_client/v2/model/list_application_keys_response.py index 1b3605870f..cbfec20613 100644 --- a/src/datadog_api_client/v2/model/list_application_keys_response.py +++ b/src/datadog_api_client/v2/model/list_application_keys_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ListApplicationKeysResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([PartialApplicationKey]): Array of application keys.. [optional] # noqa: E501 + included ([ApplicationKeyResponseIncludedItem]): Array of objects related to the application key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/log.py b/src/datadog_api_client/v2/model/log.py index 19fd89252a..17bc1e3916 100644 --- a/src/datadog_api_client/v2/model/log.py +++ b/src/datadog_api_client/v2/model/log.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Log - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (LogAttributes): [optional] # noqa: E501 + id (str): Unique ID of the Log.. [optional] # noqa: E501 + type (LogType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/log_attributes.py b/src/datadog_api_client/v2/model/log_attributes.py index f2c269c959..e60b5c8b49 100644 --- a/src/datadog_api_client/v2/model/log_attributes.py +++ b/src/datadog_api_client/v2/model/log_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogAttributes(ModelNormal): @@ -88,8 +90,93 @@ def discriminator(): "timestamp": "timestamp", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): JSON object of attributes from your log.. [optional] # noqa: E501 + host (str): Name of the machine from where the logs are being sent.. [optional] # noqa: E501 + message (str): The message [reserved attribute](https://docs.datadoghq.com/logs/log_collection/#reserved-attributes) of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry. That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.. [optional] # noqa: E501 + service (str): The name of the application or service generating the log events. It is used to switch from Logs to APM, so make sure you define the same value when you use both products.. [optional] # noqa: E501 + status (str): Status of the message associated with your log.. [optional] # noqa: E501 + tags ([str]): Array of tags associated with your log.. [optional] # noqa: E501 + timestamp (datetime): Timestamp of your log.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +266,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/log_type.py b/src/datadog_api_client/v2/model/log_type.py index 429b28cd8e..cac1524d55 100644 --- a/src/datadog_api_client/v2/model/log_type.py +++ b/src/datadog_api_client/v2/model/log_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the event.. if omitted defaults to "log", must be one of ["log", ] # noqa: E501 + + Keyword Args: + value (str): Type of the event.. if omitted defaults to "log", must be one of ["log", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "log" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_aggregate_bucket.py b/src/datadog_api_client/v2/model/logs_aggregate_bucket.py index e4bbf6b586..2176f1b896 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_bucket.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_bucket.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "computes": "computes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateBucket - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + by ({str: (str,)}): The key, value pairs for each group by. [optional] # noqa: E501 + computes ({str: (LogsAggregateBucketValue,)}): A map of the metric name -> value for regular compute or list of values for a timeseries. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value.py b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value.py index 954404492d..335c83ebaa 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -56,24 +58,7 @@ class LogsAggregateBucketValue(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -95,6 +80,87 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateBucketValue - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -177,28 +243,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries.py b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries.py index 85de0a61e2..17a866bf2b 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -79,6 +81,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -165,9 +169,92 @@ def __init__(self, *args, **kwargs): valid_classes=(self.__class__,), ) - if not isinstance(value, list): + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsAggregateBucketValueTimeseries - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ([LogsAggregateBucketValueTimeseriesPoint]): A timeseries array. # noqa: E501 + + Keyword Args: + value ([LogsAggregateBucketValueTimeseriesPoint]): A timeseries array. # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: raise ApiTypeError( - "Invalid non-list arguments=%s passed to %s." + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, @@ -193,3 +280,5 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries_point.py b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries_point.py index 90e74f730b..858e9aaada 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries_point.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_bucket_value_timeseries_point.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsAggregateBucketValueTimeseriesPoint(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "value": "value", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateBucketValueTimeseriesPoint - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + time (str): The time value for this point. [optional] # noqa: E501 + value (float): The value for this point. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_request.py b/src/datadog_api_client/v2/model/logs_aggregate_request.py index f6184be188..77360c2d5e 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_request.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,91 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + compute ([LogsCompute]): The list of metrics or timeseries to compute for the retrieved buckets.. [optional] # noqa: E501 + filter (LogsQueryFilter): [optional] # noqa: E501 + group_by ([LogsGroupBy]): The rules for the group by. [optional] # noqa: E501 + options (LogsQueryOptions): [optional] # noqa: E501 + page (LogsAggregateRequestPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +273,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_request_page.py b/src/datadog_api_client/v2/model/logs_aggregate_request_page.py index 46a36ca277..2e49a89925 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_request_page.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_request_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsAggregateRequestPage(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "cursor": "cursor", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateRequestPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cursor (str): The returned paging point to use to get the next results. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_response.py b/src/datadog_api_client/v2/model/logs_aggregate_response.py index e8a25ca428..58510885c9 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_response.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (LogsAggregateResponseData): [optional] # noqa: E501 + meta (LogsResponseMetadata): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_response_data.py b/src/datadog_api_client/v2/model/logs_aggregate_response_data.py index 0c71ec73aa..a58b7b7dc8 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_response_data.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "buckets": "buckets", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + buckets ([LogsAggregateBucket]): The list of matching buckets, one item per bucket. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_response_status.py b/src/datadog_api_client/v2/model/logs_aggregate_response_status.py index 42bdfa259d..7dc4427c1e 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_response_status.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_response_status.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsAggregateResponseStatus(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsAggregateResponseStatus - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The status of the response., must be one of ["done", "timeout", ] # noqa: E501 + + Keyword Args: + value (str): The status of the response., must be one of ["done", "timeout", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_aggregate_sort.py b/src/datadog_api_client/v2/model/logs_aggregate_sort.py index d232fa6cf4..b5199fc167 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_sort.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsAggregateSort - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregation (LogsAggregationFunction): [optional] # noqa: E501 + metric (str): The metric to sort by (only used for `type=measure`). [optional] # noqa: E501 + order (LogsSortOrder): [optional] # noqa: E501 + type (LogsAggregateSortType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_aggregate_sort_type.py b/src/datadog_api_client/v2/model/logs_aggregate_sort_type.py index c6ef8b3a32..c689045cba 100644 --- a/src/datadog_api_client/v2/model/logs_aggregate_sort_type.py +++ b/src/datadog_api_client/v2/model/logs_aggregate_sort_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsAggregateSortType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsAggregateSortType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of sorting algorithm. if omitted defaults to "alphabetical", must be one of ["alphabetical", "measure", ] # noqa: E501 + + Keyword Args: + value (str): The type of sorting algorithm. if omitted defaults to "alphabetical", must be one of ["alphabetical", "measure", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "alphabetical" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_aggregation_function.py b/src/datadog_api_client/v2/model/logs_aggregation_function.py index db8cf6e888..0315d297af 100644 --- a/src/datadog_api_client/v2/model/logs_aggregation_function.py +++ b/src/datadog_api_client/v2/model/logs_aggregation_function.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsAggregationFunction(ModelSimple): @@ -84,6 +86,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -187,3 +191,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsAggregationFunction - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): An aggregation function., must be one of ["count", "cardinality", "pc75", "pc90", "pc95", "pc98", "pc99", "sum", "min", "max", "avg", ] # noqa: E501 + + Keyword Args: + value (str): An aggregation function., must be one of ["count", "cardinality", "pc75", "pc90", "pc95", "pc98", "pc99", "sum", "min", "max", "avg", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archive.py b/src/datadog_api_client/v2/model/logs_archive.py index 5fb3cdc4bf..88b2eaa8a3 100644 --- a/src/datadog_api_client/v2/model/logs_archive.py +++ b/src/datadog_api_client/v2/model/logs_archive.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchive - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (LogsArchiveDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_attributes.py b/src/datadog_api_client/v2/model/logs_archive_attributes.py index 075e6dc7f8..e797fc799d 100644 --- a/src/datadog_api_client/v2/model/logs_archive_attributes.py +++ b/src/datadog_api_client/v2/model/logs_archive_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,97 @@ def discriminator(): "state": "state", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, destination, name, query, *args, **kwargs): # noqa: E501 + """LogsArchiveAttributes - a model defined in OpenAPI + + Args: + destination (LogsArchiveDestination): + name (str): The archive name. + query (str): The archive query/filter. Logs matching this query are included in the archive. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_tags (bool): To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.. [optional] if omitted the server will use the default value of False # noqa: E501 + rehydration_tags ([str]): An array of tags to add to rehydrated logs from an archive.. [optional] # noqa: E501 + state (LogsArchiveState): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.destination = destination + self.name = name + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -190,3 +281,8 @@ def __init__(self, destination, name, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_create_request.py b/src/datadog_api_client/v2/model/logs_archive_create_request.py index 03280f10c6..18c67ddff3 100644 --- a/src/datadog_api_client/v2/model/logs_archive_create_request.py +++ b/src/datadog_api_client/v2/model/logs_archive_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveCreateRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (LogsArchiveCreateRequestDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_create_request_attributes.py b/src/datadog_api_client/v2/model/logs_archive_create_request_attributes.py index 30653a42a5..d1d7eb8325 100644 --- a/src/datadog_api_client/v2/model/logs_archive_create_request_attributes.py +++ b/src/datadog_api_client/v2/model/logs_archive_create_request_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,96 @@ def discriminator(): "rehydration_tags": "rehydration_tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, destination, name, query, *args, **kwargs): # noqa: E501 + """LogsArchiveCreateRequestAttributes - a model defined in OpenAPI + + Args: + destination (LogsArchiveCreateRequestDestination): + name (str): The archive name. + query (str): The archive query/filter. Logs matching this query are included in the archive. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_tags (bool): To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.. [optional] if omitted the server will use the default value of False # noqa: E501 + rehydration_tags ([str]): An array of tags to add to rehydrated logs from an archive.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.destination = destination + self.name = name + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -185,3 +275,8 @@ def __init__(self, destination, name, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_create_request_definition.py b/src/datadog_api_client/v2/model/logs_archive_create_request_definition.py index 55c0b6ee1f..df695fc5af 100644 --- a/src/datadog_api_client/v2/model/logs_archive_create_request_definition.py +++ b/src/datadog_api_client/v2/model/logs_archive_create_request_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "attributes": "attributes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveCreateRequestDefinition - a model defined in OpenAPI + + Args: + + Keyword Args: + type (str): The type of the resource. The value should always be archives.. defaults to "archives" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (LogsArchiveCreateRequestAttributes): [optional] # noqa: E501 + """ + + type = kwargs.get("type", "archives") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_create_request_destination.py b/src/datadog_api_client/v2/model/logs_archive_create_request_destination.py index 49d8e40caa..cc74d4954c 100644 --- a/src/datadog_api_client/v2/model/logs_archive_create_request_destination.py +++ b/src/datadog_api_client/v2/model/logs_archive_create_request_destination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -64,24 +66,7 @@ class LogsArchiveCreateRequestDestination(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -103,6 +88,94 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveCreateRequestDestination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The archive path.. [optional] # noqa: E501 + region (str): The region where the archive will be stored.. [optional] # noqa: E501 + container (str): The container where the archive will be stored.. [optional] # noqa: E501 + integration (LogsArchiveIntegrationS3): [optional] # noqa: E501 + storage_account (str): The associated storage account.. [optional] # noqa: E501 + type (LogsArchiveDestinationS3Type): [optional] # noqa: E501 + bucket (str): The bucket where the archive will be stored.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -192,28 +265,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/logs_archive_definition.py b/src/datadog_api_client/v2/model/logs_archive_definition.py index 66a4982e25..0934b9f243 100644 --- a/src/datadog_api_client/v2/model/logs_archive_definition.py +++ b/src/datadog_api_client/v2/model/logs_archive_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,96 @@ def discriminator(): "id": "id", # noqa: E501 } + read_only_vars = { + "type", # noqa: E501 + "id", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveDefinition - a model defined in OpenAPI + + Args: + + Keyword Args: + type (str): The type of the resource. The value should always be archives.. defaults to "archives" # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (LogsArchiveAttributes): [optional] # noqa: E501 + id (str): The archive ID.. [optional] # noqa: E501 + """ + + type = kwargs.get("type", "archives") + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -104,10 +194,7 @@ def discriminator(): def __init__(self, *args, **kwargs): # noqa: E501 """LogsArchiveDefinition - a model defined in OpenAPI - Args: - Keyword Args: - type (str): The type of the resource. The value should always be archives.. defaults to "archives" # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -142,7 +229,6 @@ def __init__(self, *args, **kwargs): # noqa: E501 id (str): The archive ID.. [optional] # noqa: E501 """ - type = kwargs.get("type", "archives") _check_type = kwargs.pop("_check_type", True) _spec_property_naming = kwargs.pop("_spec_property_naming", False) _path_to_item = kwargs.pop("_path_to_item", ()) @@ -167,7 +253,6 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - self.type = type for var_name, var_value in kwargs.items(): if ( var_name not in self.attribute_map @@ -178,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_destination.py b/src/datadog_api_client/v2/model/logs_archive_destination.py index 0ed4150c74..8e7697ef3e 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -64,24 +66,7 @@ class LogsArchiveDestination(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = True @@ -103,6 +88,94 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveDestination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The archive path.. [optional] # noqa: E501 + region (str): The region where the archive will be stored.. [optional] # noqa: E501 + container (str): The container where the archive will be stored.. [optional] # noqa: E501 + integration (LogsArchiveIntegrationS3): [optional] # noqa: E501 + storage_account (str): The associated storage account.. [optional] # noqa: E501 + type (LogsArchiveDestinationS3Type): [optional] # noqa: E501 + bucket (str): The bucket where the archive will be stored.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -192,28 +265,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_azure.py b/src/datadog_api_client/v2/model/logs_archive_destination_azure.py index d9021c65cb..e13402412e 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_azure.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_azure.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,98 @@ def discriminator(): "region": "region", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, container, integration, storage_account, type, *args, **kwargs): # noqa: E501 + """LogsArchiveDestinationAzure - a model defined in OpenAPI + + Args: + container (str): The container where the archive will be stored. + integration (LogsArchiveIntegrationAzure): + storage_account (str): The associated storage account. + type (LogsArchiveDestinationAzureType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The archive path.. [optional] # noqa: E501 + region (str): The region where the archive will be stored.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.container = container + self.integration = integration + self.storage_account = storage_account + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -191,3 +283,8 @@ def __init__(self, container, integration, storage_account, type, *args, **kwarg # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_azure_type.py b/src/datadog_api_client/v2/model/logs_archive_destination_azure_type.py index f13af0d063..a148121db8 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_azure_type.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_azure_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveDestinationAzureType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArchiveDestinationAzureType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the Azure archive destination.. if omitted defaults to "azure", must be one of ["azure", ] # noqa: E501 + + Keyword Args: + value (str): Type of the Azure archive destination.. if omitted defaults to "azure", must be one of ["azure", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "azure" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_gcs.py b/src/datadog_api_client/v2/model/logs_archive_destination_gcs.py index 47dc852e6b..2b3c14eea2 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_gcs.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_gcs.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "path": "path", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, bucket, integration, type, *args, **kwargs): # noqa: E501 + """LogsArchiveDestinationGCS - a model defined in OpenAPI + + Args: + bucket (str): The bucket where the archive will be stored. + integration (LogsArchiveIntegrationGCS): + type (LogsArchiveDestinationGCSType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The archive path.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.bucket = bucket + self.integration = integration + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, bucket, integration, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_gcs_type.py b/src/datadog_api_client/v2/model/logs_archive_destination_gcs_type.py index d838b417de..c2144037ea 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_gcs_type.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_gcs_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveDestinationGCSType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArchiveDestinationGCSType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the GCS archive destination.. if omitted defaults to "gcs", must be one of ["gcs", ] # noqa: E501 + + Keyword Args: + value (str): Type of the GCS archive destination.. if omitted defaults to "gcs", must be one of ["gcs", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "gcs" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_s3.py b/src/datadog_api_client/v2/model/logs_archive_destination_s3.py index 7774b30561..c46d0b4c0a 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_s3.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_s3.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,95 @@ def discriminator(): "path": "path", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, bucket, integration, type, *args, **kwargs): # noqa: E501 + """LogsArchiveDestinationS3 - a model defined in OpenAPI + + Args: + bucket (str): The bucket where the archive will be stored. + integration (LogsArchiveIntegrationS3): + type (LogsArchiveDestinationS3Type): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The archive path.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.bucket = bucket + self.integration = integration + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +273,8 @@ def __init__(self, bucket, integration, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_destination_s3_type.py b/src/datadog_api_client/v2/model/logs_archive_destination_s3_type.py index 4486c6072f..b96509b60d 100644 --- a/src/datadog_api_client/v2/model/logs_archive_destination_s3_type.py +++ b/src/datadog_api_client/v2/model/logs_archive_destination_s3_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveDestinationS3Type(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArchiveDestinationS3Type - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the S3 archive destination.. if omitted defaults to "s3", must be one of ["s3", ] # noqa: E501 + + Keyword Args: + value (str): Type of the S3 archive destination.. if omitted defaults to "s3", must be one of ["s3", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "s3" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archive_integration_azure.py b/src/datadog_api_client/v2/model/logs_archive_integration_azure.py index 77be63f245..e6ea8c6848 100644 --- a/src/datadog_api_client/v2/model/logs_archive_integration_azure.py +++ b/src/datadog_api_client/v2/model/logs_archive_integration_azure.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveIntegrationAzure(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "tenant_id": "tenant_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, client_id, tenant_id, *args, **kwargs): # noqa: E501 + """LogsArchiveIntegrationAzure - a model defined in OpenAPI + + Args: + client_id (str): A client ID. + tenant_id (str): A tenant ID. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.client_id = client_id + self.tenant_id = tenant_id + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, client_id, tenant_id, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_integration_gcs.py b/src/datadog_api_client/v2/model/logs_archive_integration_gcs.py index 51ca0ec0a4..059b5addd3 100644 --- a/src/datadog_api_client/v2/model/logs_archive_integration_gcs.py +++ b/src/datadog_api_client/v2/model/logs_archive_integration_gcs.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveIntegrationGCS(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "project_id": "project_id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, client_email, project_id, *args, **kwargs): # noqa: E501 + """LogsArchiveIntegrationGCS - a model defined in OpenAPI + + Args: + client_email (str): A client email. + project_id (str): A project ID. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.client_email = client_email + self.project_id = project_id + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, client_email, project_id, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_integration_s3.py b/src/datadog_api_client/v2/model/logs_archive_integration_s3.py index 80eb7bb9db..8a02d115ec 100644 --- a/src/datadog_api_client/v2/model/logs_archive_integration_s3.py +++ b/src/datadog_api_client/v2/model/logs_archive_integration_s3.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveIntegrationS3(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "role_name": "role_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, account_id, role_name, *args, **kwargs): # noqa: E501 + """LogsArchiveIntegrationS3 - a model defined in OpenAPI + + Args: + account_id (str): The account ID for the integration. + role_name (str): The path of the integration. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.account_id = account_id + self.role_name = role_name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, account_id, role_name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_order.py b/src/datadog_api_client/v2/model/logs_archive_order.py index 43d3aac510..5ca346a880 100644 --- a/src/datadog_api_client/v2/model/logs_archive_order.py +++ b/src/datadog_api_client/v2/model/logs_archive_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchiveOrder - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (LogsArchiveOrderDefinition): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_order_attributes.py b/src/datadog_api_client/v2/model/logs_archive_order_attributes.py index cccba49cd0..2679e5a95f 100644 --- a/src/datadog_api_client/v2/model/logs_archive_order_attributes.py +++ b/src/datadog_api_client/v2/model/logs_archive_order_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveOrderAttributes(ModelNormal): @@ -76,8 +78,90 @@ def discriminator(): "archive_ids": "archive_ids", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, archive_ids, *args, **kwargs): # noqa: E501 + """LogsArchiveOrderAttributes - a model defined in OpenAPI + + Args: + archive_ids ([str]): An ordered array of `` strings, the order of archive IDs in the array define the overall archives order for Datadog. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.archive_ids = archive_ids + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +248,8 @@ def __init__(self, archive_ids, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_order_definition.py b/src/datadog_api_client/v2/model/logs_archive_order_definition.py index 89e1dc32d8..bd36097aae 100644 --- a/src/datadog_api_client/v2/model/logs_archive_order_definition.py +++ b/src/datadog_api_client/v2/model/logs_archive_order_definition.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """LogsArchiveOrderDefinition - a model defined in OpenAPI + + Args: + attributes (LogsArchiveOrderAttributes): + type (LogsArchiveOrderDefinitionType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_archive_order_definition_type.py b/src/datadog_api_client/v2/model/logs_archive_order_definition_type.py index 7d7a9f748c..bdeba32465 100644 --- a/src/datadog_api_client/v2/model/logs_archive_order_definition_type.py +++ b/src/datadog_api_client/v2/model/logs_archive_order_definition_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveOrderDefinitionType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArchiveOrderDefinitionType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of the archive order definition.. if omitted defaults to "archive_order", must be one of ["archive_order", ] # noqa: E501 + + Keyword Args: + value (str): Type of the archive order definition.. if omitted defaults to "archive_order", must be one of ["archive_order", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "archive_order" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archive_state.py b/src/datadog_api_client/v2/model/logs_archive_state.py index 7de8d4df24..f2052e9036 100644 --- a/src/datadog_api_client/v2/model/logs_archive_state.py +++ b/src/datadog_api_client/v2/model/logs_archive_state.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsArchiveState(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -180,3 +184,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsArchiveState - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The state of the archive.., must be one of ["UNKNOWN", "WORKING", "FAILING", "WORKING_AUTH_LEGACY", ] # noqa: E501 + + Keyword Args: + value (str): The state of the archive.., must be one of ["UNKNOWN", "WORKING", "FAILING", "WORKING_AUTH_LEGACY", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_archives.py b/src/datadog_api_client/v2/model/logs_archives.py index e2205d8a48..07d6025b16 100644 --- a/src/datadog_api_client/v2/model/logs_archives.py +++ b/src/datadog_api_client/v2/model/logs_archives.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsArchives - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([LogsArchiveDefinition]): A list of archives.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_compute.py b/src/datadog_api_client/v2/model/logs_compute.py index 8684928770..9218b5b6e3 100644 --- a/src/datadog_api_client/v2/model/logs_compute.py +++ b/src/datadog_api_client/v2/model/logs_compute.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation, *args, **kwargs): # noqa: E501 + """LogsCompute - a model defined in OpenAPI + + Args: + aggregation (LogsAggregationFunction): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + interval (str): The time buckets' size (only used for type=timeseries) Defaults to a resolution of 150 points. [optional] # noqa: E501 + metric (str): The metric to use. [optional] # noqa: E501 + type (LogsComputeType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation = aggregation + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, aggregation, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_compute_type.py b/src/datadog_api_client/v2/model/logs_compute_type.py index fcc02a75b6..436376848b 100644 --- a/src/datadog_api_client/v2/model/logs_compute_type.py +++ b/src/datadog_api_client/v2/model/logs_compute_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsComputeType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsComputeType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of compute. if omitted defaults to "total", must be one of ["timeseries", "total", ] # noqa: E501 + + Keyword Args: + value (str): The type of compute. if omitted defaults to "total", must be one of ["timeseries", "total", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "total" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_group_by.py b/src/datadog_api_client/v2/model/logs_group_by.py index 45528590a1..bb904fb05e 100644 --- a/src/datadog_api_client/v2/model/logs_group_by.py +++ b/src/datadog_api_client/v2/model/logs_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,95 @@ def discriminator(): "total": "total", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, facet, *args, **kwargs): # noqa: E501 + """LogsGroupBy - a model defined in OpenAPI + + Args: + facet (str): The name of the facet to use (required) + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + histogram (LogsGroupByHistogram): [optional] # noqa: E501 + limit (int): The maximum buckets to return for this group by. [optional] if omitted the server will use the default value of 10 # noqa: E501 + missing (LogsGroupByMissing): [optional] # noqa: E501 + sort (LogsAggregateSort): [optional] # noqa: E501 + total (LogsGroupByTotal): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.facet = facet + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -192,3 +281,8 @@ def __init__(self, facet, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_group_by_histogram.py b/src/datadog_api_client/v2/model/logs_group_by_histogram.py index dff0e1e1a5..50cf404f3f 100644 --- a/src/datadog_api_client/v2/model/logs_group_by_histogram.py +++ b/src/datadog_api_client/v2/model/logs_group_by_histogram.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsGroupByHistogram(ModelNormal): @@ -80,8 +82,94 @@ def discriminator(): "min": "min", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, interval, max, min, *args, **kwargs): # noqa: E501 + """LogsGroupByHistogram - a model defined in OpenAPI + + Args: + interval (float): The bin size of the histogram buckets + max (float): The maximum value for the measure used in the histogram (values greater than this one are filtered out) + min (float): The minimum value for the measure used in the histogram (values smaller than this one are filtered out) + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.interval = interval + self.max = max + self.min = min + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +260,8 @@ def __init__(self, interval, max, min, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_group_by_missing.py b/src/datadog_api_client/v2/model/logs_group_by_missing.py index ea5cf925bf..adae6db6b3 100644 --- a/src/datadog_api_client/v2/model/logs_group_by_missing.py +++ b/src/datadog_api_client/v2/model/logs_group_by_missing.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsGroupByMissing(ModelNormal): @@ -50,23 +52,7 @@ class LogsGroupByMissing(ModelNormal): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -88,8 +74,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsGroupByMissing - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +236,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_group_by_total.py b/src/datadog_api_client/v2/model/logs_group_by_total.py index 3476d2f6db..8aceac6703 100644 --- a/src/datadog_api_client/v2/model/logs_group_by_total.py +++ b/src/datadog_api_client/v2/model/logs_group_by_total.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsGroupByTotal(ModelNormal): @@ -50,23 +52,7 @@ class LogsGroupByTotal(ModelNormal): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -88,8 +74,86 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsGroupByTotal - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +236,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_list_request.py b/src/datadog_api_client/v2/model/logs_list_request.py index 43bb444baf..752c5e0ba1 100644 --- a/src/datadog_api_client/v2/model/logs_list_request.py +++ b/src/datadog_api_client/v2/model/logs_list_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,90 @@ def discriminator(): "sort": "sort", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsListRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsQueryFilter): [optional] # noqa: E501 + options (LogsQueryOptions): [optional] # noqa: E501 + page (LogsListRequestPage): [optional] # noqa: E501 + sort (LogsSort): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_list_request_page.py b/src/datadog_api_client/v2/model/logs_list_request_page.py index 1a39ee4b48..99d4686577 100644 --- a/src/datadog_api_client/v2/model/logs_list_request_page.py +++ b/src/datadog_api_client/v2/model/logs_list_request_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsListRequestPage(ModelNormal): @@ -82,8 +84,88 @@ def discriminator(): "limit": "limit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsListRequestPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cursor (str): List following results with a cursor provided in the previous query.. [optional] # noqa: E501 + limit (int): Maximum number of logs in the response.. [optional] if omitted the server will use the default value of 10 # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_list_response.py b/src/datadog_api_client/v2/model/logs_list_response.py index 3eb1f52027..34f8c7b4ff 100644 --- a/src/datadog_api_client/v2/model/logs_list_response.py +++ b/src/datadog_api_client/v2/model/logs_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([Log]): Array of logs matching the request.. [optional] # noqa: E501 + links (LogsListResponseLinks): [optional] # noqa: E501 + meta (LogsResponseMetadata): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_list_response_links.py b/src/datadog_api_client/v2/model/logs_list_response_links.py index f88d4f1fca..48d9bed80d 100644 --- a/src/datadog_api_client/v2/model/logs_list_response_links.py +++ b/src/datadog_api_client/v2/model/logs_list_response_links.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsListResponseLinks(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "next": "next", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsListResponseLinks - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + next (str): Link for the next set of results. Note that the request can also be made using the POST endpoint.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_compute.py b/src/datadog_api_client/v2/model/logs_metric_compute.py index cd8ebb5294..4a9034f19d 100644 --- a/src/datadog_api_client/v2/model/logs_metric_compute.py +++ b/src/datadog_api_client/v2/model/logs_metric_compute.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,91 @@ def discriminator(): "path": "path", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, aggregation_type, *args, **kwargs): # noqa: E501 + """LogsMetricCompute - a model defined in OpenAPI + + Args: + aggregation_type (LogsMetricComputeAggregationType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The path to the value the log-based metric will aggregate on (only used if the aggregation type is a \"distribution\").. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.aggregation_type = aggregation_type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -174,3 +259,8 @@ def __init__(self, aggregation_type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_compute_aggregation_type.py b/src/datadog_api_client/v2/model/logs_metric_compute_aggregation_type.py index 3d22400a75..b0b5a03793 100644 --- a/src/datadog_api_client/v2/model/logs_metric_compute_aggregation_type.py +++ b/src/datadog_api_client/v2/model/logs_metric_compute_aggregation_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricComputeAggregationType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsMetricComputeAggregationType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of aggregation to use.., must be one of ["count", "distribution", ] # noqa: E501 + + Keyword Args: + value (str): The type of aggregation to use.., must be one of ["count", "distribution", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_metric_create_attributes.py b/src/datadog_api_client/v2/model/logs_metric_create_attributes.py index da4f4dc49e..efc4261665 100644 --- a/src/datadog_api_client/v2/model/logs_metric_create_attributes.py +++ b/src/datadog_api_client/v2/model/logs_metric_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "group_by": "group_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, compute, *args, **kwargs): # noqa: E501 + """LogsMetricCreateAttributes - a model defined in OpenAPI + + Args: + compute (LogsMetricCompute): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsMetricFilter): [optional] # noqa: E501 + group_by ([LogsMetricGroupBy]): The rules for the group by.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.compute = compute + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, compute, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_create_data.py b/src/datadog_api_client/v2/model/logs_metric_create_data.py index 68df8b998e..3d351009e6 100644 --- a/src/datadog_api_client/v2/model/logs_metric_create_data.py +++ b/src/datadog_api_client/v2/model/logs_metric_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """LogsMetricCreateData - a model defined in OpenAPI + + Args: + attributes (LogsMetricCreateAttributes): + id (str): The name of the log-based metric. + type (LogsMetricType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_create_request.py b/src/datadog_api_client/v2/model/logs_metric_create_request.py index 80d3416f7e..75f4139d54 100644 --- a/src/datadog_api_client/v2/model/logs_metric_create_request.py +++ b/src/datadog_api_client/v2/model/logs_metric_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """LogsMetricCreateRequest - a model defined in OpenAPI + + Args: + data (LogsMetricCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_filter.py b/src/datadog_api_client/v2/model/logs_metric_filter.py index dec2d68bcd..27e96082f4 100644 --- a/src/datadog_api_client/v2/model/logs_metric_filter.py +++ b/src/datadog_api_client/v2/model/logs_metric_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricFilter(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + query (str): The search query - following the log search syntax.. [optional] if omitted the server will use the default value of "*" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_group_by.py b/src/datadog_api_client/v2/model/logs_metric_group_by.py index 2b972731df..bc41c902fb 100644 --- a/src/datadog_api_client/v2/model/logs_metric_group_by.py +++ b/src/datadog_api_client/v2/model/logs_metric_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricGroupBy(ModelNormal): @@ -78,8 +80,91 @@ def discriminator(): "tag_name": "tag_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, path, *args, **kwargs): # noqa: E501 + """LogsMetricGroupBy - a model defined in OpenAPI + + Args: + path (str): The path to the value the log-based metric will be aggregated over. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tag_name (str): Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.path = path + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +252,8 @@ def __init__(self, path, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response.py b/src/datadog_api_client/v2/model/logs_metric_response.py index 8741231be4..089e490230 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response.py +++ b/src/datadog_api_client/v2/model/logs_metric_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (LogsMetricResponseData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response_attributes.py b/src/datadog_api_client/v2/model/logs_metric_response_attributes.py index 8ddda237c2..9d72d366c9 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_attributes.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "group_by": "group_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponseAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + compute (LogsMetricResponseCompute): [optional] # noqa: E501 + filter (LogsMetricResponseFilter): [optional] # noqa: E501 + group_by ([LogsMetricResponseGroupBy]): The rules for the group by.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response_compute.py b/src/datadog_api_client/v2/model/logs_metric_response_compute.py index 1be68a1c07..b68a05b962 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_compute.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_compute.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "path": "path", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponseCompute - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + aggregation_type (LogsMetricResponseComputeAggregationType): [optional] # noqa: E501 + path (str): The path to the value the log-based metric will aggregate on (only used if the aggregation type is a \"distribution\").. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response_compute_aggregation_type.py b/src/datadog_api_client/v2/model/logs_metric_response_compute_aggregation_type.py index 483f4c7bfd..c08e8f1820 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_compute_aggregation_type.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_compute_aggregation_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricResponseComputeAggregationType(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsMetricResponseComputeAggregationType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of aggregation to use.., must be one of ["count", "distribution", ] # noqa: E501 + + Keyword Args: + value (str): The type of aggregation to use.., must be one of ["count", "distribution", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_metric_response_data.py b/src/datadog_api_client/v2/model/logs_metric_response_data.py index 26b6e800da..049dc5493f 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_data.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (LogsMetricResponseAttributes): [optional] # noqa: E501 + id (str): The name of the log-based metric.. [optional] # noqa: E501 + type (LogsMetricType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response_filter.py b/src/datadog_api_client/v2/model/logs_metric_response_filter.py index ccf6134cd5..f8f6516951 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_filter.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricResponseFilter(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponseFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + query (str): The search query - following the log search syntax.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_response_group_by.py b/src/datadog_api_client/v2/model/logs_metric_response_group_by.py index de9f31bf81..6f9faad82c 100644 --- a/src/datadog_api_client/v2/model/logs_metric_response_group_by.py +++ b/src/datadog_api_client/v2/model/logs_metric_response_group_by.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricResponseGroupBy(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "tag_name": "tag_name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricResponseGroupBy - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + path (str): The path to the value the log-based metric will be aggregated over.. [optional] # noqa: E501 + tag_name (str): Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_type.py b/src/datadog_api_client/v2/model/logs_metric_type.py index 2e50258613..ed5a06dd75 100644 --- a/src/datadog_api_client/v2/model/logs_metric_type.py +++ b/src/datadog_api_client/v2/model/logs_metric_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsMetricType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsMetricType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of the resource. The value should always be logs_metrics.. if omitted defaults to "logs_metrics", must be one of ["logs_metrics", ] # noqa: E501 + + Keyword Args: + value (str): The type of the resource. The value should always be logs_metrics.. if omitted defaults to "logs_metrics", must be one of ["logs_metrics", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "logs_metrics" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_metric_update_attributes.py b/src/datadog_api_client/v2/model/logs_metric_update_attributes.py index 12cd26384a..6505ad6bc6 100644 --- a/src/datadog_api_client/v2/model/logs_metric_update_attributes.py +++ b/src/datadog_api_client/v2/model/logs_metric_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "group_by": "group_by", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (LogsMetricFilter): [optional] # noqa: E501 + group_by ([LogsMetricGroupBy]): The rules for the group by.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_update_data.py b/src/datadog_api_client/v2/model/logs_metric_update_data.py index fa12249c08..64e11030a1 100644 --- a/src/datadog_api_client/v2/model/logs_metric_update_data.py +++ b/src/datadog_api_client/v2/model/logs_metric_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """LogsMetricUpdateData - a model defined in OpenAPI + + Args: + attributes (LogsMetricUpdateAttributes): + type (LogsMetricType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metric_update_request.py b/src/datadog_api_client/v2/model/logs_metric_update_request.py index a91d2a7634..f61d9c485f 100644 --- a/src/datadog_api_client/v2/model/logs_metric_update_request.py +++ b/src/datadog_api_client/v2/model/logs_metric_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """LogsMetricUpdateRequest - a model defined in OpenAPI + + Args: + data (LogsMetricUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_metrics_response.py b/src/datadog_api_client/v2/model/logs_metrics_response.py index deef61561c..fb2646d318 100644 --- a/src/datadog_api_client/v2/model/logs_metrics_response.py +++ b/src/datadog_api_client/v2/model/logs_metrics_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsMetricsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([LogsMetricResponseData]): A list of log-based metric objects.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_query_filter.py b/src/datadog_api_client/v2/model/logs_query_filter.py index c1859b7408..37d1c3bc82 100644 --- a/src/datadog_api_client/v2/model/logs_query_filter.py +++ b/src/datadog_api_client/v2/model/logs_query_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsQueryFilter(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "to": "to", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsQueryFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _from (str): The minimum time for the requested logs, supports date math and regular timestamps. [optional] if omitted the server will use the default value of "now-15m" # noqa: E501 + indexes ([str]): For customers with multiple indexes, the indexes to search. Defaults to ['*'] which means all indexes.. [optional] if omitted the server will use the default value of ["*"] # noqa: E501 + query (str): The search query - following the log search syntax.. [optional] if omitted the server will use the default value of "*" # noqa: E501 + to (str): The maximum time for the requested logs, supports date math and regular timestamps. [optional] if omitted the server will use the default value of "now" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_query_options.py b/src/datadog_api_client/v2/model/logs_query_options.py index 8ea91b5b1c..fe5b0819ad 100644 --- a/src/datadog_api_client/v2/model/logs_query_options.py +++ b/src/datadog_api_client/v2/model/logs_query_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsQueryOptions(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "timezone": "timezone", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsQueryOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + time_offset (int): The time offset (in seconds) to apply to the query.. [optional] # noqa: E501 + timezone (str): The timezone can be specified both as an offset, for example: \"UTC+03:00\".. [optional] if omitted the server will use the default value of "UTC" # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_response_metadata.py b/src/datadog_api_client/v2/model/logs_response_metadata.py index eef836b11d..b59dae1372 100644 --- a/src/datadog_api_client/v2/model/logs_response_metadata.py +++ b/src/datadog_api_client/v2/model/logs_response_metadata.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,91 @@ def discriminator(): "warnings": "warnings", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsResponseMetadata - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + elapsed (int): The time elapsed in milliseconds. [optional] # noqa: E501 + page (LogsResponseMetadataPage): [optional] # noqa: E501 + request_id (str): The identifier of the request. [optional] # noqa: E501 + status (LogsAggregateResponseStatus): [optional] # noqa: E501 + warnings ([LogsWarning]): A list of warnings (non fatal errors) encountered, partial results might be returned if warnings are present in the response.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +269,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_response_metadata_page.py b/src/datadog_api_client/v2/model/logs_response_metadata_page.py index ff83b5111f..c9481615f8 100644 --- a/src/datadog_api_client/v2/model/logs_response_metadata_page.py +++ b/src/datadog_api_client/v2/model/logs_response_metadata_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsResponseMetadataPage(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "after": "after", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsResponseMetadataPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + after (str): The cursor to use to get the next results, if any. To make the next request, use the same. parameters with the addition of the `page[cursor]`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/logs_sort.py b/src/datadog_api_client/v2/model/logs_sort.py index 2e370b354d..effefaf1f5 100644 --- a/src/datadog_api_client/v2/model/logs_sort.py +++ b/src/datadog_api_client/v2/model/logs_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsSort(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Sort parameters when querying logs.., must be one of ["timestamp", "-timestamp", ] # noqa: E501 + + Keyword Args: + value (str): Sort parameters when querying logs.., must be one of ["timestamp", "-timestamp", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_sort_order.py b/src/datadog_api_client/v2/model/logs_sort_order.py index 570f409af2..5f83cda185 100644 --- a/src/datadog_api_client/v2/model/logs_sort_order.py +++ b/src/datadog_api_client/v2/model/logs_sort_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsSortOrder(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """LogsSortOrder - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The order to use, ascending or descending., must be one of ["asc", "desc", ] # noqa: E501 + + Keyword Args: + value (str): The order to use, ascending or descending., must be one of ["asc", "desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/logs_warning.py b/src/datadog_api_client/v2/model/logs_warning.py index d796e87a18..9f3d1e48e7 100644 --- a/src/datadog_api_client/v2/model/logs_warning.py +++ b/src/datadog_api_client/v2/model/logs_warning.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class LogsWarning(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "title": "title", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """LogsWarning - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + code (str): A unique code for this type of warning. [optional] # noqa: E501 + detail (str): A detailed explanation of this specific warning. [optional] # noqa: E501 + title (str): A short human-readable summary of the warning. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric.py b/src/datadog_api_client/v2/model/metric.py index 418b9c58c7..e83d4b436a 100644 --- a/src/datadog_api_client/v2/model/metric.py +++ b/src/datadog_api_client/v2/model/metric.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Metric - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_all_tags.py b/src/datadog_api_client/v2/model/metric_all_tags.py index 1d829d250d..bf07b9a5c7 100644 --- a/src/datadog_api_client/v2/model/metric_all_tags.py +++ b/src/datadog_api_client/v2/model/metric_all_tags.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricAllTags - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricAllTagsAttributes): [optional] # noqa: E501 + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_all_tags_attributes.py b/src/datadog_api_client/v2/model/metric_all_tags_attributes.py index fda7c64ce1..a7c5b51604 100644 --- a/src/datadog_api_client/v2/model/metric_all_tags_attributes.py +++ b/src/datadog_api_client/v2/model/metric_all_tags_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricAllTagsAttributes(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricAllTagsAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + tags ([str]): List of indexed tag value pairs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_all_tags_response.py b/src/datadog_api_client/v2/model/metric_all_tags_response.py index 9b25035bda..eb406853ea 100644 --- a/src/datadog_api_client/v2/model/metric_all_tags_response.py +++ b/src/datadog_api_client/v2/model/metric_all_tags_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricAllTagsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (MetricAllTags): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_distinct_volume.py b/src/datadog_api_client/v2/model/metric_distinct_volume.py index 85a484aaf1..d5a16f2e35 100644 --- a/src/datadog_api_client/v2/model/metric_distinct_volume.py +++ b/src/datadog_api_client/v2/model/metric_distinct_volume.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricDistinctVolume - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricDistinctVolumeAttributes): [optional] # noqa: E501 + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricDistinctVolumeType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_distinct_volume_attributes.py b/src/datadog_api_client/v2/model/metric_distinct_volume_attributes.py index 33310aba8b..ae16bb90bd 100644 --- a/src/datadog_api_client/v2/model/metric_distinct_volume_attributes.py +++ b/src/datadog_api_client/v2/model/metric_distinct_volume_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricDistinctVolumeAttributes(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "distinct_volume": "distinct_volume", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricDistinctVolumeAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + distinct_volume (int): Distinct volume for the given metric.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_distinct_volume_type.py b/src/datadog_api_client/v2/model/metric_distinct_volume_type.py index 7ea50c9e8e..f2d5a701b3 100644 --- a/src/datadog_api_client/v2/model/metric_distinct_volume_type.py +++ b/src/datadog_api_client/v2/model/metric_distinct_volume_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricDistinctVolumeType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MetricDistinctVolumeType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The metric distinct volume type.. if omitted defaults to "distinct_metric_volumes", must be one of ["distinct_metric_volumes", ] # noqa: E501 + + Keyword Args: + value (str): The metric distinct volume type.. if omitted defaults to "distinct_metric_volumes", must be one of ["distinct_metric_volumes", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "distinct_metric_volumes" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume.py b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume.py index 520ef3e859..5bd1f71492 100644 --- a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume.py +++ b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricIngestedIndexedVolume - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricIngestedIndexedVolumeAttributes): [optional] # noqa: E501 + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricIngestedIndexedVolumeType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_attributes.py b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_attributes.py index 057a04fe4c..5e0607e018 100644 --- a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_attributes.py +++ b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricIngestedIndexedVolumeAttributes(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "ingested_volume": "ingested_volume", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricIngestedIndexedVolumeAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + indexed_volume (int): Indexed volume for the given metric.. [optional] # noqa: E501 + ingested_volume (int): Ingested volume for the given metric.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_type.py b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_type.py index 38a6a35d12..6f8294faa3 100644 --- a/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_type.py +++ b/src/datadog_api_client/v2/model/metric_ingested_indexed_volume_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricIngestedIndexedVolumeType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MetricIngestedIndexedVolumeType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The metric ingested and indexed volume type.. if omitted defaults to "metric_volumes", must be one of ["metric_volumes", ] # noqa: E501 + + Keyword Args: + value (str): The metric ingested and indexed volume type.. if omitted defaults to "metric_volumes", must be one of ["metric_volumes", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "metric_volumes" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration.py b/src/datadog_api_client/v2/model/metric_tag_configuration.py index a3d90f2bee..dda16dea2f 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricTagConfiguration - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricTagConfigurationAttributes): [optional] # noqa: E501 + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricTagConfigurationType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_attributes.py b/src/datadog_api_client/v2/model/metric_tag_configuration_attributes.py index 8b249027be..b94ca92bef 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_attributes.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,91 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Timestamp when the tag configuration was created.. [optional] # noqa: E501 + include_percentiles (bool): Toggle to turn on/off percentile aggregations for distribution metrics. Only present when the `metric_type` is `distribution`.. [optional] # noqa: E501 + metric_type (MetricTagConfigurationMetricTypes): [optional] # noqa: E501 + modified_at (datetime): Timestamp when the tag configuration was last modified.. [optional] # noqa: E501 + tags ([str]): List of tag keys on which to group.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -180,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_create_attributes.py b/src/datadog_api_client/v2/model/metric_tag_configuration_create_attributes.py index 642d165890..43d96c0271 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_create_attributes.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,94 @@ def discriminator(): "include_percentiles": "include_percentiles", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, metric_type, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationCreateAttributes - a model defined in OpenAPI + + Args: + metric_type (MetricTagConfigurationMetricTypes): + + Keyword Args: + tags ([str]): A list of tag keys that will be queryable for your metric.. defaults to [] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_percentiles (bool): Toggle to include/exclude percentiles for a distribution metric. Defaults to false. Can only be applied to metrics that have a `metric_type` of `distribution`.. [optional] if omitted the server will use the default value of False # noqa: E501 + """ + + tags = kwargs.get("tags", []) + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.metric_type = metric_type + self.tags = tags + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +267,8 @@ def __init__(self, metric_type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_create_data.py b/src/datadog_api_client/v2/model/metric_tag_configuration_create_data.py index 17dc28919d..4c1075a5aa 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_create_data.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "attributes": "attributes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationCreateData - a model defined in OpenAPI + + Args: + id (str): The metric name for this resource. + type (MetricTagConfigurationType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricTagConfigurationCreateAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_create_request.py b/src/datadog_api_client/v2/model/metric_tag_configuration_create_request.py index e9c2698591..a9887a2d94 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_create_request.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationCreateRequest - a model defined in OpenAPI + + Args: + data (MetricTagConfigurationCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_metric_types.py b/src/datadog_api_client/v2/model/metric_tag_configuration_metric_types.py index 868e75b45e..98c4316163 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_metric_types.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_metric_types.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricTagConfigurationMetricTypes(ModelSimple): @@ -77,6 +79,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -176,3 +180,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MetricTagConfigurationMetricTypes - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The metric's type.. if omitted defaults to "gauge", must be one of ["gauge", "count", "rate", "distribution", ] # noqa: E501 + + Keyword Args: + value (str): The metric's type.. if omitted defaults to "gauge", must be one of ["gauge", "count", "rate", "distribution", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "gauge" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_response.py b/src/datadog_api_client/v2/model/metric_tag_configuration_response.py index ce5e772646..62d4731669 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_response.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (MetricTagConfiguration): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_type.py b/src/datadog_api_client/v2/model/metric_tag_configuration_type.py index 5fda8b1130..043d86b736 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_type.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricTagConfigurationType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MetricTagConfigurationType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The metric tag configuration resource type.. if omitted defaults to "manage_tags", must be one of ["manage_tags", ] # noqa: E501 + + Keyword Args: + value (str): The metric tag configuration resource type.. if omitted defaults to "manage_tags", must be one of ["manage_tags", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "manage_tags" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_update_attributes.py b/src/datadog_api_client/v2/model/metric_tag_configuration_update_attributes.py index 1af8a3a15b..ff97342aad 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_update_attributes.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricTagConfigurationUpdateAttributes(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + include_percentiles (bool): Toggle to include/exclude percentiles for a distribution metric. Defaults to false. Can only be applied to metrics that have a `metric_type` of `distribution`.. [optional] if omitted the server will use the default value of False # noqa: E501 + tags ([str]): A list of tag keys that will be queryable for your metric.. [optional] if omitted the server will use the default value of [] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_update_data.py b/src/datadog_api_client/v2/model/metric_tag_configuration_update_data.py index 3f394bea00..887e49a831 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_update_data.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "attributes": "attributes", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationUpdateData - a model defined in OpenAPI + + Args: + id (str): The metric name for this resource. + type (MetricTagConfigurationType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricTagConfigurationUpdateAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_tag_configuration_update_request.py b/src/datadog_api_client/v2/model/metric_tag_configuration_update_request.py index 4ca19c168e..990d6e9319 100644 --- a/src/datadog_api_client/v2/model/metric_tag_configuration_update_request.py +++ b/src/datadog_api_client/v2/model/metric_tag_configuration_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """MetricTagConfigurationUpdateRequest - a model defined in OpenAPI + + Args: + data (MetricTagConfigurationUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metric_type.py b/src/datadog_api_client/v2/model/metric_type.py index 5d856aa13b..2e50b63b5e 100644 --- a/src/datadog_api_client/v2/model/metric_type.py +++ b/src/datadog_api_client/v2/model/metric_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class MetricType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """MetricType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The metric resource type.. if omitted defaults to "metrics", must be one of ["metrics", ] # noqa: E501 + + Keyword Args: + value (str): The metric resource type.. if omitted defaults to "metrics", must be one of ["metrics", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "metrics" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/metric_volumes.py b/src/datadog_api_client/v2/model/metric_volumes.py index aefb51ed70..db07d788f0 100644 --- a/src/datadog_api_client/v2/model/metric_volumes.py +++ b/src/datadog_api_client/v2/model/metric_volumes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -64,24 +66,7 @@ class MetricVolumes(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -103,6 +88,90 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricVolumes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (MetricIngestedIndexedVolumeAttributes): [optional] # noqa: E501 + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricIngestedIndexedVolumeType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -188,28 +257,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/metric_volumes_response.py b/src/datadog_api_client/v2/model/metric_volumes_response.py index cbe52f1cda..4ed0c41c13 100644 --- a/src/datadog_api_client/v2/model/metric_volumes_response.py +++ b/src/datadog_api_client/v2/model/metric_volumes_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricVolumesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (MetricVolumes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations.py b/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations.py index 0217e3cf58..f54d891977 100644 --- a/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations.py +++ b/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -62,24 +64,7 @@ class MetricsAndMetricTagConfigurations(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -101,6 +86,90 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsAndMetricTagConfigurations - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): The metric name for this resource.. [optional] # noqa: E501 + type (MetricTagConfigurationType): [optional] # noqa: E501 + attributes (MetricTagConfigurationAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -186,28 +255,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations_response.py b/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations_response.py index ee93491790..88a07ff5c0 100644 --- a/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations_response.py +++ b/src/datadog_api_client/v2/model/metrics_and_metric_tag_configurations_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """MetricsAndMetricTagConfigurationsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([MetricsAndMetricTagConfigurations]): Array of metrics and metric tag configurations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/organization.py b/src/datadog_api_client/v2/model/organization.py index 3b8301d9d7..bd0f5445b4 100644 --- a/src/datadog_api_client/v2/model/organization.py +++ b/src/datadog_api_client/v2/model/organization.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,92 @@ def discriminator(): "id": "id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """Organization - a model defined in OpenAPI + + Args: + type (OrganizationsType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (OrganizationAttributes): [optional] # noqa: E501 + id (str): ID of the organization.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +265,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/organization_attributes.py b/src/datadog_api_client/v2/model/organization_attributes.py index a24af425d3..c814da1591 100644 --- a/src/datadog_api_client/v2/model/organization_attributes.py +++ b/src/datadog_api_client/v2/model/organization_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class OrganizationAttributes(ModelNormal): @@ -90,8 +92,94 @@ def discriminator(): "url": "url", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """OrganizationAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the organization.. [optional] # noqa: E501 + description (str): Description of the organization.. [optional] # noqa: E501 + disabled (bool): Whether or not the organization is disabled.. [optional] # noqa: E501 + modified_at (datetime): Time of last organization modification.. [optional] # noqa: E501 + name (str): Name of the organization.. [optional] # noqa: E501 + public_id (str): Public ID of the organization.. [optional] # noqa: E501 + sharing (str): Sharing type of the organization.. [optional] # noqa: E501 + url (str): URL of the site that this organization exists at.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +270,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/organizations_type.py b/src/datadog_api_client/v2/model/organizations_type.py index a16c5d9e34..3f33b993f7 100644 --- a/src/datadog_api_client/v2/model/organizations_type.py +++ b/src/datadog_api_client/v2/model/organizations_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class OrganizationsType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """OrganizationsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Organizations resource type.. if omitted defaults to "orgs", must be one of ["orgs", ] # noqa: E501 + + Keyword Args: + value (str): Organizations resource type.. if omitted defaults to "orgs", must be one of ["orgs", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "orgs" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/pagination.py b/src/datadog_api_client/v2/model/pagination.py index 3eeeb504ca..14cf0101fc 100644 --- a/src/datadog_api_client/v2/model/pagination.py +++ b/src/datadog_api_client/v2/model/pagination.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class Pagination(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "total_filtered_count": "total_filtered_count", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Pagination - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + total_count (int): Total count.. [optional] # noqa: E501 + total_filtered_count (int): Total count of elements matched by the filter.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/partial_api_key.py b/src/datadog_api_client/v2/model/partial_api_key.py index d3fd19286c..cfe01ef06a 100644 --- a/src/datadog_api_client/v2/model/partial_api_key.py +++ b/src/datadog_api_client/v2/model/partial_api_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PartialAPIKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (PartialAPIKeyAttributes): [optional] # noqa: E501 + id (str): ID of the API key.. [optional] # noqa: E501 + relationships (APIKeyRelationships): [optional] # noqa: E501 + type (APIKeysType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/partial_api_key_attributes.py b/src/datadog_api_client/v2/model/partial_api_key_attributes.py index ccc263cafc..65c9aedfb5 100644 --- a/src/datadog_api_client/v2/model/partial_api_key_attributes.py +++ b/src/datadog_api_client/v2/model/partial_api_key_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class PartialAPIKeyAttributes(ModelNormal): @@ -87,8 +89,94 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "last4", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PartialAPIKeyAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (str): Creation date of the API key.. [optional] # noqa: E501 + last4 (str): The last four characters of the API key.. [optional] # noqa: E501 + modified_at (str): Date the API key was last modified.. [optional] # noqa: E501 + name (str): Name of the API key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +263,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/partial_application_key.py b/src/datadog_api_client/v2/model/partial_application_key.py index 18ba1c0d8a..8927a9e19b 100644 --- a/src/datadog_api_client/v2/model/partial_application_key.py +++ b/src/datadog_api_client/v2/model/partial_application_key.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PartialApplicationKey - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (PartialApplicationKeyAttributes): [optional] # noqa: E501 + id (str): ID of the application key.. [optional] # noqa: E501 + relationships (ApplicationKeyRelationships): [optional] # noqa: E501 + type (ApplicationKeysType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/partial_application_key_attributes.py b/src/datadog_api_client/v2/model/partial_application_key_attributes.py index 041ac66c69..618cdad0fa 100644 --- a/src/datadog_api_client/v2/model/partial_application_key_attributes.py +++ b/src/datadog_api_client/v2/model/partial_application_key_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class PartialApplicationKeyAttributes(ModelNormal): @@ -85,8 +87,92 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "last4", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PartialApplicationKeyAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (str): Creation date of the application key.. [optional] # noqa: E501 + last4 (str): The last four characters of the application key.. [optional] # noqa: E501 + name (str): Name of the application key.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -172,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/permission.py b/src/datadog_api_client/v2/model/permission.py index a4c375f568..865ce9eab2 100644 --- a/src/datadog_api_client/v2/model/permission.py +++ b/src/datadog_api_client/v2/model/permission.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,92 @@ def discriminator(): "id": "id", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """Permission - a model defined in OpenAPI + + Args: + type (PermissionsType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (PermissionAttributes): [optional] # noqa: E501 + id (str): ID of the permission.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +265,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/permission_attributes.py b/src/datadog_api_client/v2/model/permission_attributes.py index 30e06062b1..5b0a05fe76 100644 --- a/src/datadog_api_client/v2/model/permission_attributes.py +++ b/src/datadog_api_client/v2/model/permission_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class PermissionAttributes(ModelNormal): @@ -88,8 +90,93 @@ def discriminator(): "restricted": "restricted", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PermissionAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created (datetime): Creation time of the permission.. [optional] # noqa: E501 + description (str): Description of the permission.. [optional] # noqa: E501 + display_name (str): Displayed name for the permission.. [optional] # noqa: E501 + display_type (str): Display type.. [optional] # noqa: E501 + group_name (str): Name of the permission group.. [optional] # noqa: E501 + name (str): Name of the permission.. [optional] # noqa: E501 + restricted (bool): Whether or not the permission is restricted.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +266,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/permissions_response.py b/src/datadog_api_client/v2/model/permissions_response.py index acc99f16f7..b6e2d72193 100644 --- a/src/datadog_api_client/v2/model/permissions_response.py +++ b/src/datadog_api_client/v2/model/permissions_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PermissionsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([Permission]): Array of permissions.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/permissions_type.py b/src/datadog_api_client/v2/model/permissions_type.py index 75a6f60a9c..2710cc6139 100644 --- a/src/datadog_api_client/v2/model/permissions_type.py +++ b/src/datadog_api_client/v2/model/permissions_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class PermissionsType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """PermissionsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Permissions resource type.. if omitted defaults to "permissions", must be one of ["permissions", ] # noqa: E501 + + Keyword Args: + value (str): Permissions resource type.. if omitted defaults to "permissions", must be one of ["permissions", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "permissions" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/process_summaries_meta.py b/src/datadog_api_client/v2/model/process_summaries_meta.py index eb06ce45e4..1a104dc9bc 100644 --- a/src/datadog_api_client/v2/model/process_summaries_meta.py +++ b/src/datadog_api_client/v2/model/process_summaries_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ProcessSummariesMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (ProcessSummariesMetaPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/process_summaries_meta_page.py b/src/datadog_api_client/v2/model/process_summaries_meta_page.py index 58d194b12c..e7cedbe87d 100644 --- a/src/datadog_api_client/v2/model/process_summaries_meta_page.py +++ b/src/datadog_api_client/v2/model/process_summaries_meta_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ProcessSummariesMetaPage(ModelNormal): @@ -83,8 +85,88 @@ def discriminator(): "size": "size", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ProcessSummariesMetaPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + after (str): The cursor used to get the next results, if any. To make the next request, use the same parameters with the addition of the `page[cursor]`.. [optional] # noqa: E501 + size (int): Number of results returned.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -169,3 +251,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/process_summaries_response.py b/src/datadog_api_client/v2/model/process_summaries_response.py index ee37291a36..039a370cb9 100644 --- a/src/datadog_api_client/v2/model/process_summaries_response.py +++ b/src/datadog_api_client/v2/model/process_summaries_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ProcessSummariesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([ProcessSummary]): Array of process summary objects.. [optional] # noqa: E501 + meta (ProcessSummariesMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/process_summary.py b/src/datadog_api_client/v2/model/process_summary.py index eb66d12af6..530bf19ee9 100644 --- a/src/datadog_api_client/v2/model/process_summary.py +++ b/src/datadog_api_client/v2/model/process_summary.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ProcessSummary - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (ProcessSummaryAttributes): [optional] # noqa: E501 + id (str): Process ID.. [optional] # noqa: E501 + type (ProcessSummaryType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/process_summary_attributes.py b/src/datadog_api_client/v2/model/process_summary_attributes.py index 0c7281f6e6..8e14505dbd 100644 --- a/src/datadog_api_client/v2/model/process_summary_attributes.py +++ b/src/datadog_api_client/v2/model/process_summary_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ProcessSummaryAttributes(ModelNormal): @@ -90,8 +92,94 @@ def discriminator(): "user": "user", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ProcessSummaryAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cmdline (str): Process command line.. [optional] # noqa: E501 + host (str): Host running the process.. [optional] # noqa: E501 + pid (int): Process ID.. [optional] # noqa: E501 + ppid (int): Parent process ID.. [optional] # noqa: E501 + start (str): Time the process was started.. [optional] # noqa: E501 + tags ([str]): List of tags associated with the process.. [optional] # noqa: E501 + timestamp (str): Time the process was seen.. [optional] # noqa: E501 + user (str): Process owner.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +270,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/process_summary_type.py b/src/datadog_api_client/v2/model/process_summary_type.py index 8760f59c8f..5b0ea1ddb7 100644 --- a/src/datadog_api_client/v2/model/process_summary_type.py +++ b/src/datadog_api_client/v2/model/process_summary_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class ProcessSummaryType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """ProcessSummaryType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Type of process summary.. if omitted defaults to "process", must be one of ["process", ] # noqa: E501 + + Keyword Args: + value (str): Type of process summary.. if omitted defaults to "process", must be one of ["process", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "process" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/query_sort_order.py b/src/datadog_api_client/v2/model/query_sort_order.py index 38eaaef7dc..3258dcfe0e 100644 --- a/src/datadog_api_client/v2/model/query_sort_order.py +++ b/src/datadog_api_client/v2/model/query_sort_order.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class QuerySortOrder(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -174,3 +178,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """QuerySortOrder - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Direction of sort.. if omitted defaults to "desc", must be one of ["asc", "desc", ] # noqa: E501 + + Keyword Args: + value (str): Direction of sort.. if omitted defaults to "desc", must be one of ["asc", "desc", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "desc" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadata_data.py b/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadata_data.py index 4847e31d17..bd58519981 100644 --- a/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadata_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadata_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """RelationshipToIncidentIntegrationMetadataData - a model defined in OpenAPI + + Args: + id (str): A unique identifier that represents the integration metadata. + type (IncidentIntegrationMetadataType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadatas.py b/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadatas.py index c05ec78b9d..b74a376d0a 100644 --- a/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadatas.py +++ b/src/datadog_api_client/v2/model/relationship_to_incident_integration_metadatas.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToIncidentIntegrationMetadatas - a model defined in OpenAPI + + Args: + data ([RelationshipToIncidentIntegrationMetadataData]): The integration metadata relationship array + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +257,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_incident_postmortem.py b/src/datadog_api_client/v2/model/relationship_to_incident_postmortem.py index 036c4e2c8b..90ced7d6f6 100644 --- a/src/datadog_api_client/v2/model/relationship_to_incident_postmortem.py +++ b/src/datadog_api_client/v2/model/relationship_to_incident_postmortem.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToIncidentPostmortem - a model defined in OpenAPI + + Args: + data (RelationshipToIncidentPostmortemData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +257,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_incident_postmortem_data.py b/src/datadog_api_client/v2/model/relationship_to_incident_postmortem_data.py index 3917fc161c..46eb2284c1 100644 --- a/src/datadog_api_client/v2/model/relationship_to_incident_postmortem_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_incident_postmortem_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """RelationshipToIncidentPostmortemData - a model defined in OpenAPI + + Args: + id (str): A unique identifier that represents the postmortem. + type (IncidentPostmortemType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_organization.py b/src/datadog_api_client/v2/model/relationship_to_organization.py index 7f4ff2966e..17a0fd16df 100644 --- a/src/datadog_api_client/v2/model/relationship_to_organization.py +++ b/src/datadog_api_client/v2/model/relationship_to_organization.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToOrganization - a model defined in OpenAPI + + Args: + data (RelationshipToOrganizationData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_organization_data.py b/src/datadog_api_client/v2/model/relationship_to_organization_data.py index aa863ed595..219a4d8fec 100644 --- a/src/datadog_api_client/v2/model/relationship_to_organization_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_organization_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """RelationshipToOrganizationData - a model defined in OpenAPI + + Args: + id (str): ID of the organization. + type (OrganizationsType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_organizations.py b/src/datadog_api_client/v2/model/relationship_to_organizations.py index f4fdec4c58..c50579fbd3 100644 --- a/src/datadog_api_client/v2/model/relationship_to_organizations.py +++ b/src/datadog_api_client/v2/model/relationship_to_organizations.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToOrganizations - a model defined in OpenAPI + + Args: + data ([RelationshipToOrganizationData]): Relationships to organization objects. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_permission.py b/src/datadog_api_client/v2/model/relationship_to_permission.py index cd2eea2f9e..bcd6a71e47 100644 --- a/src/datadog_api_client/v2/model/relationship_to_permission.py +++ b/src/datadog_api_client/v2/model/relationship_to_permission.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToPermission - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (RelationshipToPermissionData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_permission_data.py b/src/datadog_api_client/v2/model/relationship_to_permission_data.py index de31cf99b5..3e961e3782 100644 --- a/src/datadog_api_client/v2/model/relationship_to_permission_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_permission_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToPermissionData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): ID of the permission.. [optional] # noqa: E501 + type (PermissionsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_permissions.py b/src/datadog_api_client/v2/model/relationship_to_permissions.py index 2c1ebb56fb..04c9c4a142 100644 --- a/src/datadog_api_client/v2/model/relationship_to_permissions.py +++ b/src/datadog_api_client/v2/model/relationship_to_permissions.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToPermissions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([RelationshipToPermissionData]): Relationships to permission objects.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_role.py b/src/datadog_api_client/v2/model/relationship_to_role.py index fea73ee00c..a35cfea4c3 100644 --- a/src/datadog_api_client/v2/model/relationship_to_role.py +++ b/src/datadog_api_client/v2/model/relationship_to_role.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToRole - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (RelationshipToRoleData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_role_data.py b/src/datadog_api_client/v2/model/relationship_to_role_data.py index 9d1c5a33c3..1ff92e842f 100644 --- a/src/datadog_api_client/v2/model/relationship_to_role_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_role_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToRoleData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + id (str): ID of the role.. [optional] # noqa: E501 + type (RolesType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_roles.py b/src/datadog_api_client/v2/model/relationship_to_roles.py index 930a6bedb4..a28a16bcba 100644 --- a/src/datadog_api_client/v2/model/relationship_to_roles.py +++ b/src/datadog_api_client/v2/model/relationship_to_roles.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RelationshipToRoles - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([RelationshipToRoleData]): An array containing type and ID of a role.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_user.py b/src/datadog_api_client/v2/model/relationship_to_user.py index 7c4211d041..2d882e8629 100644 --- a/src/datadog_api_client/v2/model/relationship_to_user.py +++ b/src/datadog_api_client/v2/model/relationship_to_user.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToUser - a model defined in OpenAPI + + Args: + data (RelationshipToUserData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_user_data.py b/src/datadog_api_client/v2/model/relationship_to_user_data.py index 7ef99fc222..41f911013d 100644 --- a/src/datadog_api_client/v2/model/relationship_to_user_data.py +++ b/src/datadog_api_client/v2/model/relationship_to_user_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, type, *args, **kwargs): # noqa: E501 + """RelationshipToUserData - a model defined in OpenAPI + + Args: + id (str): A unique identifier that represents the user. + type (UsersType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -175,3 +261,8 @@ def __init__(self, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/relationship_to_users.py b/src/datadog_api_client/v2/model/relationship_to_users.py index 498122d13f..834c3ecf8b 100644 --- a/src/datadog_api_client/v2/model/relationship_to_users.py +++ b/src/datadog_api_client/v2/model/relationship_to_users.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RelationshipToUsers - a model defined in OpenAPI + + Args: + data ([RelationshipToUserData]): Relationships to user objects. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/response_meta_attributes.py b/src/datadog_api_client/v2/model/response_meta_attributes.py index 26f745c60b..781abfa519 100644 --- a/src/datadog_api_client/v2/model/response_meta_attributes.py +++ b/src/datadog_api_client/v2/model/response_meta_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """ResponseMetaAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (Pagination): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role.py b/src/datadog_api_client/v2/model/role.py index b6add838c9..a2314c27fe 100644 --- a/src/datadog_api_client/v2/model/role.py +++ b/src/datadog_api_client/v2/model/role.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """Role - a model defined in OpenAPI + + Args: + type (RolesType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (RoleAttributes): [optional] # noqa: E501 + id (str): ID of the role.. [optional] # noqa: E501 + relationships (RoleResponseRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_attributes.py b/src/datadog_api_client/v2/model/role_attributes.py index 9aa1215d91..3bdfceead5 100644 --- a/src/datadog_api_client/v2/model/role_attributes.py +++ b/src/datadog_api_client/v2/model/role_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class RoleAttributes(ModelNormal): @@ -82,8 +84,94 @@ def discriminator(): "user_count": "user_count", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "modified_at", # noqa: E501 + "user_count", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the role.. [optional] # noqa: E501 + modified_at (datetime): Time of last role modification.. [optional] # noqa: E501 + name (str): Name of the role.. [optional] # noqa: E501 + user_count (int): Number of users with that role.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +258,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_create_attributes.py b/src/datadog_api_client/v2/model/role_create_attributes.py index eec0138a91..27e3803787 100644 --- a/src/datadog_api_client/v2/model/role_create_attributes.py +++ b/src/datadog_api_client/v2/model/role_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class RoleCreateAttributes(ModelNormal): @@ -80,8 +82,95 @@ def discriminator(): "modified_at": "modified_at", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, *args, **kwargs): # noqa: E501 + """RoleCreateAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the role. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the role.. [optional] # noqa: E501 + modified_at (datetime): Time of last role modification.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +259,8 @@ def __init__(self, name, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_create_data.py b/src/datadog_api_client/v2/model/role_create_data.py index e448e2f980..1763650284 100644 --- a/src/datadog_api_client/v2/model/role_create_data.py +++ b/src/datadog_api_client/v2/model/role_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, *args, **kwargs): # noqa: E501 + """RoleCreateData - a model defined in OpenAPI + + Args: + attributes (RoleCreateAttributes): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + relationships (RoleRelationships): [optional] # noqa: E501 + type (RolesType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +267,8 @@ def __init__(self, attributes, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_create_request.py b/src/datadog_api_client/v2/model/role_create_request.py index 7085365da0..cb0ac1437c 100644 --- a/src/datadog_api_client/v2/model/role_create_request.py +++ b/src/datadog_api_client/v2/model/role_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RoleCreateRequest - a model defined in OpenAPI + + Args: + data (RoleCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_create_response.py b/src/datadog_api_client/v2/model/role_create_response.py index a73e5a1342..21e16def6a 100644 --- a/src/datadog_api_client/v2/model/role_create_response.py +++ b/src/datadog_api_client/v2/model/role_create_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleCreateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (RoleCreateResponseData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_create_response_data.py b/src/datadog_api_client/v2/model/role_create_response_data.py index 2d6106bcc4..717277645d 100644 --- a/src/datadog_api_client/v2/model/role_create_response_data.py +++ b/src/datadog_api_client/v2/model/role_create_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """RoleCreateResponseData - a model defined in OpenAPI + + Args: + type (RolesType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (RoleCreateAttributes): [optional] # noqa: E501 + id (str): ID of the role.. [optional] # noqa: E501 + relationships (RoleResponseRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_relationships.py b/src/datadog_api_client/v2/model/role_relationships.py index 37f9ff8bc2..bcc5f53934 100644 --- a/src/datadog_api_client/v2/model/role_relationships.py +++ b/src/datadog_api_client/v2/model/role_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "users": "users", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + permissions (RelationshipToPermissions): [optional] # noqa: E501 + users (RelationshipToUsers): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_response.py b/src/datadog_api_client/v2/model/role_response.py index 5830356681..500840dc63 100644 --- a/src/datadog_api_client/v2/model/role_response.py +++ b/src/datadog_api_client/v2/model/role_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (Role): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_response_relationships.py b/src/datadog_api_client/v2/model/role_response_relationships.py index 6c010aaa9a..a5937a9b3a 100644 --- a/src/datadog_api_client/v2/model/role_response_relationships.py +++ b/src/datadog_api_client/v2/model/role_response_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "permissions": "permissions", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleResponseRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + permissions (RelationshipToPermissions): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_update_attributes.py b/src/datadog_api_client/v2/model/role_update_attributes.py index a9d1744c1b..5cc9df3644 100644 --- a/src/datadog_api_client/v2/model/role_update_attributes.py +++ b/src/datadog_api_client/v2/model/role_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class RoleUpdateAttributes(ModelNormal): @@ -80,8 +82,92 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = { + "created_at", # noqa: E501 + "modified_at", # noqa: E501 + } + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the role.. [optional] # noqa: E501 + modified_at (datetime): Time of last role modification.. [optional] # noqa: E501 + name (str): Name of the role.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_update_data.py b/src/datadog_api_client/v2/model/role_update_data.py index 7995ebc5b7..467cf67231 100644 --- a/src/datadog_api_client/v2/model/role_update_data.py +++ b/src/datadog_api_client/v2/model/role_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """RoleUpdateData - a model defined in OpenAPI + + Args: + attributes (RoleUpdateAttributes): + id (str): ID of the role. + type (RolesType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_update_request.py b/src/datadog_api_client/v2/model/role_update_request.py index af7eb598f4..f9d4cb0848 100644 --- a/src/datadog_api_client/v2/model/role_update_request.py +++ b/src/datadog_api_client/v2/model/role_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """RoleUpdateRequest - a model defined in OpenAPI + + Args: + data (RoleUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_update_response.py b/src/datadog_api_client/v2/model/role_update_response.py index bbee1a1969..25d4b55bad 100644 --- a/src/datadog_api_client/v2/model/role_update_response.py +++ b/src/datadog_api_client/v2/model/role_update_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RoleUpdateResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (RoleUpdateResponseData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/role_update_response_data.py b/src/datadog_api_client/v2/model/role_update_response_data.py index 935b8e2b68..37b3cfac05 100644 --- a/src/datadog_api_client/v2/model/role_update_response_data.py +++ b/src/datadog_api_client/v2/model/role_update_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, type, *args, **kwargs): # noqa: E501 + """RoleUpdateResponseData - a model defined in OpenAPI + + Args: + type (RolesType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (RoleUpdateAttributes): [optional] # noqa: E501 + id (str): ID of the role.. [optional] # noqa: E501 + relationships (RoleResponseRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -184,3 +271,8 @@ def __init__(self, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/roles_response.py b/src/datadog_api_client/v2/model/roles_response.py index de04e7c735..d1d10bb19b 100644 --- a/src/datadog_api_client/v2/model/roles_response.py +++ b/src/datadog_api_client/v2/model/roles_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """RolesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([Role]): Array of returned roles.. [optional] # noqa: E501 + meta (ResponseMetaAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/roles_sort.py b/src/datadog_api_client/v2/model/roles_sort.py index 3d69baf784..6328dccd08 100644 --- a/src/datadog_api_client/v2/model/roles_sort.py +++ b/src/datadog_api_client/v2/model/roles_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class RolesSort(ModelSimple): @@ -79,6 +81,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """RolesSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Sorting options for roles.. if omitted defaults to "name", must be one of ["name", "-name", "modified_at", "-modified_at", "user_count", "-user_count", ] # noqa: E501 + + Keyword Args: + value (str): Sorting options for roles.. if omitted defaults to "name", must be one of ["name", "-name", "modified_at", "-modified_at", "user_count", "-user_count", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "name" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/roles_type.py b/src/datadog_api_client/v2/model/roles_type.py index 7ea435c0a1..4695cf92fb 100644 --- a/src/datadog_api_client/v2/model/roles_type.py +++ b/src/datadog_api_client/v2/model/roles_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class RolesType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """RolesType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Roles type.. if omitted defaults to "roles", must be one of ["roles", ] # noqa: E501 + + Keyword Args: + value (str): Roles type.. if omitted defaults to "roles", must be one of ["roles", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "roles" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_filter.py b/src/datadog_api_client/v2/model/security_filter.py index d33978d08d..08d024d137 100644 --- a/src/datadog_api_client/v2/model/security_filter.py +++ b/src/datadog_api_client/v2/model/security_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (SecurityFilterAttributes): [optional] # noqa: E501 + id (str): The ID of the security filter.. [optional] # noqa: E501 + type (SecurityFilterType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_attributes.py b/src/datadog_api_client/v2/model/security_filter_attributes.py index 77413d533c..d50a4cf7c0 100644 --- a/src/datadog_api_client/v2/model/security_filter_attributes.py +++ b/src/datadog_api_client/v2/model/security_filter_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -103,8 +105,93 @@ def discriminator(): "version": "version", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilterAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + exclusion_filters ([SecurityFilterExclusionFilterResponse]): The list of exclusion filters applied in this security filter.. [optional] # noqa: E501 + filtered_data_type (SecurityFilterFilteredDataType): [optional] # noqa: E501 + is_builtin (bool): Whether the security filter is the built-in filter.. [optional] # noqa: E501 + is_enabled (bool): Whether the security filter is enabled.. [optional] # noqa: E501 + name (str): The security filter name.. [optional] # noqa: E501 + query (str): The security filter query. Logs accepted by this query will be accepted by this filter.. [optional] # noqa: E501 + version (int): The version of the security filter.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -194,3 +281,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_create_attributes.py b/src/datadog_api_client/v2/model/security_filter_create_attributes.py index 61fe897901..60e2b1fc4e 100644 --- a/src/datadog_api_client/v2/model/security_filter_create_attributes.py +++ b/src/datadog_api_client/v2/model/security_filter_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,100 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data( + cls, exclusion_filters, filtered_data_type, is_enabled, name, query, *args, **kwargs + ): # noqa: E501 + """SecurityFilterCreateAttributes - a model defined in OpenAPI + + Args: + exclusion_filters ([SecurityFilterExclusionFilter]): Exclusion filters to exclude some logs from the security filter. + filtered_data_type (SecurityFilterFilteredDataType): + is_enabled (bool): Whether the security filter is enabled. + name (str): The name of the security filter. + query (str): The query of the security filter. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.exclusion_filters = exclusion_filters + self.filtered_data_type = filtered_data_type + self.is_enabled = is_enabled + self.name = name + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +283,8 @@ def __init__(self, exclusion_filters, filtered_data_type, is_enabled, name, quer # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_create_data.py b/src/datadog_api_client/v2/model/security_filter_create_data.py index 7b8569884c..113d720b7f 100644 --- a/src/datadog_api_client/v2/model/security_filter_create_data.py +++ b/src/datadog_api_client/v2/model/security_filter_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """SecurityFilterCreateData - a model defined in OpenAPI + + Args: + attributes (SecurityFilterCreateAttributes): + type (SecurityFilterType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_create_request.py b/src/datadog_api_client/v2/model/security_filter_create_request.py index 2810df19e2..85b4585317 100644 --- a/src/datadog_api_client/v2/model/security_filter_create_request.py +++ b/src/datadog_api_client/v2/model/security_filter_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """SecurityFilterCreateRequest - a model defined in OpenAPI + + Args: + data (SecurityFilterCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_exclusion_filter.py b/src/datadog_api_client/v2/model/security_filter_exclusion_filter.py index 790bd80c1f..a4ef457575 100644 --- a/src/datadog_api_client/v2/model/security_filter_exclusion_filter.py +++ b/src/datadog_api_client/v2/model/security_filter_exclusion_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityFilterExclusionFilter(ModelNormal): @@ -78,8 +80,92 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, query, *args, **kwargs): # noqa: E501 + """SecurityFilterExclusionFilter - a model defined in OpenAPI + + Args: + name (str): Exclusion filter name. + query (str): Exclusion filter query. Logs that match this query are excluded from the security filter. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +254,8 @@ def __init__(self, name, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_exclusion_filter_response.py b/src/datadog_api_client/v2/model/security_filter_exclusion_filter_response.py index 638b995a82..7c79a08509 100644 --- a/src/datadog_api_client/v2/model/security_filter_exclusion_filter_response.py +++ b/src/datadog_api_client/v2/model/security_filter_exclusion_filter_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityFilterExclusionFilterResponse(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilterExclusionFilterResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): The exclusion filter name.. [optional] # noqa: E501 + query (str): The exclusion filter query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_filtered_data_type.py b/src/datadog_api_client/v2/model/security_filter_filtered_data_type.py index 494af3e1e0..0693853aea 100644 --- a/src/datadog_api_client/v2/model/security_filter_filtered_data_type.py +++ b/src/datadog_api_client/v2/model/security_filter_filtered_data_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityFilterFilteredDataType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityFilterFilteredDataType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The filtered data type.. if omitted defaults to "logs", must be one of ["logs", ] # noqa: E501 + + Keyword Args: + value (str): The filtered data type.. if omitted defaults to "logs", must be one of ["logs", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "logs" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_filter_meta.py b/src/datadog_api_client/v2/model/security_filter_meta.py index 9e42330169..cac3f39952 100644 --- a/src/datadog_api_client/v2/model/security_filter_meta.py +++ b/src/datadog_api_client/v2/model/security_filter_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityFilterMeta(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "warning": "warning", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilterMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + warning (str): A warning message.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_response.py b/src/datadog_api_client/v2/model/security_filter_response.py index f6e467e9a6..16d86d977c 100644 --- a/src/datadog_api_client/v2/model/security_filter_response.py +++ b/src/datadog_api_client/v2/model/security_filter_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilterResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (SecurityFilter): [optional] # noqa: E501 + meta (SecurityFilterMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_type.py b/src/datadog_api_client/v2/model/security_filter_type.py index 894281e13c..2b514ce740 100644 --- a/src/datadog_api_client/v2/model/security_filter_type.py +++ b/src/datadog_api_client/v2/model/security_filter_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityFilterType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityFilterType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of the resource. The value should always be `security_filters`.. if omitted defaults to "security_filters", must be one of ["security_filters", ] # noqa: E501 + + Keyword Args: + value (str): The type of the resource. The value should always be `security_filters`.. if omitted defaults to "security_filters", must be one of ["security_filters", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "security_filters" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_filter_update_attributes.py b/src/datadog_api_client/v2/model/security_filter_update_attributes.py index 8c0c62ff2d..8450dd8c5a 100644 --- a/src/datadog_api_client/v2/model/security_filter_update_attributes.py +++ b/src/datadog_api_client/v2/model/security_filter_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,92 @@ def discriminator(): "version": "version", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFilterUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + exclusion_filters ([SecurityFilterExclusionFilter]): Exclusion filters to exclude some logs from the security filter.. [optional] # noqa: E501 + filtered_data_type (SecurityFilterFilteredDataType): [optional] # noqa: E501 + is_enabled (bool): Whether the security filter is enabled.. [optional] # noqa: E501 + name (str): The name of the security filter.. [optional] # noqa: E501 + query (str): The query of the security filter.. [optional] # noqa: E501 + version (int): The version of the security filter to update.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -189,3 +275,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_update_data.py b/src/datadog_api_client/v2/model/security_filter_update_data.py index c86a6e72c9..cd9c6e6962 100644 --- a/src/datadog_api_client/v2/model/security_filter_update_data.py +++ b/src/datadog_api_client/v2/model/security_filter_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """SecurityFilterUpdateData - a model defined in OpenAPI + + Args: + attributes (SecurityFilterUpdateAttributes): + type (SecurityFilterType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filter_update_request.py b/src/datadog_api_client/v2/model/security_filter_update_request.py index b003568a86..99a741eb08 100644 --- a/src/datadog_api_client/v2/model/security_filter_update_request.py +++ b/src/datadog_api_client/v2/model/security_filter_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """SecurityFilterUpdateRequest - a model defined in OpenAPI + + Args: + data (SecurityFilterUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_filters_response.py b/src/datadog_api_client/v2/model/security_filters_response.py index 1b701bbcf2..7caa828106 100644 --- a/src/datadog_api_client/v2/model/security_filters_response.py +++ b/src/datadog_api_client/v2/model/security_filters_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityFiltersResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([SecurityFilter]): A list of security filters objects.. [optional] # noqa: E501 + meta (SecurityFilterMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_filter.py b/src/datadog_api_client/v2/model/security_monitoring_filter.py index 2917d05efa..85469f323e 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_filter.py +++ b/src/datadog_api_client/v2/model/security_monitoring_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,88 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + action (SecurityMonitoringFilterAction): [optional] # noqa: E501 + query (str): Query for selecting logs to apply the filtering action.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +253,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_filter_action.py b/src/datadog_api_client/v2/model/security_monitoring_filter_action.py index cf95f6637c..c368320b2a 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_filter_action.py +++ b/src/datadog_api_client/v2/model/security_monitoring_filter_action.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringFilterAction(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringFilterAction - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of filtering action.., must be one of ["require", "suppress", ] # noqa: E501 + + Keyword Args: + value (str): The type of filtering action.., must be one of ["require", "suppress", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_list_rules_response.py b/src/datadog_api_client/v2/model/security_monitoring_list_rules_response.py index d1c54946f7..c0f0915375 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_list_rules_response.py +++ b/src/datadog_api_client/v2/model/security_monitoring_list_rules_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringListRulesResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([SecurityMonitoringRuleResponse]): Array containing the list of rules.. [optional] # noqa: E501 + meta (ResponseMetaAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_case.py b/src/datadog_api_client/v2/model/security_monitoring_rule_case.py index d27b25e97a..5b92b01413 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_case.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_case.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,90 @@ def discriminator(): "status": "status", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleCase - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + condition (str): A rule case contains logical operations (`>`,`>=`, `&&`, `||`) to determine if a signal should be generated based on the event counts in the previously defined queries.. [optional] # noqa: E501 + name (str): Name of the case.. [optional] # noqa: E501 + notifications ([str]): Notification targets for each rule case.. [optional] # noqa: E501 + status (SecurityMonitoringRuleSeverity): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_case_create.py b/src/datadog_api_client/v2/model/security_monitoring_rule_case_create.py index 56a76c2e25..851ca8ad83 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_case_create.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_case_create.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,93 @@ def discriminator(): "notifications": "notifications", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, status, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleCaseCreate - a model defined in OpenAPI + + Args: + status (SecurityMonitoringRuleSeverity): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + condition (str): A rule case contains logical operations (`>`,`>=`, `&&`, `||`) to determine if a signal should be generated based on the event counts in the previously defined queries.. [optional] # noqa: E501 + name (str): Name of the case.. [optional] # noqa: E501 + notifications ([str]): Notification targets for each rule case.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.status = status + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -180,3 +267,8 @@ def __init__(self, status, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_create_payload.py b/src/datadog_api_client/v2/model/security_monitoring_rule_create_payload.py index 2c1af3df5b..479152b0f3 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_create_payload.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_create_payload.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -105,8 +107,103 @@ def discriminator(): "tags": "tags", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, cases, is_enabled, message, name, options, queries, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleCreatePayload - a model defined in OpenAPI + + Args: + cases ([SecurityMonitoringRuleCaseCreate]): Cases for generating signals. + is_enabled (bool): Whether the rule is enabled. + message (str): Message for generated signals. + name (str): The name of the rule. + options (SecurityMonitoringRuleOptions): + queries ([SecurityMonitoringRuleQueryCreate]): Queries for selecting logs which are part of the rule. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filters ([SecurityMonitoringFilter]): Additional queries to filter matched events before they are processed.. [optional] # noqa: E501 + has_extended_title (bool): Whether the notifications include the triggering group-by values in their title.. [optional] # noqa: E501 + tags ([str]): Tags for generated signals.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.cases = cases + self.is_enabled = is_enabled + self.message = message + self.name = name + self.options = options + self.queries = queries + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -206,3 +303,8 @@ def __init__(self, cases, is_enabled, message, name, options, queries, *args, ** # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_detection_method.py b/src/datadog_api_client/v2/model/security_monitoring_rule_detection_method.py index 0709fe0300..83c6c7e3c6 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_detection_method.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_detection_method.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleDetectionMethod(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleDetectionMethod - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The detection method.., must be one of ["threshold", "new_value", "anomaly_detection", ] # noqa: E501 + + Keyword Args: + value (str): The detection method.., must be one of ["threshold", "new_value", "anomaly_detection", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_evaluation_window.py b/src/datadog_api_client/v2/model/security_monitoring_rule_evaluation_window.py index 4b7745ebe9..ec4bcba4dd 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_evaluation_window.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_evaluation_window.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleEvaluationWindow(ModelSimple): @@ -81,6 +83,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -184,3 +188,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleEvaluationWindow - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): A time window is specified to match when at least one of the cases matches true. This is a sliding window and evaluates in real time.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, ] # noqa: E501 + + Keyword Args: + value (int): A time window is specified to match when at least one of the cases matches true. This is a sliding window and evaluates in real time.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_keep_alive.py b/src/datadog_api_client/v2/model/security_monitoring_rule_keep_alive.py index 825b09b9fd..c946fea22a 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_keep_alive.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_keep_alive.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleKeepAlive(ModelSimple): @@ -83,6 +85,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -186,3 +190,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleKeepAlive - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): Once a signal is generated, the signal will remain “open” if a case is matched at least once within this keep alive window.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 21600, ] # noqa: E501 + + Keyword Args: + value (int): Once a signal is generated, the signal will remain “open” if a case is matched at least once within this keep alive window.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 21600, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_max_signal_duration.py b/src/datadog_api_client/v2/model/security_monitoring_rule_max_signal_duration.py index 4d3af8a95a..61af34be0f 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_max_signal_duration.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_max_signal_duration.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleMaxSignalDuration(ModelSimple): @@ -85,6 +87,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -188,3 +192,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleMaxSignalDuration - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): A signal will “close” regardless of the query being matched once the time exceeds the maximum duration. This time is calculated from the first seen timestamp.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, ] # noqa: E501 + + Keyword Args: + value (int): A signal will “close” regardless of the query being matched once the time exceeds the maximum duration. This time is calculated from the first seen timestamp.., must be one of [0, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options.py b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options.py index 074ec06129..3ce7a1df06 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,88 @@ def discriminator(): "learning_duration": "learningDuration", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleNewValueOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + forget_after (SecurityMonitoringRuleNewValueOptionsForgetAfter): [optional] # noqa: E501 + learning_duration (SecurityMonitoringRuleNewValueOptionsLearningDuration): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -179,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_forget_after.py b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_forget_after.py index 48abfd9933..497f5937f0 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_forget_after.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_forget_after.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleNewValueOptionsForgetAfter(ModelSimple): @@ -79,6 +81,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -182,3 +186,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleNewValueOptionsForgetAfter - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): The duration in days after which a learned value is forgotten.., must be one of [1, 2, 7, 14, 21, 28, ] # noqa: E501 + + Keyword Args: + value (int): The duration in days after which a learned value is forgotten.., must be one of [1, 2, 7, 14, 21, 28, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_learning_duration.py b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_learning_duration.py index 53bc074499..326f443d51 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_learning_duration.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_new_value_options_learning_duration.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleNewValueOptionsLearningDuration(ModelSimple): @@ -76,6 +78,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -179,3 +183,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleNewValueOptionsLearningDuration - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (int): The duration in days during which values are learned, and after which signals will be generated for values that weren't learned. If set to 0, a signal will be generated for all new values after the first value is learned.., must be one of [0, 1, 7, ] # noqa: E501 + + Keyword Args: + value (int): The duration in days during which values are learned, and after which signals will be generated for values that weren't learned. If set to 0, a signal will be generated for all new values after the first value is learned.., must be one of [0, 1, 7, ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_options.py b/src/datadog_api_client/v2/model/security_monitoring_rule_options.py index 897020f8da..b8f2b2ebaa 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_options.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_options.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -107,8 +109,91 @@ def discriminator(): "new_value_options": "newValueOptions", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleOptions - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + detection_method (SecurityMonitoringRuleDetectionMethod): [optional] # noqa: E501 + evaluation_window (SecurityMonitoringRuleEvaluationWindow): [optional] # noqa: E501 + keep_alive (SecurityMonitoringRuleKeepAlive): [optional] # noqa: E501 + max_signal_duration (SecurityMonitoringRuleMaxSignalDuration): [optional] # noqa: E501 + new_value_options (SecurityMonitoringRuleNewValueOptions): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -196,3 +281,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_query.py b/src/datadog_api_client/v2/model/security_monitoring_rule_query.py index a6cc84cc41..568af9a7dc 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_query.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_query.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,93 @@ def discriminator(): "query": "query", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleQuery - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_rule (SecurityMonitoringRuntimeAgentRule): [optional] # noqa: E501 + aggregation (SecurityMonitoringRuleQueryAggregation): [optional] # noqa: E501 + distinct_fields ([str]): Field for which the cardinality is measured. Sent as an array.. [optional] # noqa: E501 + group_by_fields ([str]): Fields to group by.. [optional] # noqa: E501 + metric (str): The target field to aggregate over when using the sum or max aggregations.. [optional] # noqa: E501 + name (str): Name of the query.. [optional] # noqa: E501 + query (str): Query to run on logs.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -190,3 +277,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_query_aggregation.py b/src/datadog_api_client/v2/model/security_monitoring_rule_query_aggregation.py index 698408cf94..88c8c23d01 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_query_aggregation.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_query_aggregation.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleQueryAggregation(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleQueryAggregation - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The aggregation type.., must be one of ["count", "cardinality", "sum", "max", "new_value", ] # noqa: E501 + + Keyword Args: + value (str): The aggregation type.., must be one of ["count", "cardinality", "sum", "max", "new_value", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_query_create.py b/src/datadog_api_client/v2/model/security_monitoring_rule_query_create.py index 42c9aa5039..cbe9d97e7e 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_query_create.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_query_create.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -99,8 +101,96 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, query, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleQueryCreate - a model defined in OpenAPI + + Args: + query (str): Query to run on logs. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_rule (SecurityMonitoringRuntimeAgentRule): [optional] # noqa: E501 + aggregation (SecurityMonitoringRuleQueryAggregation): [optional] # noqa: E501 + distinct_fields ([str]): Field for which the cardinality is measured. Sent as an array.. [optional] # noqa: E501 + group_by_fields ([str]): Fields to group by.. [optional] # noqa: E501 + metric (str): The target field to aggregate over when using the sum or max aggregations.. [optional] # noqa: E501 + name (str): Name of the query.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.query = query + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -193,3 +283,8 @@ def __init__(self, query, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_response.py b/src/datadog_api_client/v2/model/security_monitoring_rule_response.py index 0d182757d2..da2e658193 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_response.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -119,8 +121,102 @@ def discriminator(): "version": "version", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cases ([SecurityMonitoringRuleCase]): Cases for generating signals.. [optional] # noqa: E501 + created_at (int): When the rule was created, timestamp in milliseconds.. [optional] # noqa: E501 + creation_author_id (int): User ID of the user who created the rule.. [optional] # noqa: E501 + filters ([SecurityMonitoringFilter]): Additional queries to filter matched events before they are processed.. [optional] # noqa: E501 + has_extended_title (bool): Whether the notifications include the triggering group-by values in their title.. [optional] # noqa: E501 + id (str): The ID of the rule.. [optional] # noqa: E501 + is_default (bool): Whether the rule is included by default.. [optional] # noqa: E501 + is_deleted (bool): Whether the rule has been deleted.. [optional] # noqa: E501 + is_enabled (bool): Whether the rule is enabled.. [optional] # noqa: E501 + message (str): Message for generated signals.. [optional] # noqa: E501 + name (str): The name of the rule.. [optional] # noqa: E501 + options (SecurityMonitoringRuleOptions): [optional] # noqa: E501 + queries ([SecurityMonitoringRuleQuery]): Queries for selecting logs which are part of the rule.. [optional] # noqa: E501 + tags ([str]): Tags for generated signals.. [optional] # noqa: E501 + update_author_id (int): User ID of the user who updated the rule.. [optional] # noqa: E501 + version (int): The version of the rule.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -219,3 +315,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_severity.py b/src/datadog_api_client/v2/model/security_monitoring_rule_severity.py index 20de88226b..3637aa94f5 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_severity.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_severity.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuleSeverity(ModelSimple): @@ -78,6 +80,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -181,3 +185,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringRuleSeverity - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Severity of the Security Signal.., must be one of ["info", "low", "medium", "high", "critical", ] # noqa: E501 + + Keyword Args: + value (str): Severity of the Security Signal.., must be one of ["info", "low", "medium", "high", "critical", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_rule_update_payload.py b/src/datadog_api_client/v2/model/security_monitoring_rule_update_payload.py index 5a824310a5..fd5c54ef41 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_rule_update_payload.py +++ b/src/datadog_api_client/v2/model/security_monitoring_rule_update_payload.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -111,8 +113,96 @@ def discriminator(): "version": "version", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuleUpdatePayload - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cases ([SecurityMonitoringRuleCase]): Cases for generating signals.. [optional] # noqa: E501 + filters ([SecurityMonitoringFilter]): Additional queries to filter matched events before they are processed.. [optional] # noqa: E501 + has_extended_title (bool): Whether the notifications include the triggering group-by values in their title.. [optional] # noqa: E501 + is_enabled (bool): Whether the rule is enabled.. [optional] # noqa: E501 + message (str): Message for generated signals.. [optional] # noqa: E501 + name (str): Name of the rule.. [optional] # noqa: E501 + options (SecurityMonitoringRuleOptions): [optional] # noqa: E501 + queries ([SecurityMonitoringRuleQuery]): Queries for selecting logs which are part of the rule.. [optional] # noqa: E501 + tags ([str]): Tags for generated signals.. [optional] # noqa: E501 + version (int): The version of the rule being updated.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -205,3 +295,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_runtime_agent_rule.py b/src/datadog_api_client/v2/model/security_monitoring_runtime_agent_rule.py index 4bd4ccda02..4cbccfef5c 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_runtime_agent_rule.py +++ b/src/datadog_api_client/v2/model/security_monitoring_runtime_agent_rule.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringRuntimeAgentRule(ModelNormal): @@ -78,8 +80,88 @@ def discriminator(): "expression": "expression", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringRuntimeAgentRule - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + agent_rule_id (str): The Agent rule ID. Must be unique within the rule.. [optional] # noqa: E501 + expression (str): A Runtime Security expression determines what activity should be collected by the Datadog Agent. These logical expressions can use predefined operators and attributes. Tags cannot be used in Runtime Security expressions. Instead, allow or deny based on tags under the advanced option.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -164,3 +246,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal.py b/src/datadog_api_client/v2/model/security_monitoring_signal.py index d35d80429c..08fa32383f 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignal - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (SecurityMonitoringSignalAttributes): [optional] # noqa: E501 + id (str): The unique ID of the security signal.. [optional] # noqa: E501 + type (SecurityMonitoringSignalType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal_attributes.py b/src/datadog_api_client/v2/model/security_monitoring_signal_attributes.py index cf2ffdcd1c..2c69134579 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal_attributes.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalAttributes(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "timestamp": "timestamp", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): A JSON object of attributes in the security signal.. [optional] # noqa: E501 + message (str): The message in the security signal defined by the rule that generated the signal.. [optional] # noqa: E501 + tags ([bool, date, datetime, dict, float, int, list, str, none_type]): An array of tags associated with the security signal.. [optional] # noqa: E501 + timestamp (datetime): The timestamp of the security signal.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request.py b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request.py index fedd77bee5..759ea0330c 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,89 @@ def discriminator(): "sort": "sort", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalListRequest - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + filter (SecurityMonitoringSignalListRequestFilter): [optional] # noqa: E501 + page (SecurityMonitoringSignalListRequestPage): [optional] # noqa: E501 + sort (SecurityMonitoringSignalsSort): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_filter.py b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_filter.py index deada4d02d..9736b2aad6 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_filter.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_filter.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalListRequestFilter(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "to": "to", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalListRequestFilter - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + _from (datetime): The minimum timestamp for requested security signals.. [optional] # noqa: E501 + query (str): Search query for listing security signals.. [optional] # noqa: E501 + to (datetime): The maximum timestamp for requested security signals.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_page.py b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_page.py index c00950ddc7..d3290fcf5d 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_page.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal_list_request_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalListRequestPage(ModelNormal): @@ -82,8 +84,88 @@ def discriminator(): "limit": "limit", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalListRequestPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + cursor (str): A list of results using the cursor provided in the previous query.. [optional] # noqa: E501 + limit (int): The maximum number of security signals in the response.. [optional] if omitted the server will use the default value of 10 # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signal_type.py b/src/datadog_api_client/v2/model/security_monitoring_signal_type.py index ab75e74236..c98ff7504a 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signal_type.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signal_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringSignalType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The type of event.. if omitted defaults to "signal", must be one of ["signal", ] # noqa: E501 + + Keyword Args: + value (str): The type of event.. if omitted defaults to "signal", must be one of ["signal", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "signal" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response.py b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response.py index 1e1fe4bb4d..5b1641432d 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,89 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalsListResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([SecurityMonitoringSignal]): An array of security signals matching the request.. [optional] # noqa: E501 + links (SecurityMonitoringSignalsListResponseLinks): [optional] # noqa: E501 + meta (SecurityMonitoringSignalsListResponseMeta): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_links.py b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_links.py index 17cabd0e9f..6a743ee296 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_links.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_links.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalsListResponseLinks(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "next": "next", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalsListResponseLinks - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + next (str): The link for the next set of results. **Note**: The request can also be made using the POST endpoint.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta.py b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta.py index 9afeedc18d..2eb0bbe701 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -85,8 +87,87 @@ def discriminator(): "page": "page", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalsListResponseMeta - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + page (SecurityMonitoringSignalsListResponseMetaPage): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +251,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta_page.py b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta_page.py index 62d663c6d1..80bb8d2511 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta_page.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signals_list_response_meta_page.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalsListResponseMetaPage(ModelNormal): @@ -76,8 +78,87 @@ def discriminator(): "after": "after", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """SecurityMonitoringSignalsListResponseMetaPage - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + after (str): The cursor used to get the next results, if any. To make the next request, use the same parameters with the addition of the `page[cursor]`.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -161,3 +242,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/security_monitoring_signals_sort.py b/src/datadog_api_client/v2/model/security_monitoring_signals_sort.py index a8f63a833f..885b9cb9a5 100644 --- a/src/datadog_api_client/v2/model/security_monitoring_signals_sort.py +++ b/src/datadog_api_client/v2/model/security_monitoring_signals_sort.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class SecurityMonitoringSignalsSort(ModelSimple): @@ -75,6 +77,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -178,3 +182,99 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """SecurityMonitoringSignalsSort - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): The sort parameters used for querying security signals.., must be one of ["timestamp", "-timestamp", ] # noqa: E501 + + Keyword Args: + value (str): The sort parameters used for querying security signals.., must be one of ["timestamp", "-timestamp", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/user.py b/src/datadog_api_client/v2/model/user.py index 0a9977f844..f8e3b9b772 100644 --- a/src/datadog_api_client/v2/model/user.py +++ b/src/datadog_api_client/v2/model/user.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -93,8 +95,90 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """User - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserAttributes): [optional] # noqa: E501 + id (str): ID of the user.. [optional] # noqa: E501 + relationships (UserResponseRelationships): [optional] # noqa: E501 + type (UsersType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +265,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_attributes.py b/src/datadog_api_client/v2/model/user_attributes.py index 5c95cea9c8..c177b81f88 100644 --- a/src/datadog_api_client/v2/model/user_attributes.py +++ b/src/datadog_api_client/v2/model/user_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UserAttributes(ModelNormal): @@ -94,8 +96,96 @@ def discriminator(): "verified": "verified", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the user.. [optional] # noqa: E501 + disabled (bool): Whether the user is disabled.. [optional] # noqa: E501 + email (str): Email of the user.. [optional] # noqa: E501 + handle (str): Handle of the user.. [optional] # noqa: E501 + icon (str): URL of the user's icon.. [optional] # noqa: E501 + modified_at (datetime): Time that the user was last modified.. [optional] # noqa: E501 + name (str): Name of the user.. [optional] # noqa: E501 + status (str): Status of the user.. [optional] # noqa: E501 + title (str): Title of the user.. [optional] # noqa: E501 + verified (bool): Whether the user is verified.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -188,3 +278,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_create_attributes.py b/src/datadog_api_client/v2/model/user_create_attributes.py index 6097d215db..368dbaeafa 100644 --- a/src/datadog_api_client/v2/model/user_create_attributes.py +++ b/src/datadog_api_client/v2/model/user_create_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UserCreateAttributes(ModelNormal): @@ -80,8 +82,92 @@ def discriminator(): "title": "title", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, email, *args, **kwargs): # noqa: E501 + """UserCreateAttributes - a model defined in OpenAPI + + Args: + email (str): The email of the user. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): The name of the user.. [optional] # noqa: E501 + title (str): The title of the user.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.email = email + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +256,8 @@ def __init__(self, email, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_create_data.py b/src/datadog_api_client/v2/model/user_create_data.py index 425644c121..48cf251d49 100644 --- a/src/datadog_api_client/v2/model/user_create_data.py +++ b/src/datadog_api_client/v2/model/user_create_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,93 @@ def discriminator(): "relationships": "relationships", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, type, *args, **kwargs): # noqa: E501 + """UserCreateData - a model defined in OpenAPI + + Args: + attributes (UserCreateAttributes): + type (UsersType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + relationships (UserRelationships): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -182,3 +269,8 @@ def __init__(self, attributes, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_create_request.py b/src/datadog_api_client/v2/model/user_create_request.py index 46bfb7bc33..fe003dd783 100644 --- a/src/datadog_api_client/v2/model/user_create_request.py +++ b/src/datadog_api_client/v2/model/user_create_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """UserCreateRequest - a model defined in OpenAPI + + Args: + data (UserCreateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitation_data.py b/src/datadog_api_client/v2/model/user_invitation_data.py index 77ac88ce4a..0fdab10948 100644 --- a/src/datadog_api_client/v2/model/user_invitation_data.py +++ b/src/datadog_api_client/v2/model/user_invitation_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,92 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, relationships, type, *args, **kwargs): # noqa: E501 + """UserInvitationData - a model defined in OpenAPI + + Args: + relationships (UserInvitationRelationships): + type (UserInvitationsType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.relationships = relationships + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -177,3 +263,8 @@ def __init__(self, relationships, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitation_data_attributes.py b/src/datadog_api_client/v2/model/user_invitation_data_attributes.py index 339d43e2b6..ecd0f34c37 100644 --- a/src/datadog_api_client/v2/model/user_invitation_data_attributes.py +++ b/src/datadog_api_client/v2/model/user_invitation_data_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UserInvitationDataAttributes(ModelNormal): @@ -82,8 +84,90 @@ def discriminator(): "uuid": "uuid", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserInvitationDataAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + created_at (datetime): Creation time of the user invitation.. [optional] # noqa: E501 + expires_at (datetime): Time of invitation expiration.. [optional] # noqa: E501 + invite_type (str): Type of invitation.. [optional] # noqa: E501 + uuid (str): UUID of the user invitation.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -170,3 +254,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitation_relationships.py b/src/datadog_api_client/v2/model/user_invitation_relationships.py index a745d8f4f2..68b5b35ac5 100644 --- a/src/datadog_api_client/v2/model/user_invitation_relationships.py +++ b/src/datadog_api_client/v2/model/user_invitation_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "user": "user", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, user, *args, **kwargs): # noqa: E501 + """UserInvitationRelationships - a model defined in OpenAPI + + Args: + user (RelationshipToUser): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.user = user + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, user, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitation_response.py b/src/datadog_api_client/v2/model/user_invitation_response.py index 337bc9df57..1de4888624 100644 --- a/src/datadog_api_client/v2/model/user_invitation_response.py +++ b/src/datadog_api_client/v2/model/user_invitation_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserInvitationResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (UserInvitationResponseData): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitation_response_data.py b/src/datadog_api_client/v2/model/user_invitation_response_data.py index 8a47c73c6c..de8d780d76 100644 --- a/src/datadog_api_client/v2/model/user_invitation_response_data.py +++ b/src/datadog_api_client/v2/model/user_invitation_response_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,89 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserInvitationResponseData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (UserInvitationDataAttributes): [optional] # noqa: E501 + id (str): ID of the user invitation.. [optional] # noqa: E501 + type (UserInvitationsType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -176,3 +259,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitations_request.py b/src/datadog_api_client/v2/model/user_invitations_request.py index 513efc214e..ca0bf604d4 100644 --- a/src/datadog_api_client/v2/model/user_invitations_request.py +++ b/src/datadog_api_client/v2/model/user_invitations_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """UserInvitationsRequest - a model defined in OpenAPI + + Args: + data ([UserInvitationData]): List of user invitations. + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitations_response.py b/src/datadog_api_client/v2/model/user_invitations_response.py index c0651b149e..021e8317f4 100644 --- a/src/datadog_api_client/v2/model/user_invitations_response.py +++ b/src/datadog_api_client/v2/model/user_invitations_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserInvitationsResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([UserInvitationResponseData]): Array of user invitations.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_invitations_type.py b/src/datadog_api_client/v2/model/user_invitations_type.py index 94809816e6..4e111ed900 100644 --- a/src/datadog_api_client/v2/model/user_invitations_type.py +++ b/src/datadog_api_client/v2/model/user_invitations_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UserInvitationsType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UserInvitationsType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): User invitations type.. if omitted defaults to "user_invitations", must be one of ["user_invitations", ] # noqa: E501 + + Keyword Args: + value (str): User invitations type.. if omitted defaults to "user_invitations", must be one of ["user_invitations", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "user_invitations" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model/user_relationships.py b/src/datadog_api_client/v2/model/user_relationships.py index 3e2519f629..46862b0db4 100644 --- a/src/datadog_api_client/v2/model/user_relationships.py +++ b/src/datadog_api_client/v2/model/user_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,87 @@ def discriminator(): "roles": "roles", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + roles (RelationshipToRoles): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -168,3 +249,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_response.py b/src/datadog_api_client/v2/model/user_response.py index aca99dfdc6..fbb5f68628 100644 --- a/src/datadog_api_client/v2/model/user_response.py +++ b/src/datadog_api_client/v2/model/user_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -87,8 +89,88 @@ def discriminator(): "included": "included", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data (User): [optional] # noqa: E501 + included ([UserResponseIncludedItem]): Array of objects related to the user.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -173,3 +255,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_response_included_item.py b/src/datadog_api_client/v2/model/user_response_included_item.py index 2c7cdb3c6f..78c3bba675 100644 --- a/src/datadog_api_client/v2/model/user_response_included_item.py +++ b/src/datadog_api_client/v2/model/user_response_included_item.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -66,24 +68,7 @@ class UserResponseIncludedItem(ModelComposed): validations = {} - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + additional_properties_type = None _nullable = False @@ -105,6 +90,91 @@ def discriminator(): attribute_map = {} + read_only_vars = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserResponseIncludedItem - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + attributes (RoleAttributes): [optional] # noqa: E501 + id (str): ID of the role.. [optional] # noqa: E501 + relationships (RoleResponseRelationships): [optional] # noqa: E501 + type (RolesType): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + "_check_type": _check_type, + "_path_to_item": _path_to_item, + "_spec_property_naming": _spec_property_naming, + "_configuration": _configuration, + "_visited_composed_classes": self._visited_composed_classes, + } + composed_info = validate_get_composed_info(constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + return self + required_properties = set( [ "_data_store", @@ -191,28 +261,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 "_configuration": _configuration, "_visited_composed_classes": self._visited_composed_classes, } - required_args = {} - model_args = {} - model_args.update(required_args) - model_args.update(kwargs) - composed_info = validate_get_composed_info(constant_args, model_args, self) + composed_info = validate_get_composed_info(constant_args, kwargs, self) self._composed_instances = composed_info[0] self._var_name_to_model_instances = composed_info[1] self._additional_properties_model_instances = composed_info[2] - unused_args = composed_info[3] - - for var_name, var_value in required_args.items(): - setattr(self, var_name, var_value) - for var_name, var_value in kwargs.items(): - if ( - var_name in unused_args - and self._configuration is not None - and self._configuration.discard_unknown_keys - and not self._additional_properties_model_instances - ): - # discard variable. - continue - setattr(self, var_name, var_value) + discarded_args = composed_info[3] @cached_property def _composed_schemas(): diff --git a/src/datadog_api_client/v2/model/user_response_relationships.py b/src/datadog_api_client/v2/model/user_response_relationships.py index 6d3601fbf4..a20bf006aa 100644 --- a/src/datadog_api_client/v2/model/user_response_relationships.py +++ b/src/datadog_api_client/v2/model/user_response_relationships.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -95,8 +97,90 @@ def discriminator(): "roles": "roles", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserResponseRelationships - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + org (RelationshipToOrganization): [optional] # noqa: E501 + other_orgs (RelationshipToOrganizations): [optional] # noqa: E501 + other_users (RelationshipToUsers): [optional] # noqa: E501 + roles (RelationshipToRoles): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -183,3 +267,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_update_attributes.py b/src/datadog_api_client/v2/model/user_update_attributes.py index d260f92df3..e6581b55ed 100644 --- a/src/datadog_api_client/v2/model/user_update_attributes.py +++ b/src/datadog_api_client/v2/model/user_update_attributes.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UserUpdateAttributes(ModelNormal): @@ -80,8 +82,89 @@ def discriminator(): "name": "name", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UserUpdateAttributes - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + disabled (bool): If the user is enabled or disabled.. [optional] # noqa: E501 + email (str): The email of the user.. [optional] # noqa: E501 + name (str): The name of the user.. [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -167,3 +250,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_update_data.py b/src/datadog_api_client/v2/model/user_update_data.py index c065696e77..9ffe82e8fe 100644 --- a/src/datadog_api_client/v2/model/user_update_data.py +++ b/src/datadog_api_client/v2/model/user_update_data.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -89,8 +91,94 @@ def discriminator(): "type": "type", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, attributes, id, type, *args, **kwargs): # noqa: E501 + """UserUpdateData - a model defined in OpenAPI + + Args: + attributes (UserUpdateAttributes): + id (str): ID of the user. + type (UsersType): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.attributes = attributes + self.id = id + self.type = type + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -181,3 +269,8 @@ def __init__(self, attributes, id, type, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/user_update_request.py b/src/datadog_api_client/v2/model/user_update_request.py index 1f858efb30..97c3e14d5f 100644 --- a/src/datadog_api_client/v2/model/user_update_request.py +++ b/src/datadog_api_client/v2/model/user_update_request.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -83,8 +85,90 @@ def discriminator(): "data": "data", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, data, *args, **kwargs): # noqa: E501 + """UserUpdateRequest - a model defined in OpenAPI + + Args: + data (UserUpdateData): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.data = data + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -171,3 +255,8 @@ def __init__(self, data, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/users_response.py b/src/datadog_api_client/v2/model/users_response.py index 48c4df1edf..b6bbbc4680 100644 --- a/src/datadog_api_client/v2/model/users_response.py +++ b/src/datadog_api_client/v2/model/users_response.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError def lazy_import(): @@ -91,8 +93,89 @@ def discriminator(): "meta": "meta", # noqa: E501 } + read_only_vars = {} + _composed_schemas = {} + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """UsersResponse - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + data ([User]): Array of returned users.. [optional] # noqa: E501 + included ([UserResponseIncludedItem]): Array of objects related to the users.. [optional] # noqa: E501 + meta (ResponseMetaAttributes): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _path_to_item = kwargs.pop("_path_to_item", ()) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if ( + var_name not in self.attribute_map + and self._configuration is not None + and self._configuration.discard_unknown_keys + and self.additional_properties_type is None + ): + # discard variable. + continue + setattr(self, var_name, var_value) + return self + required_properties = set( [ "_data_store", @@ -178,3 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 # discard variable. continue setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError( + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes." + ) diff --git a/src/datadog_api_client/v2/model/users_type.py b/src/datadog_api_client/v2/model/users_type.py index a1a920e528..82a538ddca 100644 --- a/src/datadog_api_client/v2/model/users_type.py +++ b/src/datadog_api_client/v2/model/users_type.py @@ -20,6 +20,8 @@ none_type, validate_get_composed_info, ) +from ..model_utils import OpenApiModel +from datadog_api_client.v2.exceptions import ApiAttributeError class UsersType(ModelSimple): @@ -74,6 +76,8 @@ def discriminator(): attribute_map = {} + read_only_vars = set() + _composed_schemas = None required_properties = set( @@ -173,3 +177,95 @@ def __init__(self, *args, **kwargs): path_to_item=_path_to_item, valid_classes=(self.__class__,), ) + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """UsersType - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] (str): Users resource type.. if omitted defaults to "users", must be one of ["users", ] # noqa: E501 + + Keyword Args: + value (str): Users resource type.. if omitted defaults to "users", must be one of ["users", ] # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + # required up here when default value is not given + _path_to_item = kwargs.pop("_path_to_item", ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if "value" in kwargs: + value = kwargs.pop("value") + elif args: + args = list(args) + value = args.pop(0) + else: + value = "users" + + _check_type = kwargs.pop("_check_type", True) + _spec_property_naming = kwargs.pop("_spec_property_naming", False) + _configuration = kwargs.pop("_configuration", None) + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." + % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.value = value + if kwargs: + raise ApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." + % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self diff --git a/src/datadog_api_client/v2/model_utils.py b/src/datadog_api_client/v2/model_utils.py index 2a6247f0c3..8daf1328f6 100644 --- a/src/datadog_api_client/v2/model_utils.py +++ b/src/datadog_api_client/v2/model_utils.py @@ -24,9 +24,27 @@ file_type = io.IOBase +def convert_js_args_to_python_args(fn): + from functools import wraps + + @wraps(fn) + def wrapped_init(_self, *args, **kwargs): + """ + An attribute named `self` received from the api will conflicts with the reserved `self` + parameter of a class method. During generation, `self` attributes are mapped + to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. + """ + spec_property_naming = kwargs.get("_spec_property_naming", False) + if spec_property_naming: + kwargs = change_keys_js_to_python(kwargs, _self if isinstance(_self, type) else _self.__class__) + return fn(_self, *args, **kwargs) + + return wrapped_init + + class cached_property(object): # this caches the result of the function call for fn with no inputs - # use this as a decorator on fuction methods that you want converted + # use this as a decorator on function methods that you want converted # into cached properties result_key = "_results" @@ -249,6 +267,109 @@ def __new__(cls, *args, **kwargs): new_inst.__init__(*args, **kwargs) return new_inst + @classmethod + @convert_js_args_to_python_args + def _new_from_openapi_data(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + visited_composed_classes = kwargs.get("_visited_composed_classes", ()) + if cls.discriminator is None or cls in visited_composed_classes: + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: If Animal has a discriminator + # petType and we pass in "Dog", and the class Dog + # allOf includes Animal, we move through Animal + # once using the discriminator, and pick Dog. + # Then in the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return cls._from_openapi_data(*args, **kwargs) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get("_path_to_item", ()) + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class(cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get("_path_to_item", ()) + disc_prop_value = kwargs.get(discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return cls._from_openapi_data(*args, **kwargs) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = cls._composed_schemas.get("oneOf", ()) + cls._composed_schemas.get("anyOf", ()) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs["_visited_composed_classes"] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get("allOf") and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = cls._from_openapi_data(*args, **kwargs) + + new_inst = new_cls._new_from_openapi_data(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -396,22 +517,13 @@ def __setitem__(self, name, value): self.__dict__[name] = value return - # set the attribute on the correct instance - model_instances = self._var_name_to_model_instances.get(name, self._additional_properties_model_instances) - if model_instances: - for model_instance in model_instances: - if model_instance == self: - self.set_attribute(name, value) - else: - setattr(model_instance, name, value) - if name not in self._var_name_to_model_instances: - # we assigned an additional property - self.__dict__["_var_name_to_model_instances"][name] = model_instance - return None - - raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), [e for e in [self._path_to_item, name] if e] - ) + # Set attribute on composed instances + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__["_var_name_to_model_instances"][name] = self._composed_instances + [self] + return None __unset_attribute_value__ = object() @@ -421,12 +533,12 @@ def get(self, name, default=None): return self.__dict__[name] # get the attribute from the correct instance - model_instances = self._var_name_to_model_instances.get(name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get(name) values = [] - # A composed model stores child (oneof/anyOf/allOf) models under - # self._var_name_to_model_instances. A named property can exist in - # multiple child models. If the property is present in more than one - # child model, the value must be the same across all the child models. + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same if model_instances: for model_instance in model_instances: if name in model_instance._data_store: @@ -1102,17 +1214,17 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, configu ) if issubclass(model_class, ModelSimple): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) elif isinstance(model_data, list): if issubclass(model_class, ModelComposed) and allows_single_value_input(model_class): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) else: - return model_class(*model_data, **kw_args) + return model_class._new_from_openapi_data(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) - return model_class(**kw_args) + return model_class._new_from_openapi_data(**kw_args) elif isinstance(model_data, PRIMITIVE_TYPES): - return model_class(model_data, **kw_args) + return model_class._new_from_openapi_data(model_data, **kw_args) def deserialize_file(response_data, configuration, content_disposition=None): @@ -1405,20 +1517,34 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) + seen_json_attribute_names = set() + used_fallback_python_attribute_names = set() + py_to_json_map = {} for model_instance in model_instances: for attr, value in model_instance._data_store.items(): if serialize: # we use get here because additional property key names do not # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) + try: + attr = model_instance.attribute_map[attr] + py_to_json_map.update(model_instance.attribute_map) + seen_json_attribute_names.add(attr) + except KeyError: + used_fallback_python_attribute_names.add(attr) if isinstance(value, list): - if not value or isinstance(value[0], PRIMITIVE_TYPES): - # empty list or primitive types + if not value: + # empty list or None result[attr] = value - elif isinstance(value[0], ModelSimple): - result[attr] = [x.value for x in value] else: - result[attr] = [model_to_dict(x, serialize=serialize) if x is not None else None for x in value] + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict( map( @@ -1434,6 +1560,16 @@ def model_to_dict(model_instance, serialize=True): result[attr] = model_to_dict(value, serialize=serialize) else: result[attr] = value + if serialize: + for python_key in used_fallback_python_attribute_names: + json_key = py_to_json_map.get(python_key) + if json_key is None: + continue + if python_key == json_key: + continue + json_key_assigned_no_need_for_python_key = json_key in seen_json_attribute_names + if json_key_assigned_no_need_for_python_key: + del result[python_key] return result @@ -1472,27 +1608,19 @@ def get_valid_classes_phrase(input_classes): return "is one of [{0}]".format(", ".join(all_class_names)) -def convert_js_args_to_python_args(fn): - from functools import wraps - - @wraps(fn) - def wrapped_init(self, *args, **kwargs): - spec_property_naming = kwargs.get("_spec_property_naming", False) - if spec_property_naming: - kwargs = change_keys_js_to_python(kwargs, self.__class__) - return fn(self, *args, **kwargs) - - return wrapped_init - - def get_allof_instances(self, model_args, constant_args): """ Args: self: the class we are handling model_args (dict): var_name to var_value used to make instances - constant_args (dict): var_name to var_value - used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes Returns composed_instances (list) @@ -1500,20 +1628,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances = [] for allof_class in self._composed_schemas["allOf"]: - # no need to handle changing js keys to python because - # for composed schemas, allof parameters are included in the - # composed schema and were changed to python keys in __new__ - # extract a dict of only required keys from fixed_model_args - kwargs = {} - var_names = set(allof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in model_args: - kwargs[var_name] = model_args[var_name] - - # and use it to make the instance - kwargs.update(constant_args) try: - allof_instance = allof_class(**kwargs) + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1568,30 +1684,9 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): single_value_input = allows_single_value_input(oneof_class) - if not single_value_input: - # transform js keys from input data to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_kwargs, oneof_class) - - # Extract a dict with the properties that are declared in the oneOf schema. - # Undeclared properties (e.g. properties that are allowed because of the - # additionalProperties attribute in the OAS document) are not added to - # the dict. - kwargs = {} - var_names = set(oneof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_kwargs) - try: if not single_value_input: - oneof_instance = oneof_class(**kwargs) + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): oneof_instance = oneof_class(model_arg, **constant_kwargs) @@ -1646,24 +1741,8 @@ def get_anyof_instances(self, model_args, constant_args): # none_type deserialization is handled in the __new__ method continue - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python(model_args, anyof_class) - - # extract a dict of only required keys from these_model_vars - kwargs = {} - var_names = set(anyof_class.openapi_types.keys()) - for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] - - # do not try to make a model with no input args - if len(kwargs) == 0: - continue - - # and use it to make the instance - kwargs.update(constant_args) try: - anyof_instance = anyof_class(**kwargs) + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass @@ -1675,46 +1754,34 @@ def get_anyof_instances(self, model_args, constant_args): return anyof_instances -def get_additional_properties_model_instances(composed_instances, self): - additional_properties_model_instances = [] - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - if instance.additional_properties_type is not None: - additional_properties_model_instances.append(instance) - return additional_properties_model_instances - - -def get_var_name_to_model_instances(self, composed_instances): - var_name_to_model_instances = {} - all_instances = [self] - all_instances.extend(composed_instances) - for instance in all_instances: - for var_name in instance.openapi_types: - if var_name not in var_name_to_model_instances: - var_name_to_model_instances[var_name] = [instance] - else: - var_name_to_model_instances[var_name].append(instance) - return var_name_to_model_instances - - -def get_unused_args(self, composed_instances, model_args): - unused_args = dict(model_args) - # arguments apssed to self were already converted to python names +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names # before __init__ was called - for var_name_py in self.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] for instance in composed_instances: if instance.__class__ in self._composed_schemas["allOf"]: - for var_name_py in instance.attribute_map: - if var_name_py in unused_args: - del unused_args[var_name_py] + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass else: - for var_name_js in instance.attribute_map.values(): - if var_name_js in unused_args: - del unused_args[var_name_js] - return unused_args + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args def validate_get_composed_info(constant_args, model_args, self): @@ -1758,29 +1825,37 @@ def validate_get_composed_info(constant_args, model_args, self): composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] - # map variable names to composed_instances - var_name_to_model_instances = get_var_name_to_model_instances(self, composed_instances) - - # set additional_properties_model_instances - additional_properties_model_instances = get_additional_properties_model_instances(composed_instances, self) - - # set any remaining values - unused_args = get_unused_args(self, composed_instances, model_args) - if ( - len(unused_args) > 0 - and len(additional_properties_model_instances) == 0 - and (self._configuration is None or not self._configuration.discard_unknown_keys) - ): - raise ApiValueError( - "Invalid input arguments input when making an instance of " - "class %s. Not all inputs were used. The unused input data " - "is %s" % (self.__class__.__name__, unused_args) - ) + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) - # no need to add additional_properties to var_name_to_model_instances here - # because additional_properties_model_instances will direct us to that - # instance when we use getattr or setattr - # and we update var_name_to_model_instances in setattr + # map variable names to composed_instances + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances - return [composed_instances, var_name_to_model_instances, additional_properties_model_instances, unused_args] + return [composed_instances, var_name_to_model_instances, additional_properties_model_instances, discarded_args] diff --git a/src/datadog_api_client/v2/rest.py b/src/datadog_api_client/v2/rest.py index b390a351eb..1646853b2e 100644 --- a/src/datadog_api_client/v2/rest.py +++ b/src/datadog_api_client/v2/rest.py @@ -140,15 +140,15 @@ def request( elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) - if "Content-Type" not in headers: - headers["Content-Type"] = "application/json" - try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests + if (method != "DELETE") and ("Content-Type" not in headers): + headers["Content-Type"] = "application/json" if query_params: url += "?" + urlencode(query_params) - if re.search("json", headers["Content-Type"], re.IGNORECASE): + if ("Content-Type" not in headers) or (re.search("json", headers["Content-Type"], re.IGNORECASE)): request_body = None if body is not None: request_body = json.dumps(body) diff --git a/tests/v1/features/synthetics.feature b/tests/v1/features/synthetics.feature index 8f0482cead..e7b33f09ca 100644 --- a/tests/v1/features/synthetics.feature +++ b/tests/v1/features/synthetics.feature @@ -15,7 +15,7 @@ Feature: Synthetics And a valid "appKeyAuth" key in the system And an instance of "Synthetics" API - @replay-only @skip-python @skip-typescript @skip-java @skip-ruby + @replay-only @skip-java @skip-python @skip-ruby @skip-typescript Scenario: Client is resilient to enum and oneOf deserialization errors Given new "ListTests" request When the request is sent