From b66dd55b128758cc929a1633ab6e15f8385873a1 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 3 Jan 2019 16:53:58 -0800 Subject: python codegen --- python/fatcat_client/README.md | 3 + python/fatcat_client/__init__.py | 2 + python/fatcat_client/api/default_api.py | 97 ++++++++++++ python/fatcat_client/models/__init__.py | 2 + python/fatcat_client/models/auth_oidc.py | 167 +++++++++++++++++++++ python/fatcat_client/models/auth_oidc_result.py | 142 ++++++++++++++++++ python/fatcat_client/models/editor.py | 84 ++++++++++- python/tests/codegen_tests/test_auth_oidc.py | 40 +++++ .../tests/codegen_tests/test_auth_oidc_result.py | 40 +++++ python/tests/codegen_tests/test_default_api.py | 6 + 10 files changed, 580 insertions(+), 3 deletions(-) create mode 100644 python/fatcat_client/models/auth_oidc.py create mode 100644 python/fatcat_client/models/auth_oidc_result.py create mode 100644 python/tests/codegen_tests/test_auth_oidc.py create mode 100644 python/tests/codegen_tests/test_auth_oidc_result.py diff --git a/python/fatcat_client/README.md b/python/fatcat_client/README.md index 069eb1b4..d03a4092 100644 --- a/python/fatcat_client/README.md +++ b/python/fatcat_client/README.md @@ -74,6 +74,7 @@ All URIs are relative to *https://api.fatcat.wiki/v0* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *DefaultApi* | [**accept_editgroup**](docs/DefaultApi.md#accept_editgroup) | **POST** /editgroup/{editgroup_id}/accept | +*DefaultApi* | [**auth_oidc**](docs/DefaultApi.md#auth_oidc) | **POST** /auth/oidc | *DefaultApi* | [**create_container**](docs/DefaultApi.md#create_container) | **POST** /container | *DefaultApi* | [**create_container_batch**](docs/DefaultApi.md#create_container_batch) | **POST** /container/batch | *DefaultApi* | [**create_creator**](docs/DefaultApi.md#create_creator) | **POST** /creator | @@ -163,6 +164,8 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AuthOidc](docs/AuthOidc.md) + - [AuthOidcResult](docs/AuthOidcResult.md) - [ChangelogEntry](docs/ChangelogEntry.md) - [ContainerEntity](docs/ContainerEntity.md) - [CreatorEntity](docs/CreatorEntity.md) diff --git a/python/fatcat_client/__init__.py b/python/fatcat_client/__init__.py index 6b08c0b1..e9a04942 100644 --- a/python/fatcat_client/__init__.py +++ b/python/fatcat_client/__init__.py @@ -22,6 +22,8 @@ from fatcat_client.api.default_api import DefaultApi from fatcat_client.api_client import ApiClient from fatcat_client.configuration import Configuration # import models into sdk package +from fatcat_client.models.auth_oidc import AuthOidc +from fatcat_client.models.auth_oidc_result import AuthOidcResult from fatcat_client.models.changelog_entry import ChangelogEntry from fatcat_client.models.container_entity import ContainerEntity from fatcat_client.models.creator_entity import CreatorEntity diff --git a/python/fatcat_client/api/default_api.py b/python/fatcat_client/api/default_api.py index 5cb5dc64..a0a193f0 100644 --- a/python/fatcat_client/api/default_api.py +++ b/python/fatcat_client/api/default_api.py @@ -138,6 +138,103 @@ class DefaultApi(object): _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + def auth_oidc(self, oidc_params, **kwargs): # noqa: E501 + """auth_oidc # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.auth_oidc(oidc_params, async=True) + >>> result = thread.get() + + :param async bool + :param AuthOidc oidc_params: (required) + :return: AuthOidcResult + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async'): + return self.auth_oidc_with_http_info(oidc_params, **kwargs) # noqa: E501 + else: + (data) = self.auth_oidc_with_http_info(oidc_params, **kwargs) # noqa: E501 + return data + + def auth_oidc_with_http_info(self, oidc_params, **kwargs): # noqa: E501 + """auth_oidc # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.auth_oidc_with_http_info(oidc_params, async=True) + >>> result = thread.get() + + :param async bool + :param AuthOidc oidc_params: (required) + :return: AuthOidcResult + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['oidc_params'] # 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 auth_oidc" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'oidc_params' is set + if ('oidc_params' not in params or + params['oidc_params'] is None): + raise ValueError("Missing the required parameter `oidc_params` when calling `auth_oidc`") # noqa: E501 + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'oidc_params' in params: + body_params = params['oidc_params'] + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['Bearer'] # noqa: E501 + + return self.api_client.call_api( + '/auth/oidc', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='AuthOidcResult', # 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) + def create_container(self, entity, **kwargs): # noqa: E501 """create_container # noqa: E501 diff --git a/python/fatcat_client/models/__init__.py b/python/fatcat_client/models/__init__.py index f4716d61..ef77b4fd 100644 --- a/python/fatcat_client/models/__init__.py +++ b/python/fatcat_client/models/__init__.py @@ -15,6 +15,8 @@ from __future__ import absolute_import # import models into model package +from fatcat_client.models.auth_oidc import AuthOidc +from fatcat_client.models.auth_oidc_result import AuthOidcResult from fatcat_client.models.changelog_entry import ChangelogEntry from fatcat_client.models.container_entity import ContainerEntity from fatcat_client.models.creator_entity import CreatorEntity diff --git a/python/fatcat_client/models/auth_oidc.py b/python/fatcat_client/models/auth_oidc.py new file mode 100644 index 00000000..871cc23d --- /dev/null +++ b/python/fatcat_client/models/auth_oidc.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +import pprint +import re # noqa: F401 + +import six + + +class AuthOidc(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + 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 = { + 'provider': 'str', + 'sub': 'str', + 'iss': 'str' + } + + attribute_map = { + 'provider': 'provider', + 'sub': 'sub', + 'iss': 'iss' + } + + def __init__(self, provider=None, sub=None, iss=None): # noqa: E501 + """AuthOidc - a model defined in Swagger""" # noqa: E501 + + self._provider = None + self._sub = None + self._iss = None + self.discriminator = None + + self.provider = provider + self.sub = sub + self.iss = iss + + @property + def provider(self): + """Gets the provider of this AuthOidc. # noqa: E501 + + + :return: The provider of this AuthOidc. # noqa: E501 + :rtype: str + """ + return self._provider + + @provider.setter + def provider(self, provider): + """Sets the provider of this AuthOidc. + + + :param provider: The provider of this AuthOidc. # noqa: E501 + :type: str + """ + if provider is None: + raise ValueError("Invalid value for `provider`, must not be `None`") # noqa: E501 + + self._provider = provider + + @property + def sub(self): + """Gets the sub of this AuthOidc. # noqa: E501 + + + :return: The sub of this AuthOidc. # noqa: E501 + :rtype: str + """ + return self._sub + + @sub.setter + def sub(self, sub): + """Sets the sub of this AuthOidc. + + + :param sub: The sub of this AuthOidc. # noqa: E501 + :type: str + """ + if sub is None: + raise ValueError("Invalid value for `sub`, must not be `None`") # noqa: E501 + + self._sub = sub + + @property + def iss(self): + """Gets the iss of this AuthOidc. # noqa: E501 + + + :return: The iss of this AuthOidc. # noqa: E501 + :rtype: str + """ + return self._iss + + @iss.setter + def iss(self, iss): + """Sets the iss of this AuthOidc. + + + :param iss: The iss of this AuthOidc. # noqa: E501 + :type: str + """ + if iss is None: + raise ValueError("Invalid value for `iss`, must not be `None`") # noqa: E501 + + self._iss = iss + + 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, AuthOidc): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/python/fatcat_client/models/auth_oidc_result.py b/python/fatcat_client/models/auth_oidc_result.py new file mode 100644 index 00000000..5e31a574 --- /dev/null +++ b/python/fatcat_client/models/auth_oidc_result.py @@ -0,0 +1,142 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +import pprint +import re # noqa: F401 + +import six + +from fatcat_client.models.editor import Editor # noqa: F401,E501 + + +class AuthOidcResult(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + 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 = { + 'editor': 'Editor', + 'token': 'str' + } + + attribute_map = { + 'editor': 'editor', + 'token': 'token' + } + + def __init__(self, editor=None, token=None): # noqa: E501 + """AuthOidcResult - a model defined in Swagger""" # noqa: E501 + + self._editor = None + self._token = None + self.discriminator = None + + self.editor = editor + self.token = token + + @property + def editor(self): + """Gets the editor of this AuthOidcResult. # noqa: E501 + + + :return: The editor of this AuthOidcResult. # noqa: E501 + :rtype: Editor + """ + return self._editor + + @editor.setter + def editor(self, editor): + """Sets the editor of this AuthOidcResult. + + + :param editor: The editor of this AuthOidcResult. # noqa: E501 + :type: Editor + """ + if editor is None: + raise ValueError("Invalid value for `editor`, must not be `None`") # noqa: E501 + + self._editor = editor + + @property + def token(self): + """Gets the token of this AuthOidcResult. # noqa: E501 + + + :return: The token of this AuthOidcResult. # noqa: E501 + :rtype: str + """ + return self._token + + @token.setter + def token(self, token): + """Sets the token of this AuthOidcResult. + + + :param token: The token of this AuthOidcResult. # noqa: E501 + :type: str + """ + if token is None: + raise ValueError("Invalid value for `token`, must not be `None`") # noqa: E501 + + self._token = token + + 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, AuthOidcResult): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/python/fatcat_client/models/editor.py b/python/fatcat_client/models/editor.py index 2010d454..493f5d81 100644 --- a/python/fatcat_client/models/editor.py +++ b/python/fatcat_client/models/editor.py @@ -32,24 +32,39 @@ class Editor(object): """ swagger_types = { 'editor_id': 'str', - 'username': 'str' + 'username': 'str', + 'is_admin': 'bool', + 'is_bot': 'bool', + 'is_active': 'bool' } attribute_map = { 'editor_id': 'editor_id', - 'username': 'username' + 'username': 'username', + 'is_admin': 'is_admin', + 'is_bot': 'is_bot', + 'is_active': 'is_active' } - def __init__(self, editor_id=None, username=None): # noqa: E501 + def __init__(self, editor_id=None, username=None, is_admin=None, is_bot=None, is_active=None): # noqa: E501 """Editor - a model defined in Swagger""" # noqa: E501 self._editor_id = None self._username = None + self._is_admin = None + self._is_bot = None + self._is_active = None self.discriminator = None if editor_id is not None: self.editor_id = editor_id self.username = username + if is_admin is not None: + self.is_admin = is_admin + if is_bot is not None: + self.is_bot = is_bot + if is_active is not None: + self.is_active = is_active @property def editor_id(self): @@ -103,6 +118,69 @@ class Editor(object): self._username = username + @property + def is_admin(self): + """Gets the is_admin of this Editor. # noqa: E501 + + + :return: The is_admin of this Editor. # noqa: E501 + :rtype: bool + """ + return self._is_admin + + @is_admin.setter + def is_admin(self, is_admin): + """Sets the is_admin of this Editor. + + + :param is_admin: The is_admin of this Editor. # noqa: E501 + :type: bool + """ + + self._is_admin = is_admin + + @property + def is_bot(self): + """Gets the is_bot of this Editor. # noqa: E501 + + + :return: The is_bot of this Editor. # noqa: E501 + :rtype: bool + """ + return self._is_bot + + @is_bot.setter + def is_bot(self, is_bot): + """Sets the is_bot of this Editor. + + + :param is_bot: The is_bot of this Editor. # noqa: E501 + :type: bool + """ + + self._is_bot = is_bot + + @property + def is_active(self): + """Gets the is_active of this Editor. # noqa: E501 + + + :return: The is_active of this Editor. # noqa: E501 + :rtype: bool + """ + return self._is_active + + @is_active.setter + def is_active(self, is_active): + """Sets the is_active of this Editor. + + + :param is_active: The is_active of this Editor. # noqa: E501 + :type: bool + """ + + self._is_active = is_active + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/python/tests/codegen_tests/test_auth_oidc.py b/python/tests/codegen_tests/test_auth_oidc.py new file mode 100644 index 00000000..f799da55 --- /dev/null +++ b/python/tests/codegen_tests/test_auth_oidc.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.auth_oidc import AuthOidc # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestAuthOidc(unittest.TestCase): + """AuthOidc unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAuthOidc(self): + """Test AuthOidc""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.auth_oidc.AuthOidc() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_auth_oidc_result.py b/python/tests/codegen_tests/test_auth_oidc_result.py new file mode 100644 index 00000000..d99ef446 --- /dev/null +++ b/python/tests/codegen_tests/test_auth_oidc_result.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.auth_oidc_result import AuthOidcResult # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestAuthOidcResult(unittest.TestCase): + """AuthOidcResult unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAuthOidcResult(self): + """Test AuthOidcResult""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.auth_oidc_result.AuthOidcResult() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_default_api.py b/python/tests/codegen_tests/test_default_api.py index ebc66cda..2f37a582 100644 --- a/python/tests/codegen_tests/test_default_api.py +++ b/python/tests/codegen_tests/test_default_api.py @@ -35,6 +35,12 @@ class TestDefaultApi(unittest.TestCase): """ pass + def test_auth_oidc(self): + """Test case for auth_oidc + + """ + pass + def test_create_container(self): """Test case for create_container -- cgit v1.2.3