# coding: utf-8

"""
    University Human Resources API

    This API exposes identity information from the University Human Resources system. The purpose of this API is to give access to basic identity information about staff members for use by downstream systems, therefore the data exposed is limited to basic information about who a staff member is and details of any affiliations they have.  This API uses the following identifiers to link people to person-records held within different systems:  * `person.v1.human-resources.university.identifiers.cam.ac.uk` - the university human resources (uhr) identifier of     this person - also known as the staff number of HRN. * `v1.person.identifiers.cam.ac.uk` - the common registration scheme identifier (CRSid) of     this person.  Additionally this API uses the following identifiers to link people to institutions or entities which a person may have an affiliation to:  * `institution.v1.human-resources.university.identifiers.cam.ac.uk` - the university human resources (uhr) institution     identifier. This encompasses departments within the University HR system     (currently CHRIS). * `institution.v1.student-records.university.identifiers.cam.ac.uk` - the student records institution identifier. This     encompasses colleges within the University Student Records system (currently CamSIS).  Affiliations can be used to indicate an institution that a person holds a position within, with the `status` indicating the job role that is held and the scheme of the affiliation being `institution.v1.human-resources.university.identifiers.cam.ac.uk`. Additionally an affiliation can indicate a staff member's line manager with the scheme being `person.v1.human-resources.university.identifiers.cam.ac.uk` and the status being `report`. A staff member can have multiple institution affiliations and multiple report affiliations.  This API is currently backed by data from CHRIS, exposing a view which is updated hourly.  

    The version of the OpenAPI document: v1alpha2
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictInt, StrictStr

from typing import Optional

from identitylib.hr_client.models.paginated_results_staff_member import PaginatedResultsStaffMember
from identitylib.hr_client.models.staff_member import StaffMember

from identitylib.hr_client.api_client import ApiClient
from identitylib.hr_client.api_response import ApiResponse
from identitylib.hr_client.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class StaffMembersApi(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.get_default()
        self.api_client = api_client

    @validate_arguments
    def get_v1alpha2_staff_member_staff_identifier_get(self, identifier : StrictStr, **kwargs) -> StaffMember:  # noqa: E501
        """Get a single staff member  # noqa: E501

        Returns a single staff member based on the identifier provided. The identifier can be provided in the format `<value>@<scheme>`, if the scheme is omitted it shall be assumed that the scheme is `person.v1.human-resources.university.identifiers.cam.ac.uk` (also know as the staff number or HRN).  Currently this endpoint only supports querying by `person.v1.human-resources.university.identifiers.cam.ac.uk` and `v1.person.identifiers.cam.ac.uk` identifiers.  # 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_v1alpha2_staff_member_staff_identifier_get(identifier, async_req=True)
        >>> result = thread.get()

        :param identifier: (required)
        :type identifier: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: 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: StaffMember
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            raise ValueError("Error! Please call the get_v1alpha2_staff_member_staff_identifier_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
        return self.get_v1alpha2_staff_member_staff_identifier_get_with_http_info(identifier, **kwargs)  # noqa: E501

    @validate_arguments
    def get_v1alpha2_staff_member_staff_identifier_get_with_http_info(self, identifier : StrictStr, **kwargs) -> ApiResponse:  # noqa: E501
        """Get a single staff member  # noqa: E501

        Returns a single staff member based on the identifier provided. The identifier can be provided in the format `<value>@<scheme>`, if the scheme is omitted it shall be assumed that the scheme is `person.v1.human-resources.university.identifiers.cam.ac.uk` (also know as the staff number or HRN).  Currently this endpoint only supports querying by `person.v1.human-resources.university.identifiers.cam.ac.uk` and `v1.person.identifiers.cam.ac.uk` identifiers.  # 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_v1alpha2_staff_member_staff_identifier_get_with_http_info(identifier, async_req=True)
        >>> result = thread.get()

        :param identifier: (required)
        :type identifier: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the 
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: 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(StaffMember, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'identifier'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_v1alpha2_staff_member_staff_identifier_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['identifier']:
            _path_params['identifier'] = _params['identifier']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['ApiGatewayOAuthClientCredentials']  # noqa: E501

        _response_types_map = {
            '200': "StaffMember",
            '400': "HTTPException",
            '404': "HTTPException",
            '422': "HTTPValidationError",
        }

        return self.api_client.call_api(
            '/staff/{identifier}', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def list_v1alpha2_staff_staff_get(self, affiliation : Annotated[Optional[StrictStr], Field(description="An affiliation to filter by, in the format `<value>@<scheme>`. When included only the staff members with a matching affiliation are returned.")] = None, cursor : Annotated[Optional[StrictStr], Field(description="The cursor indicating a unique page of results - this should be auto generated on the `next` and `previous` fields and does not need to be manually added / updated.")] = None, page_size : Annotated[Optional[StrictInt], Field(description="The number of results to return per page. This is limited to 999 results, if a number over 999 is provided the results will be capped at 999. Defaults to 200.")] = None, **kwargs) -> PaginatedResultsStaffMember:  # noqa: E501
        """List staff members  # noqa: E501

        Lists all staff members held within the University Human Resources system, allowing basic filtering by affiliation.  To avoid returning very large responses, this endpoint produces a paged response. Where there are additional results which cannot be returned on a single page, a `next` field will be populated with a url containing the next page of results. These `next` urls should be followed until a page is returned with no `next` field, indicating that there are no further results. The amount of results returned can be customized using the `page_size` query parameter. The maximum amount of results returned is 999.  Staff members can be filtered by affiliation, by providing an `affiliation` query parameter. This affiliation should be provided in the format `<value>@<scheme>`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.list_v1alpha2_staff_staff_get(affiliation, cursor, page_size, async_req=True)
        >>> result = thread.get()

        :param affiliation: An affiliation to filter by, in the format `<value>@<scheme>`. When included only the staff members with a matching affiliation are returned.
        :type affiliation: str
        :param cursor: The cursor indicating a unique page of results - this should be auto generated on the `next` and `previous` fields and does not need to be manually added / updated.
        :type cursor: str
        :param page_size: The number of results to return per page. This is limited to 999 results, if a number over 999 is provided the results will be capped at 999. Defaults to 200.
        :type page_size: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: 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: PaginatedResultsStaffMember
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            raise ValueError("Error! Please call the list_v1alpha2_staff_staff_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data")
        return self.list_v1alpha2_staff_staff_get_with_http_info(affiliation, cursor, page_size, **kwargs)  # noqa: E501

    @validate_arguments
    def list_v1alpha2_staff_staff_get_with_http_info(self, affiliation : Annotated[Optional[StrictStr], Field(description="An affiliation to filter by, in the format `<value>@<scheme>`. When included only the staff members with a matching affiliation are returned.")] = None, cursor : Annotated[Optional[StrictStr], Field(description="The cursor indicating a unique page of results - this should be auto generated on the `next` and `previous` fields and does not need to be manually added / updated.")] = None, page_size : Annotated[Optional[StrictInt], Field(description="The number of results to return per page. This is limited to 999 results, if a number over 999 is provided the results will be capped at 999. Defaults to 200.")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List staff members  # noqa: E501

        Lists all staff members held within the University Human Resources system, allowing basic filtering by affiliation.  To avoid returning very large responses, this endpoint produces a paged response. Where there are additional results which cannot be returned on a single page, a `next` field will be populated with a url containing the next page of results. These `next` urls should be followed until a page is returned with no `next` field, indicating that there are no further results. The amount of results returned can be customized using the `page_size` query parameter. The maximum amount of results returned is 999.  Staff members can be filtered by affiliation, by providing an `affiliation` query parameter. This affiliation should be provided in the format `<value>@<scheme>`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.list_v1alpha2_staff_staff_get_with_http_info(affiliation, cursor, page_size, async_req=True)
        >>> result = thread.get()

        :param affiliation: An affiliation to filter by, in the format `<value>@<scheme>`. When included only the staff members with a matching affiliation are returned.
        :type affiliation: str
        :param cursor: The cursor indicating a unique page of results - this should be auto generated on the `next` and `previous` fields and does not need to be manually added / updated.
        :type cursor: str
        :param page_size: The number of results to return per page. This is limited to 999 results, if a number over 999 is provided the results will be capped at 999. Defaults to 200.
        :type page_size: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the 
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: 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(PaginatedResultsStaffMember, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'affiliation',
            'cursor',
            'page_size'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_v1alpha2_staff_staff_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('affiliation') is not None:  # noqa: E501
            _query_params.append(('affiliation', _params['affiliation']))

        if _params.get('cursor') is not None:  # noqa: E501
            _query_params.append(('cursor', _params['cursor']))

        if _params.get('page_size') is not None:  # noqa: E501
            _query_params.append(('page_size', _params['page_size']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['ApiGatewayOAuthClientCredentials']  # noqa: E501

        _response_types_map = {
            '200': "PaginatedResultsStaffMember",
            '400': "HTTPException",
            '422': "HTTPValidationError",
        }

        return self.api_client.call_api(
            '/staff', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
