<filename>Telstra_Messaging/api/authentication_api.py<gh_stars>10-100
# coding: utf-8

"""
    Telstra Messaging API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: 2.2.10
    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 Telstra_Messaging.api_client import ApiClient
from Telstra_Messaging.exceptions import (
    ApiTypeError,
    ApiValueError
)


class AuthenticationApi(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 auth_token(self, client_id, client_secret, grant_type, **kwargs):  # noqa: E501
        """Generate OAuth2 token  # noqa: E501

        To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.auth_token(client_id, client_secret, grant_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str client_id:  (required)
        :param str client_secret:  (required)
        :param str grant_type: (required)
        :param str scope: NSMS
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: OAuthResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.auth_token_with_http_info(client_id, client_secret, grant_type, **kwargs)  # noqa: E501

    def auth_token_with_http_info(self, client_id, client_secret, grant_type, **kwargs):  # noqa: E501
        """Generate OAuth2 token  # noqa: E501

        To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.auth_token_with_http_info(client_id, client_secret, grant_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str client_id:  (required)
        :param str client_secret:  (required)
        :param str grant_type: (required)
        :param str scope: NSMS
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(OAuthResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['client_id', 'client_secret', 'grant_type', 'scope']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method auth_token" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'client_id' is set
        if self.api_client.client_side_validation and ('client_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['client_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `client_id` when calling `auth_token`")  # noqa: E501
        # verify the required parameter 'client_secret' is set
        if self.api_client.client_side_validation and ('client_secret' not in local_var_params or  # noqa: E501
                                                        local_var_params['client_secret'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `client_secret` when calling `auth_token`")  # noqa: E501
        # verify the required parameter 'grant_type' is set
        if self.api_client.client_side_validation and ('grant_type' not in local_var_params or  # noqa: E501
                                                        local_var_params['grant_type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `grant_type` when calling `auth_token`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        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 'grant_type' in local_var_params:
            form_params.append(('grant_type', local_var_params['grant_type']))  # 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`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/x-www-form-urlencoded'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/oauth/token', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='OAuthResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

<filename>Telstra_Messaging/api/authentication_api.py<gh_stars>10-100
# coding: utf-8

"""
    Telstra Messaging API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: 2.2.10
    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 Telstra_Messaging.api_client import ApiClient
from Telstra_Messaging.exceptions import (
    ApiTypeError,
    ApiValueError
)


class AuthenticationApi(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 auth_token(self, client_id, client_secret, grant_type, **kwargs):  # noqa: E501
        """Generate OAuth2 token  # noqa: E501

        To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.auth_token(client_id, client_secret, grant_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str client_id:  (required)
        :param str client_secret:  (required)
        :param str grant_type: (required)
        :param str scope: NSMS
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: OAuthResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.auth_token_with_http_info(client_id, client_secret, grant_type, **kwargs)  # noqa: E501

    def auth_token_with_http_info(self, client_id, client_secret, grant_type, **kwargs):  # noqa: E501
        """Generate OAuth2 token  # noqa: E501

        To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.auth_token_with_http_info(client_id, client_secret, grant_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str client_id:  (required)
        :param str client_secret:  (required)
        :param str grant_type: (required)
        :param str scope: NSMS
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(OAuthResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['client_id', 'client_secret', 'grant_type', 'scope']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method auth_token" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'client_id' is set
        if self.api_client.client_side_validation and ('client_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['client_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `client_id` when calling `auth_token`")  # noqa: E501
        # verify the required parameter 'client_secret' is set
        if self.api_client.client_side_validation and ('client_secret' not in local_var_params or  # noqa: E501
                                                        local_var_params['client_secret'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `client_secret` when calling `auth_token`")  # noqa: E501
        # verify the required parameter 'grant_type' is set
        if self.api_client.client_side_validation and ('grant_type' not in local_var_params or  # noqa: E501
                                                        local_var_params['grant_type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `grant_type` when calling `auth_token`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        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 'grant_type' in local_var_params:
            form_params.append(('grant_type', local_var_params['grant_type']))  # 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`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/x-www-form-urlencoded'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/oauth/token', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='OAuthResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

# coding: utf-8 Telstra Messaging API      No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501      The version of the OpenAPI document: 2.2.10     Generated by: https://openapi-generator.tech # noqa: F401 # python 2 and python 3 compatibility library NOTE: This class is auto generated by OpenAPI Generator     Ref: https://openapi-generator.tech      Do not edit the class manually. # noqa: E501 Generate OAuth2 token  # noqa: E501          To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501         This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please pass async_req=True         >>> thread = api.auth_token(client_id, client_secret, grant_type, async_req=True)         >>> result = thread.get()          :param async_req bool: execute request asynchronously         :param str client_id:  (required)         :param str client_secret:  (required)         :param str grant_type: (required)         :param str scope: NSMS         :param _preload_content: if False, the urllib3.HTTPResponse object will                                  be returned without reading/decoding response                                  data. Default is True.         :param _request_timeout: timeout setting for this request. If one                                  number provided, it will be total request                                  timeout. It can also be a pair (tuple) of                                  (connection, read) timeouts.         :return: OAuthResponse                  If the method is called asynchronously,                  returns the request thread. # noqa: E501 # noqa: E501 Generate OAuth2 token  # noqa: E501          To generate an OAuth2 Authentication token, pass through your `Client key` and `Client secret` that you received when you registered for the **API Free Trial** Product.  The grant_type should be left as `client_credentials` and the scope as `NSMS`.  The token will expire in one hour.   # noqa: E501         This method makes a synchronous HTTP request by default. To make an         asynchronous HTTP request, please pass async_req=True         >>> thread = api.auth_token_with_http_info(client_id, client_secret, grant_type, async_req=True)         >>> result = thread.get()          :param async_req bool: execute request asynchronously         :param str client_id:  (required)         :param str client_secret:  (required)         :param str grant_type: (required)         :param str scope: NSMS         :param _return_http_data_only: response data without head status code                                        and headers         :param _preload_content: if False, the urllib3.HTTPResponse object will                                  be returned without reading/decoding response                                  data. Default is True.         :param _request_timeout: timeout setting for this request. If one                                  number provided, it will be total request                                  timeout. It can also be a pair (tuple) of                                  (connection, read) timeouts.         :return: tuple(OAuthResponse, status_code(int), headers(HTTPHeaderDict))                  If the method is called asynchronously,                  returns the request thread. # noqa: E501 # verify the required parameter 'client_id' is set # noqa: E501 # noqa: E501 # noqa: E501 # verify the required parameter 'client_secret' is set # noqa: E501 # noqa: E501 # noqa: E501 # verify the required parameter 'grant_type' is set # noqa: E501 # noqa: E501 # noqa: E501 # noqa: E501 # noqa: E501 # noqa: E501 # noqa: E501 # HTTP header `Accept` # noqa: E501 # HTTP header `Content-Type` # noqa: E501 # noqa: E501 # Authentication setting # noqa: E501 # noqa: E501 # noqa: E501