diff --git a/hubspot/discovery/oauth/discovery.py b/hubspot/discovery/oauth/discovery.py index 0ea3c891..83c82ec5 100644 --- a/hubspot/discovery/oauth/discovery.py +++ b/hubspot/discovery/oauth/discovery.py @@ -3,6 +3,11 @@ class Discovery(DiscoveryBase): + @property + def v3(self): + from .v3.discovery import Discovery as v3Discovery + return v3Discovery(self.config) + @property def access_tokens_api(self) -> api_client.AccessTokensApi: return self._configure_api_client(api_client, "AccessTokensApi") diff --git a/hubspot/discovery/oauth/v3/__init__.py b/hubspot/discovery/oauth/v3/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hubspot/discovery/oauth/v3/discovery.py b/hubspot/discovery/oauth/v3/discovery.py new file mode 100644 index 00000000..c67afe76 --- /dev/null +++ b/hubspot/discovery/oauth/v3/discovery.py @@ -0,0 +1,8 @@ +import hubspot.oauth.v3 as api_client +from ...discovery_base import DiscoveryBase + + +class Discovery(DiscoveryBase): + @property + def advanced_api(self) -> api_client.AdvancedApi: + return self._configure_api_client(api_client, "AdvancedApi") diff --git a/hubspot/oauth/v3/__init__.py b/hubspot/oauth/v3/__init__.py new file mode 100644 index 00000000..732b7fed --- /dev/null +++ b/hubspot/oauth/v3/__init__.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +# flake8: noqa + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +__version__ = "1.0.0" + +# import apis into sdk package +from hubspot.oauth.v3.api.advanced_api import AdvancedApi + +# import ApiClient +from hubspot.oauth.v3.api_client import ApiClient +from hubspot.oauth.v3.configuration import Configuration +from hubspot.oauth.v3.exceptions import OpenApiException +from hubspot.oauth.v3.exceptions import ApiTypeError +from hubspot.oauth.v3.exceptions import ApiValueError +from hubspot.oauth.v3.exceptions import ApiKeyError +from hubspot.oauth.v3.exceptions import ApiAttributeError +from hubspot.oauth.v3.exceptions import ApiException + +# import models into sdk package +from hubspot.oauth.v3.models.access_token_response import AccessTokenResponse +from hubspot.oauth.v3.models.client_credentials_token_response import ClientCredentialsTokenResponse +from hubspot.oauth.v3.models.error import Error +from hubspot.oauth.v3.models.error_detail import ErrorDetail +from hubspot.oauth.v3.models.public_access_token_info_response import PublicAccessTokenInfoResponse +from hubspot.oauth.v3.models.public_refresh_token_info_response import PublicRefreshTokenInfoResponse +from hubspot.oauth.v3.models.signed_access_token import SignedAccessToken +from hubspot.oauth.v3.models.token_info_response_base_if import TokenInfoResponseBaseIF +from hubspot.oauth.v3.models.token_response_if import TokenResponseIF diff --git a/hubspot/oauth/v3/api/__init__.py b/hubspot/oauth/v3/api/__init__.py new file mode 100644 index 00000000..b033bf58 --- /dev/null +++ b/hubspot/oauth/v3/api/__init__.py @@ -0,0 +1,6 @@ +from __future__ import absolute_import + +# flake8: noqa + +# import apis into api package +from hubspot.oauth.v3.api.advanced_api import AdvancedApi diff --git a/hubspot/oauth/v3/api/advanced_api.py b/hubspot/oauth/v3/api/advanced_api.py new file mode 100644 index 00000000..fc6609cc --- /dev/null +++ b/hubspot/oauth/v3/api/advanced_api.py @@ -0,0 +1,503 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from hubspot.oauth.v3.api_client import ApiClient +from hubspot.oauth.v3.exceptions import ApiTypeError, ApiValueError # noqa: F401 + + +class AdvancedApi(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 + + def get_token(self, **kwargs): # noqa: E501 + """OAuth token endpoint # noqa: E501 + + Authenticates a client and returns access and refresh tokens. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_token(async_req=True) + >>> result = thread.get() + + :param assertion: + :type assertion: str + :param client_assertion: + :type client_assertion: str + :param client_assertion_type: + :type client_assertion_type: str + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param code: + :type code: str + :param code_verifier: + :type code_verifier: str + :param grant_type: + :type grant_type: str + :param redirect_uri: + :type redirect_uri: str + :param refresh_token: + :type refresh_token: str + :param scope: + :type scope: str + :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: TokenResponseIF + """ + kwargs["_return_http_data_only"] = True + return self.get_token_with_http_info(**kwargs) # noqa: E501 + + def get_token_with_http_info(self, **kwargs): # noqa: E501 + """OAuth token endpoint # noqa: E501 + + Authenticates a client and returns access and refresh tokens. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_token_with_http_info(async_req=True) + >>> result = thread.get() + + :param assertion: + :type assertion: str + :param client_assertion: + :type client_assertion: str + :param client_assertion_type: + :type client_assertion_type: str + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param code: + :type code: str + :param code_verifier: + :type code_verifier: str + :param grant_type: + :type grant_type: str + :param redirect_uri: + :type redirect_uri: str + :param refresh_token: + :type refresh_token: str + :param scope: + :type scope: str + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(TokenResponseIF, status_code(int), headers(HTTPHeaderDict)) + """ + + local_var_params = locals() + + all_params = ["assertion", "client_assertion", "client_assertion_type", "client_id", "client_secret", "code", "code_verifier", "grant_type", "redirect_uri", "refresh_token", "scope"] + all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"]) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_token" % key) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = dict(local_var_params.get("_headers", {})) + + form_params = [] + local_var_files = {} + if "assertion" in local_var_params: + form_params.append(("assertion", local_var_params["assertion"])) # noqa: E501 + if "client_assertion" in local_var_params: + form_params.append(("client_assertion", local_var_params["client_assertion"])) # noqa: E501 + if "client_assertion_type" in local_var_params: + form_params.append(("client_assertion_type", local_var_params["client_assertion_type"])) # noqa: E501 + if "client_id" in local_var_params: + form_params.append(("client_id", local_var_params["client_id"])) # noqa: E501 + if "client_secret" in local_var_params: + form_params.append(("client_secret", local_var_params["client_secret"])) # noqa: E501 + if "code" in local_var_params: + form_params.append(("code", local_var_params["code"])) # noqa: E501 + if "code_verifier" in local_var_params: + form_params.append(("code_verifier", local_var_params["code_verifier"])) # noqa: E501 + if "grant_type" in local_var_params: + form_params.append(("grant_type", local_var_params["grant_type"])) # noqa: E501 + if "redirect_uri" in local_var_params: + form_params.append(("redirect_uri", local_var_params["redirect_uri"])) # noqa: E501 + if "refresh_token" in local_var_params: + form_params.append(("refresh_token", local_var_params["refresh_token"])) # noqa: E501 + if "scope" in local_var_params: + form_params.append(("scope", local_var_params["scope"])) # noqa: E501 + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"]) # noqa: E501 + + # HTTP header `Content-Type` + content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/x-www-form-urlencoded"], "POST", body_params)) # noqa: E501 + if content_types_list: + header_params["Content-Type"] = content_types_list + + # Authentication setting + auth_settings = [] # noqa: E501 + + response_types_map = { + 200: "TokenResponseIF", + } + + return self.api_client.call_api( + "/oauth/v3/token", + "POST", + 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"), + collection_formats=collection_formats, + _request_auth=local_var_params.get("_request_auth"), + ) + + def introspect_token(self, **kwargs): # noqa: E501 + """Token introspection endpoint # noqa: E501 + + Returns validity and metadata for access and refresh tokens. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.introspect_token(async_req=True) + >>> result = thread.get() + + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param token: + :type token: str + :param token_type_hint: + :type token_type_hint: str + :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: TokenInfoResponseBaseIF + """ + kwargs["_return_http_data_only"] = True + return self.introspect_token_with_http_info(**kwargs) # noqa: E501 + + def introspect_token_with_http_info(self, **kwargs): # noqa: E501 + """Token introspection endpoint # noqa: E501 + + Returns validity and metadata for access and refresh tokens. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.introspect_token_with_http_info(async_req=True) + >>> result = thread.get() + + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param token: + :type token: str + :param token_type_hint: + :type token_type_hint: str + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(TokenInfoResponseBaseIF, status_code(int), headers(HTTPHeaderDict)) + """ + + local_var_params = locals() + + all_params = ["client_id", "client_secret", "token", "token_type_hint"] + all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"]) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method introspect_token" % key) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = dict(local_var_params.get("_headers", {})) + + form_params = [] + local_var_files = {} + if "client_id" in local_var_params: + form_params.append(("client_id", local_var_params["client_id"])) # noqa: E501 + if "client_secret" in local_var_params: + form_params.append(("client_secret", local_var_params["client_secret"])) # noqa: E501 + if "token" in local_var_params: + form_params.append(("token", local_var_params["token"])) # noqa: E501 + if "token_type_hint" in local_var_params: + form_params.append(("token_type_hint", local_var_params["token_type_hint"])) # noqa: E501 + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"]) # noqa: E501 + + # HTTP header `Content-Type` + content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/x-www-form-urlencoded"], "POST", body_params)) # noqa: E501 + if content_types_list: + header_params["Content-Type"] = content_types_list + + # Authentication setting + auth_settings = [] # noqa: E501 + + response_types_map = { + 200: "TokenInfoResponseBaseIF", + } + + return self.api_client.call_api( + "/oauth/v3/token/introspect", + "POST", + 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"), + collection_formats=collection_formats, + _request_auth=local_var_params.get("_request_auth"), + ) + + def revoke_token(self, **kwargs): # noqa: E501 + """Token Revocation endpoint # noqa: E501 + + Deletes/Revokes provided Refresh Token # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.revoke_token(async_req=True) + >>> result = thread.get() + + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param token: + :type token: str + :param token_type_hint: + :type token_type_hint: str + :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: None + """ + kwargs["_return_http_data_only"] = True + return self.revoke_token_with_http_info(**kwargs) # noqa: E501 + + def revoke_token_with_http_info(self, **kwargs): # noqa: E501 + """Token Revocation endpoint # noqa: E501 + + Deletes/Revokes provided Refresh Token # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.revoke_token_with_http_info(async_req=True) + >>> result = thread.get() + + :param client_id: + :type client_id: str + :param client_secret: + :type client_secret: str + :param token: + :type token: str + :param token_type_hint: + :type token_type_hint: str + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + local_var_params = locals() + + all_params = ["client_id", "client_secret", "token", "token_type_hint"] + all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"]) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method revoke_token" % key) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = dict(local_var_params.get("_headers", {})) + + form_params = [] + local_var_files = {} + if "client_id" in local_var_params: + form_params.append(("client_id", local_var_params["client_id"])) # noqa: E501 + if "client_secret" in local_var_params: + form_params.append(("client_secret", local_var_params["client_secret"])) # noqa: E501 + if "token" in local_var_params: + form_params.append(("token", local_var_params["token"])) # noqa: E501 + if "token_type_hint" in local_var_params: + form_params.append(("token_type_hint", local_var_params["token_type_hint"])) # noqa: E501 + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept(["*/*"]) # noqa: E501 + + # HTTP header `Content-Type` + content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/x-www-form-urlencoded"], "POST", body_params)) # noqa: E501 + if content_types_list: + header_params["Content-Type"] = content_types_list + + # Authentication setting + auth_settings = [] # noqa: E501 + + response_types_map = {} + + return self.api_client.call_api( + "/oauth/v3/token/revoke", + "POST", + 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"), + collection_formats=collection_formats, + _request_auth=local_var_params.get("_request_auth"), + ) diff --git a/hubspot/oauth/v3/api_client.py b/hubspot/oauth/v3/api_client.py new file mode 100644 index 00000000..330958fa --- /dev/null +++ b/hubspot/oauth/v3/api_client.py @@ -0,0 +1,665 @@ +# coding: utf-8 +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + +from __future__ import absolute_import + +import atexit +import datetime +from dateutil.parser import parse +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 + +from hubspot.oauth.v3.configuration import Configuration +import hubspot.oauth.v3.models +from hubspot.oauth.v3 import rest +from hubspot.oauth.v3.exceptions import ApiValueError, ApiException + + +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.get_default_copy() + 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 = "OpenAPI-Generator/1.0.0/python" + self.client_side_validation = configuration.client_side_validation + + 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 + + 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, + ): + + 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, request_auth=_request_auth) + + # 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 + + try: + # perform request and return response + response_data = 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 + + self.last_response = response_data + + return_data = response_data + + if not _preload_content: + return return_data + + response_type = response_types_map.get(response_data.status, None) + + 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" + 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 + + if _return_http_data_only: + return return_data + else: + return (return_data, response_data.status, response_data.getheaders()) + + 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(hubspot.oauth.v3.models, 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, + ): + """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. + :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. + 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_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + _request_auth, + ) + + return self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + _request_auth, + ), + ) + + 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, _preload_content=_preload_content, _request_timeout=_request_timeout) + 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, method=None, body=None): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :param method: http method (e.g. POST, PATCH). + :param body: http body to send. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + content_types = [x.lower() for x in content_types] + + if method == "PATCH" and "application/json-patch+json" in content_types and isinstance(body, list): + return "application/json-patch+json" + + 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, queries, auth_settings, request_auth=None): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: 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, queries, request_auth) + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params(headers, queries, auth_setting) + + def _apply_auth_params(self, headers, queries, auth_setting): + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: 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": + queries.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: + 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_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))) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :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) + + kwargs["local_vars_configuration"] = self.configuration + 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 diff --git a/hubspot/oauth/v3/configuration.py b/hubspot/oauth/v3/configuration.py new file mode 100644 index 00000000..49e3c603 --- /dev/null +++ b/hubspot/oauth/v3/configuration.py @@ -0,0 +1,467 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +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 +from hubspot.oauth.v3.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. + :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. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format + + :Example: + + 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 = hubspot.oauth.v3.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} + ) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 + """ + + _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="", + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ssl_ca_cert=None, + ): + """Constructor""" + self._base_path = "https://api.hubapi.com" 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 + self.access_token = None + """access token for OAuth/Bearer + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("hubspot.oauth.v3") + 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 = ssl_ca_cert + """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. + """ + + 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. + """ + + 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 = False + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + 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 + + @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 six.iteritems(self.logger): + 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 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, 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 = {} + if "developer_hapikey" in self.api_key: + auth["developer_hapikey"] = { + "type": "api_key", + "in": "query", + "key": "hapikey", + "value": self.get_api_key_with_prefix( + "developer_hapikey", + ), + } + if self.access_token is not None: + auth["oauth2"] = {"type": "oauth2", "in": "header", "key": "Authorization", "value": "Bearer " + self.access_token} + 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: v3\n" "SDK Package Version: 1.0.0".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 [ + { + "url": "https://api.hubapi.com", + "description": "No description provided", + } + ] + + 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/hubspot/oauth/v3/exceptions.py b/hubspot/oauth/v3/exceptions.py new file mode 100644 index 00000000..f4e091bd --- /dev/null +++ b/hubspot/oauth/v3/exceptions.py @@ -0,0 +1,160 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +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 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 + + +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): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/hubspot/oauth/v3/models/__init__.py b/hubspot/oauth/v3/models/__init__.py new file mode 100644 index 00000000..5dc1b0b8 --- /dev/null +++ b/hubspot/oauth/v3/models/__init__.py @@ -0,0 +1,25 @@ +# coding: utf-8 + +# flake8: noqa +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +# import models into model package +from hubspot.oauth.v3.models.access_token_response import AccessTokenResponse +from hubspot.oauth.v3.models.client_credentials_token_response import ClientCredentialsTokenResponse +from hubspot.oauth.v3.models.error import Error +from hubspot.oauth.v3.models.error_detail import ErrorDetail +from hubspot.oauth.v3.models.public_access_token_info_response import PublicAccessTokenInfoResponse +from hubspot.oauth.v3.models.public_refresh_token_info_response import PublicRefreshTokenInfoResponse +from hubspot.oauth.v3.models.signed_access_token import SignedAccessToken +from hubspot.oauth.v3.models.token_info_response_base_if import TokenInfoResponseBaseIF +from hubspot.oauth.v3.models.token_response_if import TokenResponseIF diff --git a/hubspot/oauth/v3/models/access_token_response.py b/hubspot/oauth/v3/models/access_token_response.py new file mode 100644 index 00000000..e2db8e81 --- /dev/null +++ b/hubspot/oauth/v3/models/access_token_response.py @@ -0,0 +1,343 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class AccessTokenResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "access_token": "str", + "expires_in": "int", + "hub_id": "int", + "id_token": "str", + "refresh_token": "str", + "scopes": "list[str]", + "token_type": "str", + "token_use": "str", + "user_id": "int", + } + + attribute_map = { + "access_token": "access_token", + "expires_in": "expires_in", + "hub_id": "hub_id", + "id_token": "id_token", + "refresh_token": "refresh_token", + "scopes": "scopes", + "token_type": "token_type", + "token_use": "token_use", + "user_id": "user_id", + } + + def __init__( + self, access_token=None, expires_in=None, hub_id=None, id_token=None, refresh_token=None, scopes=None, token_type=None, token_use="access_token", user_id=None, local_vars_configuration=None + ): # noqa: E501 + """AccessTokenResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._access_token = None + self._expires_in = None + self._hub_id = None + self._id_token = None + self._refresh_token = None + self._scopes = None + self._token_type = None + self._token_use = None + self._user_id = None + self.discriminator = None + + self.access_token = access_token + self.expires_in = expires_in + if hub_id is not None: + self.hub_id = hub_id + if id_token is not None: + self.id_token = id_token + self.refresh_token = refresh_token + if scopes is not None: + self.scopes = scopes + self.token_type = token_type + self.token_use = token_use + if user_id is not None: + self.user_id = user_id + + @property + def access_token(self): + """Gets the access_token of this AccessTokenResponse. # noqa: E501 + + + :return: The access_token of this AccessTokenResponse. # noqa: E501 + :rtype: str + """ + return self._access_token + + @access_token.setter + def access_token(self, access_token): + """Sets the access_token of this AccessTokenResponse. + + + :param access_token: The access_token of this AccessTokenResponse. # noqa: E501 + :type access_token: str + """ + if self.local_vars_configuration.client_side_validation and access_token is None: # noqa: E501 + raise ValueError("Invalid value for `access_token`, must not be `None`") # noqa: E501 + + self._access_token = access_token + + @property + def expires_in(self): + """Gets the expires_in of this AccessTokenResponse. # noqa: E501 + + + :return: The expires_in of this AccessTokenResponse. # noqa: E501 + :rtype: int + """ + return self._expires_in + + @expires_in.setter + def expires_in(self, expires_in): + """Sets the expires_in of this AccessTokenResponse. + + + :param expires_in: The expires_in of this AccessTokenResponse. # noqa: E501 + :type expires_in: int + """ + if self.local_vars_configuration.client_side_validation and expires_in is None: # noqa: E501 + raise ValueError("Invalid value for `expires_in`, must not be `None`") # noqa: E501 + + self._expires_in = expires_in + + @property + def hub_id(self): + """Gets the hub_id of this AccessTokenResponse. # noqa: E501 + + + :return: The hub_id of this AccessTokenResponse. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this AccessTokenResponse. + + + :param hub_id: The hub_id of this AccessTokenResponse. # noqa: E501 + :type hub_id: int + """ + + self._hub_id = hub_id + + @property + def id_token(self): + """Gets the id_token of this AccessTokenResponse. # noqa: E501 + + + :return: The id_token of this AccessTokenResponse. # noqa: E501 + :rtype: str + """ + return self._id_token + + @id_token.setter + def id_token(self, id_token): + """Sets the id_token of this AccessTokenResponse. + + + :param id_token: The id_token of this AccessTokenResponse. # noqa: E501 + :type id_token: str + """ + + self._id_token = id_token + + @property + def refresh_token(self): + """Gets the refresh_token of this AccessTokenResponse. # noqa: E501 + + + :return: The refresh_token of this AccessTokenResponse. # noqa: E501 + :rtype: str + """ + return self._refresh_token + + @refresh_token.setter + def refresh_token(self, refresh_token): + """Sets the refresh_token of this AccessTokenResponse. + + + :param refresh_token: The refresh_token of this AccessTokenResponse. # noqa: E501 + :type refresh_token: str + """ + if self.local_vars_configuration.client_side_validation and refresh_token is None: # noqa: E501 + raise ValueError("Invalid value for `refresh_token`, must not be `None`") # noqa: E501 + + self._refresh_token = refresh_token + + @property + def scopes(self): + """Gets the scopes of this AccessTokenResponse. # noqa: E501 + + + :return: The scopes of this AccessTokenResponse. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this AccessTokenResponse. + + + :param scopes: The scopes of this AccessTokenResponse. # noqa: E501 + :type scopes: list[str] + """ + + self._scopes = scopes + + @property + def token_type(self): + """Gets the token_type of this AccessTokenResponse. # noqa: E501 + + + :return: The token_type of this AccessTokenResponse. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this AccessTokenResponse. + + + :param token_type: The token_type of this AccessTokenResponse. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this AccessTokenResponse. # noqa: E501 + + + :return: The token_use of this AccessTokenResponse. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this AccessTokenResponse. + + + :param token_use: The token_use of this AccessTokenResponse. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["access_token"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user_id(self): + """Gets the user_id of this AccessTokenResponse. # noqa: E501 + + + :return: The user_id of this AccessTokenResponse. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this AccessTokenResponse. + + + :param user_id: The user_id of this AccessTokenResponse. # noqa: E501 + :type user_id: int + """ + + self._user_id = user_id + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, AccessTokenResponse): + 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, AccessTokenResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/client_credentials_token_response.py b/hubspot/oauth/v3/models/client_credentials_token_response.py new file mode 100644 index 00000000..1ad5bfdd --- /dev/null +++ b/hubspot/oauth/v3/models/client_credentials_token_response.py @@ -0,0 +1,307 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class ClientCredentialsTokenResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = {"access_token": "str", "expires_in": "int", "hub_id": "int", "id_token": "str", "scopes": "list[str]", "token_type": "str", "token_use": "str", "user_id": "int"} + + attribute_map = { + "access_token": "access_token", + "expires_in": "expires_in", + "hub_id": "hub_id", + "id_token": "id_token", + "scopes": "scopes", + "token_type": "token_type", + "token_use": "token_use", + "user_id": "user_id", + } + + def __init__( + self, access_token=None, expires_in=None, hub_id=None, id_token=None, scopes=None, token_type=None, token_use="client_credentials", user_id=None, local_vars_configuration=None + ): # noqa: E501 + """ClientCredentialsTokenResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._access_token = None + self._expires_in = None + self._hub_id = None + self._id_token = None + self._scopes = None + self._token_type = None + self._token_use = None + self._user_id = None + self.discriminator = None + + self.access_token = access_token + self.expires_in = expires_in + if hub_id is not None: + self.hub_id = hub_id + if id_token is not None: + self.id_token = id_token + if scopes is not None: + self.scopes = scopes + self.token_type = token_type + self.token_use = token_use + if user_id is not None: + self.user_id = user_id + + @property + def access_token(self): + """Gets the access_token of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The access_token of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: str + """ + return self._access_token + + @access_token.setter + def access_token(self, access_token): + """Sets the access_token of this ClientCredentialsTokenResponse. + + + :param access_token: The access_token of this ClientCredentialsTokenResponse. # noqa: E501 + :type access_token: str + """ + if self.local_vars_configuration.client_side_validation and access_token is None: # noqa: E501 + raise ValueError("Invalid value for `access_token`, must not be `None`") # noqa: E501 + + self._access_token = access_token + + @property + def expires_in(self): + """Gets the expires_in of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The expires_in of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: int + """ + return self._expires_in + + @expires_in.setter + def expires_in(self, expires_in): + """Sets the expires_in of this ClientCredentialsTokenResponse. + + + :param expires_in: The expires_in of this ClientCredentialsTokenResponse. # noqa: E501 + :type expires_in: int + """ + if self.local_vars_configuration.client_side_validation and expires_in is None: # noqa: E501 + raise ValueError("Invalid value for `expires_in`, must not be `None`") # noqa: E501 + + self._expires_in = expires_in + + @property + def hub_id(self): + """Gets the hub_id of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The hub_id of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this ClientCredentialsTokenResponse. + + + :param hub_id: The hub_id of this ClientCredentialsTokenResponse. # noqa: E501 + :type hub_id: int + """ + + self._hub_id = hub_id + + @property + def id_token(self): + """Gets the id_token of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The id_token of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: str + """ + return self._id_token + + @id_token.setter + def id_token(self, id_token): + """Sets the id_token of this ClientCredentialsTokenResponse. + + + :param id_token: The id_token of this ClientCredentialsTokenResponse. # noqa: E501 + :type id_token: str + """ + + self._id_token = id_token + + @property + def scopes(self): + """Gets the scopes of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The scopes of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this ClientCredentialsTokenResponse. + + + :param scopes: The scopes of this ClientCredentialsTokenResponse. # noqa: E501 + :type scopes: list[str] + """ + + self._scopes = scopes + + @property + def token_type(self): + """Gets the token_type of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The token_type of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this ClientCredentialsTokenResponse. + + + :param token_type: The token_type of this ClientCredentialsTokenResponse. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The token_use of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this ClientCredentialsTokenResponse. + + + :param token_use: The token_use of this ClientCredentialsTokenResponse. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["client_credentials"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user_id(self): + """Gets the user_id of this ClientCredentialsTokenResponse. # noqa: E501 + + + :return: The user_id of this ClientCredentialsTokenResponse. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this ClientCredentialsTokenResponse. + + + :param user_id: The user_id of this ClientCredentialsTokenResponse. # noqa: E501 + :type user_id: int + """ + + self._user_id = user_id + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, ClientCredentialsTokenResponse): + 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, ClientCredentialsTokenResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/error.py b/hubspot/oauth/v3/models/error.py new file mode 100644 index 00000000..5a2b042e --- /dev/null +++ b/hubspot/oauth/v3/models/error.py @@ -0,0 +1,282 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class Error(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = {"category": "str", "context": "dict[str, list[str]]", "correlation_id": "str", "errors": "list[ErrorDetail]", "links": "dict[str, str]", "message": "str", "sub_category": "str"} + + attribute_map = {"category": "category", "context": "context", "correlation_id": "correlationId", "errors": "errors", "links": "links", "message": "message", "sub_category": "subCategory"} + + def __init__(self, category=None, context=None, correlation_id=None, errors=None, links=None, message=None, sub_category=None, local_vars_configuration=None): # noqa: E501 + """Error - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._category = None + self._context = None + self._correlation_id = None + self._errors = None + self._links = None + self._message = None + self._sub_category = None + self.discriminator = None + + self.category = category + if context is not None: + self.context = context + self.correlation_id = correlation_id + if errors is not None: + self.errors = errors + if links is not None: + self.links = links + self.message = message + if sub_category is not None: + self.sub_category = sub_category + + @property + def category(self): + """Gets the category of this Error. # noqa: E501 + + The error category # noqa: E501 + + :return: The category of this Error. # noqa: E501 + :rtype: str + """ + return self._category + + @category.setter + def category(self, category): + """Sets the category of this Error. + + The error category # noqa: E501 + + :param category: The category of this Error. # noqa: E501 + :type category: str + """ + if self.local_vars_configuration.client_side_validation and category is None: # noqa: E501 + raise ValueError("Invalid value for `category`, must not be `None`") # noqa: E501 + + self._category = category + + @property + def context(self): + """Gets the context of this Error. # noqa: E501 + + Context about the error condition # noqa: E501 + + :return: The context of this Error. # noqa: E501 + :rtype: dict[str, list[str]] + """ + return self._context + + @context.setter + def context(self, context): + """Sets the context of this Error. + + Context about the error condition # noqa: E501 + + :param context: The context of this Error. # noqa: E501 + :type context: dict[str, list[str]] + """ + + self._context = context + + @property + def correlation_id(self): + """Gets the correlation_id of this Error. # noqa: E501 + + A unique identifier for the request. Include this value with any error reports or support tickets # noqa: E501 + + :return: The correlation_id of this Error. # noqa: E501 + :rtype: str + """ + return self._correlation_id + + @correlation_id.setter + def correlation_id(self, correlation_id): + """Sets the correlation_id of this Error. + + A unique identifier for the request. Include this value with any error reports or support tickets # noqa: E501 + + :param correlation_id: The correlation_id of this Error. # noqa: E501 + :type correlation_id: str + """ + if self.local_vars_configuration.client_side_validation and correlation_id is None: # noqa: E501 + raise ValueError("Invalid value for `correlation_id`, must not be `None`") # noqa: E501 + + self._correlation_id = correlation_id + + @property + def errors(self): + """Gets the errors of this Error. # noqa: E501 + + further information about the error # noqa: E501 + + :return: The errors of this Error. # noqa: E501 + :rtype: list[ErrorDetail] + """ + return self._errors + + @errors.setter + def errors(self, errors): + """Sets the errors of this Error. + + further information about the error # noqa: E501 + + :param errors: The errors of this Error. # noqa: E501 + :type errors: list[ErrorDetail] + """ + + self._errors = errors + + @property + def links(self): + """Gets the links of this Error. # noqa: E501 + + A map of link names to associated URIs containing documentation about the error or recommended remediation steps # noqa: E501 + + :return: The links of this Error. # noqa: E501 + :rtype: dict[str, str] + """ + return self._links + + @links.setter + def links(self, links): + """Sets the links of this Error. + + A map of link names to associated URIs containing documentation about the error or recommended remediation steps # noqa: E501 + + :param links: The links of this Error. # noqa: E501 + :type links: dict[str, str] + """ + + self._links = links + + @property + def message(self): + """Gets the message of this Error. # noqa: E501 + + A human readable message describing the error along with remediation steps where appropriate # noqa: E501 + + :return: The message of this Error. # noqa: E501 + :rtype: str + """ + return self._message + + @message.setter + def message(self, message): + """Sets the message of this Error. + + A human readable message describing the error along with remediation steps where appropriate # noqa: E501 + + :param message: The message of this Error. # noqa: E501 + :type message: str + """ + if self.local_vars_configuration.client_side_validation and message is None: # noqa: E501 + raise ValueError("Invalid value for `message`, must not be `None`") # noqa: E501 + + self._message = message + + @property + def sub_category(self): + """Gets the sub_category of this Error. # noqa: E501 + + A specific category that contains more specific detail about the error # noqa: E501 + + :return: The sub_category of this Error. # noqa: E501 + :rtype: str + """ + return self._sub_category + + @sub_category.setter + def sub_category(self, sub_category): + """Sets the sub_category of this Error. + + A specific category that contains more specific detail about the error # noqa: E501 + + :param sub_category: The sub_category of this Error. # noqa: E501 + :type sub_category: str + """ + + self._sub_category = sub_category + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, Error): + 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, Error): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/error_detail.py b/hubspot/oauth/v3/models/error_detail.py new file mode 100644 index 00000000..cebba0cf --- /dev/null +++ b/hubspot/oauth/v3/models/error_detail.py @@ -0,0 +1,228 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class ErrorDetail(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = {"code": "str", "context": "dict[str, list[str]]", "_in": "str", "message": "str", "sub_category": "str"} + + attribute_map = {"code": "code", "context": "context", "_in": "in", "message": "message", "sub_category": "subCategory"} + + def __init__(self, code=None, context=None, _in=None, message=None, sub_category=None, local_vars_configuration=None): # noqa: E501 + """ErrorDetail - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._code = None + self._context = None + self.__in = None + self._message = None + self._sub_category = None + self.discriminator = None + + if code is not None: + self.code = code + if context is not None: + self.context = context + if _in is not None: + self._in = _in + self.message = message + if sub_category is not None: + self.sub_category = sub_category + + @property + def code(self): + """Gets the code of this ErrorDetail. # noqa: E501 + + The status code associated with the error detail # noqa: E501 + + :return: The code of this ErrorDetail. # noqa: E501 + :rtype: str + """ + return self._code + + @code.setter + def code(self, code): + """Sets the code of this ErrorDetail. + + The status code associated with the error detail # noqa: E501 + + :param code: The code of this ErrorDetail. # noqa: E501 + :type code: str + """ + + self._code = code + + @property + def context(self): + """Gets the context of this ErrorDetail. # noqa: E501 + + Context about the error condition # noqa: E501 + + :return: The context of this ErrorDetail. # noqa: E501 + :rtype: dict[str, list[str]] + """ + return self._context + + @context.setter + def context(self, context): + """Sets the context of this ErrorDetail. + + Context about the error condition # noqa: E501 + + :param context: The context of this ErrorDetail. # noqa: E501 + :type context: dict[str, list[str]] + """ + + self._context = context + + @property + def _in(self): + """Gets the _in of this ErrorDetail. # noqa: E501 + + The name of the field or parameter in which the error was found. # noqa: E501 + + :return: The _in of this ErrorDetail. # noqa: E501 + :rtype: str + """ + return self.__in + + @_in.setter + def _in(self, _in): + """Sets the _in of this ErrorDetail. + + The name of the field or parameter in which the error was found. # noqa: E501 + + :param _in: The _in of this ErrorDetail. # noqa: E501 + :type _in: str + """ + + self.__in = _in + + @property + def message(self): + """Gets the message of this ErrorDetail. # noqa: E501 + + A human readable message describing the error along with remediation steps where appropriate # noqa: E501 + + :return: The message of this ErrorDetail. # noqa: E501 + :rtype: str + """ + return self._message + + @message.setter + def message(self, message): + """Sets the message of this ErrorDetail. + + A human readable message describing the error along with remediation steps where appropriate # noqa: E501 + + :param message: The message of this ErrorDetail. # noqa: E501 + :type message: str + """ + if self.local_vars_configuration.client_side_validation and message is None: # noqa: E501 + raise ValueError("Invalid value for `message`, must not be `None`") # noqa: E501 + + self._message = message + + @property + def sub_category(self): + """Gets the sub_category of this ErrorDetail. # noqa: E501 + + A specific category that contains more specific detail about the error # noqa: E501 + + :return: The sub_category of this ErrorDetail. # noqa: E501 + :rtype: str + """ + return self._sub_category + + @sub_category.setter + def sub_category(self, sub_category): + """Sets the sub_category of this ErrorDetail. + + A specific category that contains more specific detail about the error # noqa: E501 + + :param sub_category: The sub_category of this ErrorDetail. # noqa: E501 + :type sub_category: str + """ + + self._sub_category = sub_category + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, ErrorDetail): + 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, ErrorDetail): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/public_access_token_info_response.py b/hubspot/oauth/v3/models/public_access_token_info_response.py new file mode 100644 index 00000000..b5ea6b55 --- /dev/null +++ b/hubspot/oauth/v3/models/public_access_token_info_response.py @@ -0,0 +1,495 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class PublicAccessTokenInfoResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "active": "bool", + "app_id": "int", + "client_id": "str", + "expires_in": "int", + "hub_domain": "str", + "hub_id": "int", + "is_private_distribution": "bool", + "scopes": "list[str]", + "signed_access_token": "SignedAccessToken", + "token": "str", + "token_type": "str", + "token_use": "str", + "user": "str", + "user_id": "int", + } + + attribute_map = { + "active": "active", + "app_id": "app_id", + "client_id": "client_id", + "expires_in": "expires_in", + "hub_domain": "hub_domain", + "hub_id": "hub_id", + "is_private_distribution": "is_private_distribution", + "scopes": "scopes", + "signed_access_token": "signed_access_token", + "token": "token", + "token_type": "token_type", + "token_use": "token_use", + "user": "user", + "user_id": "user_id", + } + + def __init__( + self, + active=None, + app_id=None, + client_id=None, + expires_in=None, + hub_domain=None, + hub_id=None, + is_private_distribution=None, + scopes=None, + signed_access_token=None, + token=None, + token_type=None, + token_use="access_token", + user=None, + user_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """PublicAccessTokenInfoResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._active = None + self._app_id = None + self._client_id = None + self._expires_in = None + self._hub_domain = None + self._hub_id = None + self._is_private_distribution = None + self._scopes = None + self._signed_access_token = None + self._token = None + self._token_type = None + self._token_use = None + self._user = None + self._user_id = None + self.discriminator = None + + self.active = active + self.app_id = app_id + self.client_id = client_id + self.expires_in = expires_in + if hub_domain is not None: + self.hub_domain = hub_domain + self.hub_id = hub_id + self.is_private_distribution = is_private_distribution + self.scopes = scopes + self.signed_access_token = signed_access_token + self.token = token + self.token_type = token_type + self.token_use = token_use + if user is not None: + self.user = user + self.user_id = user_id + + @property + def active(self): + """Gets the active of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The active of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: bool + """ + return self._active + + @active.setter + def active(self, active): + """Sets the active of this PublicAccessTokenInfoResponse. + + + :param active: The active of this PublicAccessTokenInfoResponse. # noqa: E501 + :type active: bool + """ + if self.local_vars_configuration.client_side_validation and active is None: # noqa: E501 + raise ValueError("Invalid value for `active`, must not be `None`") # noqa: E501 + + self._active = active + + @property + def app_id(self): + """Gets the app_id of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The app_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._app_id + + @app_id.setter + def app_id(self, app_id): + """Sets the app_id of this PublicAccessTokenInfoResponse. + + + :param app_id: The app_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :type app_id: int + """ + if self.local_vars_configuration.client_side_validation and app_id is None: # noqa: E501 + raise ValueError("Invalid value for `app_id`, must not be `None`") # noqa: E501 + + self._app_id = app_id + + @property + def client_id(self): + """Gets the client_id of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The client_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._client_id + + @client_id.setter + def client_id(self, client_id): + """Sets the client_id of this PublicAccessTokenInfoResponse. + + + :param client_id: The client_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :type client_id: str + """ + if self.local_vars_configuration.client_side_validation and client_id is None: # noqa: E501 + raise ValueError("Invalid value for `client_id`, must not be `None`") # noqa: E501 + + self._client_id = client_id + + @property + def expires_in(self): + """Gets the expires_in of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The expires_in of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._expires_in + + @expires_in.setter + def expires_in(self, expires_in): + """Sets the expires_in of this PublicAccessTokenInfoResponse. + + + :param expires_in: The expires_in of this PublicAccessTokenInfoResponse. # noqa: E501 + :type expires_in: int + """ + if self.local_vars_configuration.client_side_validation and expires_in is None: # noqa: E501 + raise ValueError("Invalid value for `expires_in`, must not be `None`") # noqa: E501 + + self._expires_in = expires_in + + @property + def hub_domain(self): + """Gets the hub_domain of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The hub_domain of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._hub_domain + + @hub_domain.setter + def hub_domain(self, hub_domain): + """Sets the hub_domain of this PublicAccessTokenInfoResponse. + + + :param hub_domain: The hub_domain of this PublicAccessTokenInfoResponse. # noqa: E501 + :type hub_domain: str + """ + + self._hub_domain = hub_domain + + @property + def hub_id(self): + """Gets the hub_id of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The hub_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this PublicAccessTokenInfoResponse. + + + :param hub_id: The hub_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :type hub_id: int + """ + if self.local_vars_configuration.client_side_validation and hub_id is None: # noqa: E501 + raise ValueError("Invalid value for `hub_id`, must not be `None`") # noqa: E501 + + self._hub_id = hub_id + + @property + def is_private_distribution(self): + """Gets the is_private_distribution of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The is_private_distribution of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: bool + """ + return self._is_private_distribution + + @is_private_distribution.setter + def is_private_distribution(self, is_private_distribution): + """Sets the is_private_distribution of this PublicAccessTokenInfoResponse. + + + :param is_private_distribution: The is_private_distribution of this PublicAccessTokenInfoResponse. # noqa: E501 + :type is_private_distribution: bool + """ + if self.local_vars_configuration.client_side_validation and is_private_distribution is None: # noqa: E501 + raise ValueError("Invalid value for `is_private_distribution`, must not be `None`") # noqa: E501 + + self._is_private_distribution = is_private_distribution + + @property + def scopes(self): + """Gets the scopes of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The scopes of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this PublicAccessTokenInfoResponse. + + + :param scopes: The scopes of this PublicAccessTokenInfoResponse. # noqa: E501 + :type scopes: list[str] + """ + if self.local_vars_configuration.client_side_validation and scopes is None: # noqa: E501 + raise ValueError("Invalid value for `scopes`, must not be `None`") # noqa: E501 + + self._scopes = scopes + + @property + def signed_access_token(self): + """Gets the signed_access_token of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The signed_access_token of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: SignedAccessToken + """ + return self._signed_access_token + + @signed_access_token.setter + def signed_access_token(self, signed_access_token): + """Sets the signed_access_token of this PublicAccessTokenInfoResponse. + + + :param signed_access_token: The signed_access_token of this PublicAccessTokenInfoResponse. # noqa: E501 + :type signed_access_token: SignedAccessToken + """ + if self.local_vars_configuration.client_side_validation and signed_access_token is None: # noqa: E501 + raise ValueError("Invalid value for `signed_access_token`, must not be `None`") # noqa: E501 + + self._signed_access_token = signed_access_token + + @property + def token(self): + """Gets the token of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The token of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token + + @token.setter + def token(self, token): + """Sets the token of this PublicAccessTokenInfoResponse. + + + :param token: The token of this PublicAccessTokenInfoResponse. # noqa: E501 + :type token: str + """ + if self.local_vars_configuration.client_side_validation and token is None: # noqa: E501 + raise ValueError("Invalid value for `token`, must not be `None`") # noqa: E501 + + self._token = token + + @property + def token_type(self): + """Gets the token_type of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The token_type of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this PublicAccessTokenInfoResponse. + + + :param token_type: The token_type of this PublicAccessTokenInfoResponse. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The token_use of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this PublicAccessTokenInfoResponse. + + + :param token_use: The token_use of this PublicAccessTokenInfoResponse. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["access_token"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user(self): + """Gets the user of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The user of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this PublicAccessTokenInfoResponse. + + + :param user: The user of this PublicAccessTokenInfoResponse. # noqa: E501 + :type user: str + """ + + self._user = user + + @property + def user_id(self): + """Gets the user_id of this PublicAccessTokenInfoResponse. # noqa: E501 + + + :return: The user_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this PublicAccessTokenInfoResponse. + + + :param user_id: The user_id of this PublicAccessTokenInfoResponse. # noqa: E501 + :type user_id: int + """ + if self.local_vars_configuration.client_side_validation and user_id is None: # noqa: E501 + raise ValueError("Invalid value for `user_id`, must not be `None`") # noqa: E501 + + self._user_id = user_id + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, PublicAccessTokenInfoResponse): + 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, PublicAccessTokenInfoResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/public_refresh_token_info_response.py b/hubspot/oauth/v3/models/public_refresh_token_info_response.py new file mode 100644 index 00000000..2c640847 --- /dev/null +++ b/hubspot/oauth/v3/models/public_refresh_token_info_response.py @@ -0,0 +1,411 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class PublicRefreshTokenInfoResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "active": "bool", + "app_id": "int", + "client_id": "str", + "hub_domain": "str", + "hub_id": "int", + "scopes": "list[str]", + "token": "str", + "token_type": "str", + "token_use": "str", + "user": "str", + "user_id": "int", + } + + attribute_map = { + "active": "active", + "app_id": "app_id", + "client_id": "client_id", + "hub_domain": "hub_domain", + "hub_id": "hub_id", + "scopes": "scopes", + "token": "token", + "token_type": "token_type", + "token_use": "token_use", + "user": "user", + "user_id": "user_id", + } + + def __init__( + self, + active=None, + app_id=None, + client_id=None, + hub_domain=None, + hub_id=None, + scopes=None, + token=None, + token_type=None, + token_use="refresh_token", + user=None, + user_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """PublicRefreshTokenInfoResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._active = None + self._app_id = None + self._client_id = None + self._hub_domain = None + self._hub_id = None + self._scopes = None + self._token = None + self._token_type = None + self._token_use = None + self._user = None + self._user_id = None + self.discriminator = None + + self.active = active + self.app_id = app_id + self.client_id = client_id + if hub_domain is not None: + self.hub_domain = hub_domain + self.hub_id = hub_id + self.scopes = scopes + self.token = token + self.token_type = token_type + self.token_use = token_use + if user is not None: + self.user = user + self.user_id = user_id + + @property + def active(self): + """Gets the active of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The active of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: bool + """ + return self._active + + @active.setter + def active(self, active): + """Sets the active of this PublicRefreshTokenInfoResponse. + + + :param active: The active of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type active: bool + """ + if self.local_vars_configuration.client_side_validation and active is None: # noqa: E501 + raise ValueError("Invalid value for `active`, must not be `None`") # noqa: E501 + + self._active = active + + @property + def app_id(self): + """Gets the app_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The app_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._app_id + + @app_id.setter + def app_id(self, app_id): + """Sets the app_id of this PublicRefreshTokenInfoResponse. + + + :param app_id: The app_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type app_id: int + """ + if self.local_vars_configuration.client_side_validation and app_id is None: # noqa: E501 + raise ValueError("Invalid value for `app_id`, must not be `None`") # noqa: E501 + + self._app_id = app_id + + @property + def client_id(self): + """Gets the client_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The client_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._client_id + + @client_id.setter + def client_id(self, client_id): + """Sets the client_id of this PublicRefreshTokenInfoResponse. + + + :param client_id: The client_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type client_id: str + """ + if self.local_vars_configuration.client_side_validation and client_id is None: # noqa: E501 + raise ValueError("Invalid value for `client_id`, must not be `None`") # noqa: E501 + + self._client_id = client_id + + @property + def hub_domain(self): + """Gets the hub_domain of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The hub_domain of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._hub_domain + + @hub_domain.setter + def hub_domain(self, hub_domain): + """Sets the hub_domain of this PublicRefreshTokenInfoResponse. + + + :param hub_domain: The hub_domain of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type hub_domain: str + """ + + self._hub_domain = hub_domain + + @property + def hub_id(self): + """Gets the hub_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The hub_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this PublicRefreshTokenInfoResponse. + + + :param hub_id: The hub_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type hub_id: int + """ + if self.local_vars_configuration.client_side_validation and hub_id is None: # noqa: E501 + raise ValueError("Invalid value for `hub_id`, must not be `None`") # noqa: E501 + + self._hub_id = hub_id + + @property + def scopes(self): + """Gets the scopes of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The scopes of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this PublicRefreshTokenInfoResponse. + + + :param scopes: The scopes of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type scopes: list[str] + """ + if self.local_vars_configuration.client_side_validation and scopes is None: # noqa: E501 + raise ValueError("Invalid value for `scopes`, must not be `None`") # noqa: E501 + + self._scopes = scopes + + @property + def token(self): + """Gets the token of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The token of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token + + @token.setter + def token(self, token): + """Sets the token of this PublicRefreshTokenInfoResponse. + + + :param token: The token of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type token: str + """ + if self.local_vars_configuration.client_side_validation and token is None: # noqa: E501 + raise ValueError("Invalid value for `token`, must not be `None`") # noqa: E501 + + self._token = token + + @property + def token_type(self): + """Gets the token_type of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The token_type of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this PublicRefreshTokenInfoResponse. + + + :param token_type: The token_type of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The token_use of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this PublicRefreshTokenInfoResponse. + + + :param token_use: The token_use of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["refresh_token"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user(self): + """Gets the user of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The user of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this PublicRefreshTokenInfoResponse. + + + :param user: The user of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type user: str + """ + + self._user = user + + @property + def user_id(self): + """Gets the user_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + + + :return: The user_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this PublicRefreshTokenInfoResponse. + + + :param user_id: The user_id of this PublicRefreshTokenInfoResponse. # noqa: E501 + :type user_id: int + """ + if self.local_vars_configuration.client_side_validation and user_id is None: # noqa: E501 + raise ValueError("Invalid value for `user_id`, must not be `None`") # noqa: E501 + + self._user_id = user_id + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, PublicRefreshTokenInfoResponse): + 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, PublicRefreshTokenInfoResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/signed_access_token.py b/hubspot/oauth/v3/models/signed_access_token.py new file mode 100644 index 00000000..01cabb37 --- /dev/null +++ b/hubspot/oauth/v3/models/signed_access_token.py @@ -0,0 +1,578 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class SignedAccessToken(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "app_id": "int", + "app_install_id": "str", + "audience": "str", + "expires_at": "int", + "hub_id": "int", + "hublet": "str", + "installing_user_id": "int", + "is_private_distribution": "bool", + "is_service_account": "bool", + "is_user_level": "bool", + "new_signature": "str", + "scope_to_scope_group_pks": "str", + "scopes": "str", + "signature": "str", + "trial_scope_to_scope_group_pks": "str", + "trial_scopes": "str", + "user_id": "int", + } + + attribute_map = { + "app_id": "appId", + "app_install_id": "appInstallId", + "audience": "audience", + "expires_at": "expiresAt", + "hub_id": "hubId", + "hublet": "hublet", + "installing_user_id": "installingUserId", + "is_private_distribution": "isPrivateDistribution", + "is_service_account": "isServiceAccount", + "is_user_level": "isUserLevel", + "new_signature": "newSignature", + "scope_to_scope_group_pks": "scopeToScopeGroupPks", + "scopes": "scopes", + "signature": "signature", + "trial_scope_to_scope_group_pks": "trialScopeToScopeGroupPks", + "trial_scopes": "trialScopes", + "user_id": "userId", + } + + def __init__( + self, + app_id=None, + app_install_id=None, + audience=None, + expires_at=None, + hub_id=None, + hublet=None, + installing_user_id=None, + is_private_distribution=None, + is_service_account=None, + is_user_level=None, + new_signature=None, + scope_to_scope_group_pks=None, + scopes=None, + signature=None, + trial_scope_to_scope_group_pks=None, + trial_scopes=None, + user_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """SignedAccessToken - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._app_id = None + self._app_install_id = None + self._audience = None + self._expires_at = None + self._hub_id = None + self._hublet = None + self._installing_user_id = None + self._is_private_distribution = None + self._is_service_account = None + self._is_user_level = None + self._new_signature = None + self._scope_to_scope_group_pks = None + self._scopes = None + self._signature = None + self._trial_scope_to_scope_group_pks = None + self._trial_scopes = None + self._user_id = None + self.discriminator = None + + self.app_id = app_id + self.app_install_id = app_install_id + self.audience = audience + self.expires_at = expires_at + self.hub_id = hub_id + self.hublet = hublet + self.installing_user_id = installing_user_id + self.is_private_distribution = is_private_distribution + self.is_service_account = is_service_account + self.is_user_level = is_user_level + self.new_signature = new_signature + self.scope_to_scope_group_pks = scope_to_scope_group_pks + self.scopes = scopes + self.signature = signature + self.trial_scope_to_scope_group_pks = trial_scope_to_scope_group_pks + self.trial_scopes = trial_scopes + self.user_id = user_id + + @property + def app_id(self): + """Gets the app_id of this SignedAccessToken. # noqa: E501 + + + :return: The app_id of this SignedAccessToken. # noqa: E501 + :rtype: int + """ + return self._app_id + + @app_id.setter + def app_id(self, app_id): + """Sets the app_id of this SignedAccessToken. + + + :param app_id: The app_id of this SignedAccessToken. # noqa: E501 + :type app_id: int + """ + if self.local_vars_configuration.client_side_validation and app_id is None: # noqa: E501 + raise ValueError("Invalid value for `app_id`, must not be `None`") # noqa: E501 + + self._app_id = app_id + + @property + def app_install_id(self): + """Gets the app_install_id of this SignedAccessToken. # noqa: E501 + + + :return: The app_install_id of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._app_install_id + + @app_install_id.setter + def app_install_id(self, app_install_id): + """Sets the app_install_id of this SignedAccessToken. + + + :param app_install_id: The app_install_id of this SignedAccessToken. # noqa: E501 + :type app_install_id: str + """ + if self.local_vars_configuration.client_side_validation and app_install_id is None: # noqa: E501 + raise ValueError("Invalid value for `app_install_id`, must not be `None`") # noqa: E501 + + self._app_install_id = app_install_id + + @property + def audience(self): + """Gets the audience of this SignedAccessToken. # noqa: E501 + + + :return: The audience of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._audience + + @audience.setter + def audience(self, audience): + """Sets the audience of this SignedAccessToken. + + + :param audience: The audience of this SignedAccessToken. # noqa: E501 + :type audience: str + """ + if self.local_vars_configuration.client_side_validation and audience is None: # noqa: E501 + raise ValueError("Invalid value for `audience`, must not be `None`") # noqa: E501 + + self._audience = audience + + @property + def expires_at(self): + """Gets the expires_at of this SignedAccessToken. # noqa: E501 + + + :return: The expires_at of this SignedAccessToken. # noqa: E501 + :rtype: int + """ + return self._expires_at + + @expires_at.setter + def expires_at(self, expires_at): + """Sets the expires_at of this SignedAccessToken. + + + :param expires_at: The expires_at of this SignedAccessToken. # noqa: E501 + :type expires_at: int + """ + if self.local_vars_configuration.client_side_validation and expires_at is None: # noqa: E501 + raise ValueError("Invalid value for `expires_at`, must not be `None`") # noqa: E501 + + self._expires_at = expires_at + + @property + def hub_id(self): + """Gets the hub_id of this SignedAccessToken. # noqa: E501 + + + :return: The hub_id of this SignedAccessToken. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this SignedAccessToken. + + + :param hub_id: The hub_id of this SignedAccessToken. # noqa: E501 + :type hub_id: int + """ + if self.local_vars_configuration.client_side_validation and hub_id is None: # noqa: E501 + raise ValueError("Invalid value for `hub_id`, must not be `None`") # noqa: E501 + + self._hub_id = hub_id + + @property + def hublet(self): + """Gets the hublet of this SignedAccessToken. # noqa: E501 + + + :return: The hublet of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._hublet + + @hublet.setter + def hublet(self, hublet): + """Sets the hublet of this SignedAccessToken. + + + :param hublet: The hublet of this SignedAccessToken. # noqa: E501 + :type hublet: str + """ + if self.local_vars_configuration.client_side_validation and hublet is None: # noqa: E501 + raise ValueError("Invalid value for `hublet`, must not be `None`") # noqa: E501 + + self._hublet = hublet + + @property + def installing_user_id(self): + """Gets the installing_user_id of this SignedAccessToken. # noqa: E501 + + + :return: The installing_user_id of this SignedAccessToken. # noqa: E501 + :rtype: int + """ + return self._installing_user_id + + @installing_user_id.setter + def installing_user_id(self, installing_user_id): + """Sets the installing_user_id of this SignedAccessToken. + + + :param installing_user_id: The installing_user_id of this SignedAccessToken. # noqa: E501 + :type installing_user_id: int + """ + if self.local_vars_configuration.client_side_validation and installing_user_id is None: # noqa: E501 + raise ValueError("Invalid value for `installing_user_id`, must not be `None`") # noqa: E501 + + self._installing_user_id = installing_user_id + + @property + def is_private_distribution(self): + """Gets the is_private_distribution of this SignedAccessToken. # noqa: E501 + + + :return: The is_private_distribution of this SignedAccessToken. # noqa: E501 + :rtype: bool + """ + return self._is_private_distribution + + @is_private_distribution.setter + def is_private_distribution(self, is_private_distribution): + """Sets the is_private_distribution of this SignedAccessToken. + + + :param is_private_distribution: The is_private_distribution of this SignedAccessToken. # noqa: E501 + :type is_private_distribution: bool + """ + if self.local_vars_configuration.client_side_validation and is_private_distribution is None: # noqa: E501 + raise ValueError("Invalid value for `is_private_distribution`, must not be `None`") # noqa: E501 + + self._is_private_distribution = is_private_distribution + + @property + def is_service_account(self): + """Gets the is_service_account of this SignedAccessToken. # noqa: E501 + + + :return: The is_service_account of this SignedAccessToken. # noqa: E501 + :rtype: bool + """ + return self._is_service_account + + @is_service_account.setter + def is_service_account(self, is_service_account): + """Sets the is_service_account of this SignedAccessToken. + + + :param is_service_account: The is_service_account of this SignedAccessToken. # noqa: E501 + :type is_service_account: bool + """ + if self.local_vars_configuration.client_side_validation and is_service_account is None: # noqa: E501 + raise ValueError("Invalid value for `is_service_account`, must not be `None`") # noqa: E501 + + self._is_service_account = is_service_account + + @property + def is_user_level(self): + """Gets the is_user_level of this SignedAccessToken. # noqa: E501 + + + :return: The is_user_level of this SignedAccessToken. # noqa: E501 + :rtype: bool + """ + return self._is_user_level + + @is_user_level.setter + def is_user_level(self, is_user_level): + """Sets the is_user_level of this SignedAccessToken. + + + :param is_user_level: The is_user_level of this SignedAccessToken. # noqa: E501 + :type is_user_level: bool + """ + if self.local_vars_configuration.client_side_validation and is_user_level is None: # noqa: E501 + raise ValueError("Invalid value for `is_user_level`, must not be `None`") # noqa: E501 + + self._is_user_level = is_user_level + + @property + def new_signature(self): + """Gets the new_signature of this SignedAccessToken. # noqa: E501 + + + :return: The new_signature of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._new_signature + + @new_signature.setter + def new_signature(self, new_signature): + """Sets the new_signature of this SignedAccessToken. + + + :param new_signature: The new_signature of this SignedAccessToken. # noqa: E501 + :type new_signature: str + """ + if self.local_vars_configuration.client_side_validation and new_signature is None: # noqa: E501 + raise ValueError("Invalid value for `new_signature`, must not be `None`") # noqa: E501 + + self._new_signature = new_signature + + @property + def scope_to_scope_group_pks(self): + """Gets the scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + + + :return: The scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._scope_to_scope_group_pks + + @scope_to_scope_group_pks.setter + def scope_to_scope_group_pks(self, scope_to_scope_group_pks): + """Sets the scope_to_scope_group_pks of this SignedAccessToken. + + + :param scope_to_scope_group_pks: The scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + :type scope_to_scope_group_pks: str + """ + if self.local_vars_configuration.client_side_validation and scope_to_scope_group_pks is None: # noqa: E501 + raise ValueError("Invalid value for `scope_to_scope_group_pks`, must not be `None`") # noqa: E501 + + self._scope_to_scope_group_pks = scope_to_scope_group_pks + + @property + def scopes(self): + """Gets the scopes of this SignedAccessToken. # noqa: E501 + + + :return: The scopes of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this SignedAccessToken. + + + :param scopes: The scopes of this SignedAccessToken. # noqa: E501 + :type scopes: str + """ + if self.local_vars_configuration.client_side_validation and scopes is None: # noqa: E501 + raise ValueError("Invalid value for `scopes`, must not be `None`") # noqa: E501 + + self._scopes = scopes + + @property + def signature(self): + """Gets the signature of this SignedAccessToken. # noqa: E501 + + + :return: The signature of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._signature + + @signature.setter + def signature(self, signature): + """Sets the signature of this SignedAccessToken. + + + :param signature: The signature of this SignedAccessToken. # noqa: E501 + :type signature: str + """ + if self.local_vars_configuration.client_side_validation and signature is None: # noqa: E501 + raise ValueError("Invalid value for `signature`, must not be `None`") # noqa: E501 + + self._signature = signature + + @property + def trial_scope_to_scope_group_pks(self): + """Gets the trial_scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + + + :return: The trial_scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._trial_scope_to_scope_group_pks + + @trial_scope_to_scope_group_pks.setter + def trial_scope_to_scope_group_pks(self, trial_scope_to_scope_group_pks): + """Sets the trial_scope_to_scope_group_pks of this SignedAccessToken. + + + :param trial_scope_to_scope_group_pks: The trial_scope_to_scope_group_pks of this SignedAccessToken. # noqa: E501 + :type trial_scope_to_scope_group_pks: str + """ + if self.local_vars_configuration.client_side_validation and trial_scope_to_scope_group_pks is None: # noqa: E501 + raise ValueError("Invalid value for `trial_scope_to_scope_group_pks`, must not be `None`") # noqa: E501 + + self._trial_scope_to_scope_group_pks = trial_scope_to_scope_group_pks + + @property + def trial_scopes(self): + """Gets the trial_scopes of this SignedAccessToken. # noqa: E501 + + + :return: The trial_scopes of this SignedAccessToken. # noqa: E501 + :rtype: str + """ + return self._trial_scopes + + @trial_scopes.setter + def trial_scopes(self, trial_scopes): + """Sets the trial_scopes of this SignedAccessToken. + + + :param trial_scopes: The trial_scopes of this SignedAccessToken. # noqa: E501 + :type trial_scopes: str + """ + if self.local_vars_configuration.client_side_validation and trial_scopes is None: # noqa: E501 + raise ValueError("Invalid value for `trial_scopes`, must not be `None`") # noqa: E501 + + self._trial_scopes = trial_scopes + + @property + def user_id(self): + """Gets the user_id of this SignedAccessToken. # noqa: E501 + + + :return: The user_id of this SignedAccessToken. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this SignedAccessToken. + + + :param user_id: The user_id of this SignedAccessToken. # noqa: E501 + :type user_id: int + """ + if self.local_vars_configuration.client_side_validation and user_id is None: # noqa: E501 + raise ValueError("Invalid value for `user_id`, must not be `None`") # noqa: E501 + + self._user_id = user_id + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, SignedAccessToken): + 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, SignedAccessToken): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/token_info_response_base_if.py b/hubspot/oauth/v3/models/token_info_response_base_if.py new file mode 100644 index 00000000..50644401 --- /dev/null +++ b/hubspot/oauth/v3/models/token_info_response_base_if.py @@ -0,0 +1,503 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class TokenInfoResponseBaseIF(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "active": "bool", + "app_id": "int", + "client_id": "str", + "expires_in": "int", + "hub_domain": "str", + "hub_id": "int", + "is_private_distribution": "bool", + "scopes": "list[str]", + "signed_access_token": "SignedAccessToken", + "token": "str", + "token_type": "str", + "token_use": "str", + "user": "str", + "user_id": "int", + } + + attribute_map = { + "active": "active", + "app_id": "app_id", + "client_id": "client_id", + "expires_in": "expires_in", + "hub_domain": "hub_domain", + "hub_id": "hub_id", + "is_private_distribution": "is_private_distribution", + "scopes": "scopes", + "signed_access_token": "signed_access_token", + "token": "token", + "token_type": "token_type", + "token_use": "token_use", + "user": "user", + "user_id": "user_id", + } + + discriminator_value_class_map = {} + + def __init__( + self, + active=None, + app_id=None, + client_id=None, + expires_in=None, + hub_domain=None, + hub_id=None, + is_private_distribution=None, + scopes=None, + signed_access_token=None, + token=None, + token_type=None, + token_use="refresh_token", + user=None, + user_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """TokenInfoResponseBaseIF - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._active = None + self._app_id = None + self._client_id = None + self._expires_in = None + self._hub_domain = None + self._hub_id = None + self._is_private_distribution = None + self._scopes = None + self._signed_access_token = None + self._token = None + self._token_type = None + self._token_use = None + self._user = None + self._user_id = None + self.discriminator = "token_use" + + self.active = active + self.app_id = app_id + self.client_id = client_id + self.expires_in = expires_in + if hub_domain is not None: + self.hub_domain = hub_domain + self.hub_id = hub_id + self.is_private_distribution = is_private_distribution + self.scopes = scopes + self.signed_access_token = signed_access_token + self.token = token + self.token_type = token_type + self.token_use = token_use + if user is not None: + self.user = user + self.user_id = user_id + + @property + def active(self): + """Gets the active of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The active of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: bool + """ + return self._active + + @active.setter + def active(self, active): + """Sets the active of this TokenInfoResponseBaseIF. + + + :param active: The active of this TokenInfoResponseBaseIF. # noqa: E501 + :type active: bool + """ + if self.local_vars_configuration.client_side_validation and active is None: # noqa: E501 + raise ValueError("Invalid value for `active`, must not be `None`") # noqa: E501 + + self._active = active + + @property + def app_id(self): + """Gets the app_id of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The app_id of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: int + """ + return self._app_id + + @app_id.setter + def app_id(self, app_id): + """Sets the app_id of this TokenInfoResponseBaseIF. + + + :param app_id: The app_id of this TokenInfoResponseBaseIF. # noqa: E501 + :type app_id: int + """ + if self.local_vars_configuration.client_side_validation and app_id is None: # noqa: E501 + raise ValueError("Invalid value for `app_id`, must not be `None`") # noqa: E501 + + self._app_id = app_id + + @property + def client_id(self): + """Gets the client_id of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The client_id of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._client_id + + @client_id.setter + def client_id(self, client_id): + """Sets the client_id of this TokenInfoResponseBaseIF. + + + :param client_id: The client_id of this TokenInfoResponseBaseIF. # noqa: E501 + :type client_id: str + """ + if self.local_vars_configuration.client_side_validation and client_id is None: # noqa: E501 + raise ValueError("Invalid value for `client_id`, must not be `None`") # noqa: E501 + + self._client_id = client_id + + @property + def expires_in(self): + """Gets the expires_in of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The expires_in of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: int + """ + return self._expires_in + + @expires_in.setter + def expires_in(self, expires_in): + """Sets the expires_in of this TokenInfoResponseBaseIF. + + + :param expires_in: The expires_in of this TokenInfoResponseBaseIF. # noqa: E501 + :type expires_in: int + """ + if self.local_vars_configuration.client_side_validation and expires_in is None: # noqa: E501 + raise ValueError("Invalid value for `expires_in`, must not be `None`") # noqa: E501 + + self._expires_in = expires_in + + @property + def hub_domain(self): + """Gets the hub_domain of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The hub_domain of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._hub_domain + + @hub_domain.setter + def hub_domain(self, hub_domain): + """Sets the hub_domain of this TokenInfoResponseBaseIF. + + + :param hub_domain: The hub_domain of this TokenInfoResponseBaseIF. # noqa: E501 + :type hub_domain: str + """ + + self._hub_domain = hub_domain + + @property + def hub_id(self): + """Gets the hub_id of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The hub_id of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this TokenInfoResponseBaseIF. + + + :param hub_id: The hub_id of this TokenInfoResponseBaseIF. # noqa: E501 + :type hub_id: int + """ + if self.local_vars_configuration.client_side_validation and hub_id is None: # noqa: E501 + raise ValueError("Invalid value for `hub_id`, must not be `None`") # noqa: E501 + + self._hub_id = hub_id + + @property + def is_private_distribution(self): + """Gets the is_private_distribution of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The is_private_distribution of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: bool + """ + return self._is_private_distribution + + @is_private_distribution.setter + def is_private_distribution(self, is_private_distribution): + """Sets the is_private_distribution of this TokenInfoResponseBaseIF. + + + :param is_private_distribution: The is_private_distribution of this TokenInfoResponseBaseIF. # noqa: E501 + :type is_private_distribution: bool + """ + if self.local_vars_configuration.client_side_validation and is_private_distribution is None: # noqa: E501 + raise ValueError("Invalid value for `is_private_distribution`, must not be `None`") # noqa: E501 + + self._is_private_distribution = is_private_distribution + + @property + def scopes(self): + """Gets the scopes of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The scopes of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this TokenInfoResponseBaseIF. + + + :param scopes: The scopes of this TokenInfoResponseBaseIF. # noqa: E501 + :type scopes: list[str] + """ + if self.local_vars_configuration.client_side_validation and scopes is None: # noqa: E501 + raise ValueError("Invalid value for `scopes`, must not be `None`") # noqa: E501 + + self._scopes = scopes + + @property + def signed_access_token(self): + """Gets the signed_access_token of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The signed_access_token of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: SignedAccessToken + """ + return self._signed_access_token + + @signed_access_token.setter + def signed_access_token(self, signed_access_token): + """Sets the signed_access_token of this TokenInfoResponseBaseIF. + + + :param signed_access_token: The signed_access_token of this TokenInfoResponseBaseIF. # noqa: E501 + :type signed_access_token: SignedAccessToken + """ + if self.local_vars_configuration.client_side_validation and signed_access_token is None: # noqa: E501 + raise ValueError("Invalid value for `signed_access_token`, must not be `None`") # noqa: E501 + + self._signed_access_token = signed_access_token + + @property + def token(self): + """Gets the token of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The token of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._token + + @token.setter + def token(self, token): + """Sets the token of this TokenInfoResponseBaseIF. + + + :param token: The token of this TokenInfoResponseBaseIF. # noqa: E501 + :type token: str + """ + if self.local_vars_configuration.client_side_validation and token is None: # noqa: E501 + raise ValueError("Invalid value for `token`, must not be `None`") # noqa: E501 + + self._token = token + + @property + def token_type(self): + """Gets the token_type of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The token_type of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this TokenInfoResponseBaseIF. + + + :param token_type: The token_type of this TokenInfoResponseBaseIF. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The token_use of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this TokenInfoResponseBaseIF. + + + :param token_use: The token_use of this TokenInfoResponseBaseIF. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["refresh_token"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user(self): + """Gets the user of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The user of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this TokenInfoResponseBaseIF. + + + :param user: The user of this TokenInfoResponseBaseIF. # noqa: E501 + :type user: str + """ + + self._user = user + + @property + def user_id(self): + """Gets the user_id of this TokenInfoResponseBaseIF. # noqa: E501 + + + :return: The user_id of this TokenInfoResponseBaseIF. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this TokenInfoResponseBaseIF. + + + :param user_id: The user_id of this TokenInfoResponseBaseIF. # noqa: E501 + :type user_id: int + """ + if self.local_vars_configuration.client_side_validation and user_id is None: # noqa: E501 + raise ValueError("Invalid value for `user_id`, must not be `None`") # noqa: E501 + + self._user_id = user_id + + 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) + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, TokenInfoResponseBaseIF): + 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, TokenInfoResponseBaseIF): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/models/token_response_if.py b/hubspot/oauth/v3/models/token_response_if.py new file mode 100644 index 00000000..27a52c5c --- /dev/null +++ b/hubspot/oauth/v3/models/token_response_if.py @@ -0,0 +1,361 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from hubspot.oauth.v3.configuration import Configuration + + +class TokenResponseIF(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + 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 = { + "access_token": "str", + "expires_in": "int", + "hub_id": "int", + "id_token": "str", + "refresh_token": "str", + "scopes": "list[str]", + "token_type": "str", + "token_use": "str", + "user_id": "int", + } + + attribute_map = { + "access_token": "access_token", + "expires_in": "expires_in", + "hub_id": "hub_id", + "id_token": "id_token", + "refresh_token": "refresh_token", + "scopes": "scopes", + "token_type": "token_type", + "token_use": "token_use", + "user_id": "user_id", + } + + discriminator_value_class_map = {} + + def __init__( + self, + access_token=None, + expires_in=None, + hub_id=None, + id_token=None, + refresh_token=None, + scopes=None, + token_type=None, + token_use="client_credentials", + user_id=None, + local_vars_configuration=None, + ): # noqa: E501 + """TokenResponseIF - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._access_token = None + self._expires_in = None + self._hub_id = None + self._id_token = None + self._refresh_token = None + self._scopes = None + self._token_type = None + self._token_use = None + self._user_id = None + self.discriminator = "token_use" + + self.access_token = access_token + self.expires_in = expires_in + if hub_id is not None: + self.hub_id = hub_id + if id_token is not None: + self.id_token = id_token + self.refresh_token = refresh_token + if scopes is not None: + self.scopes = scopes + self.token_type = token_type + self.token_use = token_use + if user_id is not None: + self.user_id = user_id + + @property + def access_token(self): + """Gets the access_token of this TokenResponseIF. # noqa: E501 + + + :return: The access_token of this TokenResponseIF. # noqa: E501 + :rtype: str + """ + return self._access_token + + @access_token.setter + def access_token(self, access_token): + """Sets the access_token of this TokenResponseIF. + + + :param access_token: The access_token of this TokenResponseIF. # noqa: E501 + :type access_token: str + """ + if self.local_vars_configuration.client_side_validation and access_token is None: # noqa: E501 + raise ValueError("Invalid value for `access_token`, must not be `None`") # noqa: E501 + + self._access_token = access_token + + @property + def expires_in(self): + """Gets the expires_in of this TokenResponseIF. # noqa: E501 + + + :return: The expires_in of this TokenResponseIF. # noqa: E501 + :rtype: int + """ + return self._expires_in + + @expires_in.setter + def expires_in(self, expires_in): + """Sets the expires_in of this TokenResponseIF. + + + :param expires_in: The expires_in of this TokenResponseIF. # noqa: E501 + :type expires_in: int + """ + if self.local_vars_configuration.client_side_validation and expires_in is None: # noqa: E501 + raise ValueError("Invalid value for `expires_in`, must not be `None`") # noqa: E501 + + self._expires_in = expires_in + + @property + def hub_id(self): + """Gets the hub_id of this TokenResponseIF. # noqa: E501 + + + :return: The hub_id of this TokenResponseIF. # noqa: E501 + :rtype: int + """ + return self._hub_id + + @hub_id.setter + def hub_id(self, hub_id): + """Sets the hub_id of this TokenResponseIF. + + + :param hub_id: The hub_id of this TokenResponseIF. # noqa: E501 + :type hub_id: int + """ + + self._hub_id = hub_id + + @property + def id_token(self): + """Gets the id_token of this TokenResponseIF. # noqa: E501 + + + :return: The id_token of this TokenResponseIF. # noqa: E501 + :rtype: str + """ + return self._id_token + + @id_token.setter + def id_token(self, id_token): + """Sets the id_token of this TokenResponseIF. + + + :param id_token: The id_token of this TokenResponseIF. # noqa: E501 + :type id_token: str + """ + + self._id_token = id_token + + @property + def refresh_token(self): + """Gets the refresh_token of this TokenResponseIF. # noqa: E501 + + + :return: The refresh_token of this TokenResponseIF. # noqa: E501 + :rtype: str + """ + return self._refresh_token + + @refresh_token.setter + def refresh_token(self, refresh_token): + """Sets the refresh_token of this TokenResponseIF. + + + :param refresh_token: The refresh_token of this TokenResponseIF. # noqa: E501 + :type refresh_token: str + """ + if self.local_vars_configuration.client_side_validation and refresh_token is None: # noqa: E501 + raise ValueError("Invalid value for `refresh_token`, must not be `None`") # noqa: E501 + + self._refresh_token = refresh_token + + @property + def scopes(self): + """Gets the scopes of this TokenResponseIF. # noqa: E501 + + + :return: The scopes of this TokenResponseIF. # noqa: E501 + :rtype: list[str] + """ + return self._scopes + + @scopes.setter + def scopes(self, scopes): + """Sets the scopes of this TokenResponseIF. + + + :param scopes: The scopes of this TokenResponseIF. # noqa: E501 + :type scopes: list[str] + """ + + self._scopes = scopes + + @property + def token_type(self): + """Gets the token_type of this TokenResponseIF. # noqa: E501 + + + :return: The token_type of this TokenResponseIF. # noqa: E501 + :rtype: str + """ + return self._token_type + + @token_type.setter + def token_type(self, token_type): + """Sets the token_type of this TokenResponseIF. + + + :param token_type: The token_type of this TokenResponseIF. # noqa: E501 + :type token_type: str + """ + if self.local_vars_configuration.client_side_validation and token_type is None: # noqa: E501 + raise ValueError("Invalid value for `token_type`, must not be `None`") # noqa: E501 + + self._token_type = token_type + + @property + def token_use(self): + """Gets the token_use of this TokenResponseIF. # noqa: E501 + + + :return: The token_use of this TokenResponseIF. # noqa: E501 + :rtype: str + """ + return self._token_use + + @token_use.setter + def token_use(self, token_use): + """Sets the token_use of this TokenResponseIF. + + + :param token_use: The token_use of this TokenResponseIF. # noqa: E501 + :type token_use: str + """ + if self.local_vars_configuration.client_side_validation and token_use is None: # noqa: E501 + raise ValueError("Invalid value for `token_use`, must not be `None`") # noqa: E501 + allowed_values = ["client_credentials"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and token_use not in allowed_values: # noqa: E501 + raise ValueError("Invalid value for `token_use` ({0}), must be one of {1}".format(token_use, allowed_values)) # noqa: E501 + + self._token_use = token_use + + @property + def user_id(self): + """Gets the user_id of this TokenResponseIF. # noqa: E501 + + + :return: The user_id of this TokenResponseIF. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this TokenResponseIF. + + + :param user_id: The user_id of this TokenResponseIF. # noqa: E501 + :type user_id: int + """ + + self._user_id = user_id + + 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) + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(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, TokenResponseIF): + 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, TokenResponseIF): + return True + + return self.to_dict() != other.to_dict() diff --git a/hubspot/oauth/v3/rest.py b/hubspot/oauth/v3/rest.py new file mode 100644 index 00000000..ce538def --- /dev/null +++ b/hubspot/oauth/v3/rest.py @@ -0,0 +1,215 @@ +# coding: utf-8 + +""" + Auth Oauth + + Basepom for all HubSpot Projects # noqa: E501 + + The version of the OpenAPI document: v3 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import io +import json +import logging +import re +import ssl + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode +import urllib3 + +from hubspot.oauth.v3.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, 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 + + 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=configuration.ssl_ca_cert, + 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=configuration.ssl_ca_cert, 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, six.integer_types + (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: + 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 + + 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/tests/spec/oauth/v3/test_v3.py b/tests/spec/oauth/v3/test_v3.py new file mode 100644 index 00000000..58f65d82 --- /dev/null +++ b/tests/spec/oauth/v3/test_v3.py @@ -0,0 +1,66 @@ +import json +from unittest.mock import patch + +from hubspot import HubSpot +from hubspot.oauth.v3 import AdvancedApi +from hubspot.oauth.v3.rest import RESTResponse + + +class FakeResponse: + def __init__(self, body): + self.status = 200 + self.reason = "OK" + self.data = json.dumps(body).encode("utf-8") + + def getheaders(self): + return {"content-type": "application/json"} + + def getheader(self, name, default=None): + return self.getheaders().get(name.lower(), default) + + +def respond_with(body): + return patch("hubspot.oauth.v3.rest.RESTClientObject.request", return_value=RESTResponse(FakeResponse(body))) + + +def test_is_discoverable(): + apis = HubSpot().oauth.v3 + assert isinstance(apis.advanced_api, AdvancedApi) + + +def test_get_token_deserializes_access_token_response(): + body = { + "access_token": "access", + "refresh_token": "refresh", + "expires_in": 1800, + "token_type": "bearer", + "token_use": "access_token", + } + with respond_with(body): + response = HubSpot().oauth.v3.advanced_api.get_token() + + assert response.access_token == "access" + assert response.refresh_token == "refresh" + assert response.expires_in == 1800 + assert response.token_use == "access_token" + + +def test_introspect_token_deserializes_refresh_token_info_response(): + body = { + "active": True, + "app_id": 1, + "client_id": "client", + "hub_id": 2, + "scopes": ["oauth"], + "token": "refresh", + "token_type": "bearer", + "token_use": "refresh_token", + "user_id": 3, + } + with respond_with(body): + response = HubSpot().oauth.v3.advanced_api.introspect_token() + + assert response.active is True + assert response.app_id == 1 + assert response.token_use == "refresh_token" + assert response.user_id == 3