# coding: utf-8

"""
    Eazyrent IAM API

    EazyRent IAM API ==================  Description -------------  The EazyRent IAM API provides robust identity and access management capabilities, enabling efficient account management and permission controls across the platform. Tailored for the SaaS environment, this API allows administrators to handle user authentication, manage roles, and define permissions to secure access to various resources. By centralizing user accounts and access rules, the IAM API ensures a secure, organized, and scalable approach to managing tenant and staff permissions.  Target Audience ------------------   * **Real Estate Agencies and Social Housing Providers:** Organizations requiring a secure, structured way to manage access for staff and tenants, ensuring that only authorized users can access specific resources and functionalities.   * **Rent Guarantee Insurers:** Companies that need to manage and restrict access to sensitive information, allowing only certain roles to handle tenant verification and risk assessment data.  Purpose --------  The purpose of the EazyRent IAM API is to centralize identity and permission management for platform users. Through this API, businesses can handle account creation, manage user roles, assign permissions, and track access to critical resources, all while ensuring compliance and data security. This results in streamlined operations, allowing clients to configure role-based access in alignment with organizational policies and requirements.  How to use this API -----------------------  To start using the EazyRent IAM API, consult our detailed documentation, which provides information on authentication, endpoint definitions, and integration best practices. This documentation covers the steps required to manage user identities, roles, and permissions within your existing systems, ensuring secure and efficient access control across the platform.

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

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

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictStr
from typing import Any, Optional
from typing_extensions import Annotated
from eazyrent.iam.v1.models.update_user_grants import UpdateUserGrants

from eazyrent.iam.v1.api_client import ApiClient, RequestSerialized
from eazyrent.iam.v1.api_response import ApiResponse
from eazyrent.iam.v1.rest import RESTResponseType


class UserGrantsApi:
    """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) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_call
    def retrieve_my_authorizations(
        self,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> object:
        """Retrieve my authorizations

        Retrieve Current User Authorizations.  This endpoint retrieves all authorization grants for the currently authenticated user using the Zitadel client. It queries the user's organization for available grants and returns them in a list.  ## Response: - **200 OK**: Returns a list of authorization grants for the current user. - **401 Unauthorized**: If the user is not authenticated. - **403 Forbidden**: If the user lacks necessary permissions.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer

        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_my_authorizations_serialize(
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    def retrieve_my_authorizations_with_http_info(
        self,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[object]:
        """Retrieve my authorizations

        Retrieve Current User Authorizations.  This endpoint retrieves all authorization grants for the currently authenticated user using the Zitadel client. It queries the user's organization for available grants and returns them in a list.  ## Response: - **200 OK**: Returns a list of authorization grants for the current user. - **401 Unauthorized**: If the user is not authenticated. - **403 Forbidden**: If the user lacks necessary permissions.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer

        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_my_authorizations_serialize(
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )

    @validate_call
    def retrieve_my_authorizations_without_preload_content(
        self,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Retrieve my authorizations

        Retrieve Current User Authorizations.  This endpoint retrieves all authorization grants for the currently authenticated user using the Zitadel client. It queries the user's organization for available grants and returns them in a list.  ## Response: - **200 OK**: Returns a list of authorization grants for the current user. - **401 Unauthorized**: If the user is not authenticated. - **403 Forbidden**: If the user lacks necessary permissions.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer

        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_my_authorizations_serialize(
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _retrieve_my_authorizations_serialize(
        self,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = ["APIKeyHeader", "OAuth2"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/user-grants/me/authorizations/",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )

    @validate_call
    def retrieve_user_authorizations(
        self,
        user_id: StrictStr,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> object:
        """Retrieve user authorizations

        Retrieve User Authorizations.  This endpoint fetches the groups or permissions for a specific user. It searches for the user within the organization of the authenticated client and returns the user's roles or permissions.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are to be retrieved.  ## Response: - **200 OK**: Returns a list of groups or permissions for the specified user. - **404 Not Found**: If the user is not found within the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `org:staff` - `org:user` - `organization:read`

        :param user_id: (required)
        :type user_id: str
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_user_authorizations_serialize(
            user_id=user_id,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    def retrieve_user_authorizations_with_http_info(
        self,
        user_id: StrictStr,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[object]:
        """Retrieve user authorizations

        Retrieve User Authorizations.  This endpoint fetches the groups or permissions for a specific user. It searches for the user within the organization of the authenticated client and returns the user's roles or permissions.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are to be retrieved.  ## Response: - **200 OK**: Returns a list of groups or permissions for the specified user. - **404 Not Found**: If the user is not found within the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `org:staff` - `org:user` - `organization:read`

        :param user_id: (required)
        :type user_id: str
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_user_authorizations_serialize(
            user_id=user_id,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )

    @validate_call
    def retrieve_user_authorizations_without_preload_content(
        self,
        user_id: StrictStr,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Retrieve user authorizations

        Retrieve User Authorizations.  This endpoint fetches the groups or permissions for a specific user. It searches for the user within the organization of the authenticated client and returns the user's roles or permissions.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are to be retrieved.  ## Response: - **200 OK**: Returns a list of groups or permissions for the specified user. - **404 Not Found**: If the user is not found within the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `org:staff` - `org:user` - `organization:read`

        :param user_id: (required)
        :type user_id: str
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._retrieve_user_authorizations_serialize(
            user_id=user_id,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _retrieve_user_authorizations_serialize(
        self,
        user_id,
        x_eaz_account_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if user_id is not None:
            _path_params["user_id"] = user_id
        # process the query parameters
        # process the header parameters
        if x_eaz_account_id is not None:
            _header_params["x-eaz-account-id"] = x_eaz_account_id
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = ["APIKeyHeader", "OAuth2"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/user-grants/{user_id}/authorizations/",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )

    @validate_call
    def update_user_authorizations(
        self,
        user_id: StrictStr,
        update_user_grants: UpdateUserGrants,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> object:
        """Update user authorizations

        Update User Authorizations.  This endpoint updates a user's authorizations by assigning a new role. It fetches the user from the authenticated client's organization and updates their project roles accordingly.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are updated.  ## Request Body: - **role** (required): A role to assign to the user. Must be one of: - `org:admin` - `org:staff` - `org:user`  ## Response: - **200 OK**: Returns the updated list of user roles. - **404 Not Found**: If the user is not found in the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `organization:write`

        :param user_id: (required)
        :type user_id: str
        :param update_user_grants: (required)
        :type update_user_grants: UpdateUserGrants
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._update_user_authorizations_serialize(
            user_id=user_id,
            update_user_grants=update_user_grants,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    def update_user_authorizations_with_http_info(
        self,
        user_id: StrictStr,
        update_user_grants: UpdateUserGrants,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[object]:
        """Update user authorizations

        Update User Authorizations.  This endpoint updates a user's authorizations by assigning a new role. It fetches the user from the authenticated client's organization and updates their project roles accordingly.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are updated.  ## Request Body: - **role** (required): A role to assign to the user. Must be one of: - `org:admin` - `org:staff` - `org:user`  ## Response: - **200 OK**: Returns the updated list of user roles. - **404 Not Found**: If the user is not found in the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `organization:write`

        :param user_id: (required)
        :type user_id: str
        :param update_user_grants: (required)
        :type update_user_grants: UpdateUserGrants
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._update_user_authorizations_serialize(
            user_id=user_id,
            update_user_grants=update_user_grants,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )

    @validate_call
    def update_user_authorizations_without_preload_content(
        self,
        user_id: StrictStr,
        update_user_grants: UpdateUserGrants,
        x_eaz_account_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Update user authorizations

        Update User Authorizations.  This endpoint updates a user's authorizations by assigning a new role. It fetches the user from the authenticated client's organization and updates their project roles accordingly.  ## Path Parameters: - **user_id** (required): The unique identifier of the user whose authorizations are updated.  ## Request Body: - **role** (required): A role to assign to the user. Must be one of: - `org:admin` - `org:staff` - `org:user`  ## Response: - **200 OK**: Returns the updated list of user roles. - **404 Not Found**: If the user is not found in the authenticated organization.  ## 🔒 Authentication  This endpoint require a valid OAuth2 Bearer  It supports account impersonation within Organization's sub-accounts using `X-Eaz-Account-Id` Header.  - If the `X-Eaz-Account-Id` header is provided and the user has access rights to that sub-account, the impersonation context is applied. - Otherwise, the user's own account context is used. ### Scopes :  User must provide one of the following scopes: - `admin` - `staff` - `user` - `org:admin` - `organization:write`

        :param user_id: (required)
        :type user_id: str
        :param update_user_grants: (required)
        :type update_user_grants: UpdateUserGrants
        :param x_eaz_account_id: The default is always the organization of the requesting user. If you like to get/set a result of another organization include the header. Make sure the user has permission to access the requested data.
        :type x_eaz_account_id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :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
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._update_user_authorizations_serialize(
            user_id=user_id,
            update_user_grants=update_user_grants,
            x_eaz_account_id=x_eaz_account_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "object",
            "422": "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _update_user_authorizations_serialize(
        self,
        user_id,
        update_user_grants,
        x_eaz_account_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if user_id is not None:
            _path_params["user_id"] = user_id
        # process the query parameters
        # process the header parameters
        if x_eaz_account_id is not None:
            _header_params["x-eaz-account-id"] = x_eaz_account_id
        # process the form parameters
        # process the body parameter
        if update_user_grants is not None:
            _body_params = update_user_grants

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params["Content-Type"] = _content_type
        else:
            _default_content_type = self.api_client.select_header_content_type(
                ["application/json"]
            )
            if _default_content_type is not None:
                _header_params["Content-Type"] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = ["APIKeyHeader", "OAuth2"]

        return self.api_client.param_serialize(
            method="PUT",
            resource_path="/user-grants/{user_id}/authorizations/",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )
