# coding: utf-8

"""
    Fabric Orchestrator API

    This is Fabric Orchestrator API  # noqa: E501

    OpenAPI spec version: 1.0.1
    Contact: kthare10@unc.edu
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from fabric_cf.orchestrator.swagger_client.api_client import ApiClient


class PoasApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def poas_create_sliver_id_post(self, body, sliver_id, **kwargs):  # noqa: E501
        """Perform an operational action on a sliver.  # noqa: E501

        Request to perform an operation action on a sliver. Supported actions include - reboot a VM sliver, get cpu info, get numa info, pin vCPUs, pin memory to a numa node etc, add/remove ssh keys.     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_create_sliver_id_post(body, sliver_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param PoaPost body: Perform Operation Action (required)
        :param str sliver_id: Sliver identified by universally unique identifier (required)
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.poas_create_sliver_id_post_with_http_info(body, sliver_id, **kwargs)  # noqa: E501
        else:
            (data) = self.poas_create_sliver_id_post_with_http_info(body, sliver_id, **kwargs)  # noqa: E501
            return data

    def poas_create_sliver_id_post_with_http_info(self, body, sliver_id, **kwargs):  # noqa: E501
        """Perform an operational action on a sliver.  # noqa: E501

        Request to perform an operation action on a sliver. Supported actions include - reboot a VM sliver, get cpu info, get numa info, pin vCPUs, pin memory to a numa node etc, add/remove ssh keys.     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_create_sliver_id_post_with_http_info(body, sliver_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param PoaPost body: Perform Operation Action (required)
        :param str sliver_id: Sliver identified by universally unique identifier (required)
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'sliver_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method poas_create_sliver_id_post" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'body' is set
        if ('body' not in params or
                params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `poas_create_sliver_id_post`")  # noqa: E501
        # verify the required parameter 'sliver_id' is set
        if ('sliver_id' not in params or
                params['sliver_id'] is None):
            raise ValueError("Missing the required parameter `sliver_id` when calling `poas_create_sliver_id_post`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'sliver_id' in params:
            path_params['sliver_id'] = params['sliver_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearerAuth']  # noqa: E501

        return self.api_client.call_api(
            '/poas/create/{sliver_id}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Poa',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def poas_get(self, **kwargs):  # noqa: E501
        """Request get the status of the POAs.  # noqa: E501

        Request get the status of the POAs     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_get(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str sliver_id: Search for POAs for a sliver
        :param list[str] states: Search for POAs in the specified states
        :param int limit: maximum number of results to return per page (1 or more)
        :param int offset: number of items to skip before starting to collect the result set
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.poas_get_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.poas_get_with_http_info(**kwargs)  # noqa: E501
            return data

    def poas_get_with_http_info(self, **kwargs):  # noqa: E501
        """Request get the status of the POAs.  # noqa: E501

        Request get the status of the POAs     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str sliver_id: Search for POAs for a sliver
        :param list[str] states: Search for POAs in the specified states
        :param int limit: maximum number of results to return per page (1 or more)
        :param int offset: number of items to skip before starting to collect the result set
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['sliver_id', 'states', 'limit', 'offset']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method poas_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'sliver_id' in params:
            query_params.append(('sliver_id', params['sliver_id']))  # noqa: E501
        if 'states' in params:
            query_params.append(('states', params['states']))  # noqa: E501
            collection_formats['states'] = 'multi'  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearerAuth']  # noqa: E501

        return self.api_client.call_api(
            '/poas/', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Poa',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def poas_poa_id_get(self, poa_id, **kwargs):  # noqa: E501
        """Perform an operational action on a sliver.  # noqa: E501

        Request get the status of the POA identified by poa_id.     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_poa_id_get(poa_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str poa_id: Poa Id for the POA triggered (required)
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.poas_poa_id_get_with_http_info(poa_id, **kwargs)  # noqa: E501
        else:
            (data) = self.poas_poa_id_get_with_http_info(poa_id, **kwargs)  # noqa: E501
            return data

    def poas_poa_id_get_with_http_info(self, poa_id, **kwargs):  # noqa: E501
        """Perform an operational action on a sliver.  # noqa: E501

        Request get the status of the POA identified by poa_id.     # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.poas_poa_id_get_with_http_info(poa_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str poa_id: Poa Id for the POA triggered (required)
        :return: Poa
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['poa_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method poas_poa_id_get" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'poa_id' is set
        if ('poa_id' not in params or
                params['poa_id'] is None):
            raise ValueError("Missing the required parameter `poa_id` when calling `poas_poa_id_get`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'poa_id' in params:
            path_params['poa_id'] = params['poa_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearerAuth']  # noqa: E501

        return self.api_client.call_api(
            '/poas/{poa_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Poa',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
