# coding: utf-8

"""
Alteryx Server API V3

No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501

OpenAPI spec version: 3

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 src.server_client.api_client import ApiClient


class UserGroupsApi(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 user_groups_add_active_directory_group_to_custom_group(self, user_group_id, sid, **kwargs):  # noqa: E501
        """Add an Active Directory group to an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  This endpoint can only be used for Windows Authentication configured
          Server instances.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_add_active_directory_group_to_custom_group(user_group_id, sid, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str sid: The identifier of the Active Directory group. This is a JSON body payload. You must submit the
          value wrapped in quotation marks such as: \"S-My-SID\". (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_add_active_directory_group_to_custom_group_with_http_info(
                user_group_id, sid, **kwargs
            )  # noqa: E501
        else:
            (data) = self.user_groups_add_active_directory_group_to_custom_group_with_http_info(
                user_group_id, sid, **kwargs
            )  # noqa: E501
            return data

    def user_groups_add_active_directory_group_to_custom_group_with_http_info(self, user_group_id, sid, **kwargs):  # noqa: E501
        """Add an Active Directory group to an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  This endpoint can only be used for Windows Authentication configured
          Server instances.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_add_active_directory_group_to_custom_group_with_http_info(user_group_id, sid,
          async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str sid: The identifier of the Active Directory group. This is a JSON body payload. You must submit the
          value wrapped in quotation marks such as: \"S-My-SID\". (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "sid"]  # 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 user_groups_add_active_directory_group_to_custom_group" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling "
                "`user_groups_add_active_directory_group_to_custom_group`"
            )  # noqa: E501
        # verify the required parameter 'sid' is set
        if self.api_client.client_side_validation and ("sid" not in params or params["sid"] is None):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `sid` when calling "
                "`user_groups_add_active_directory_group_to_custom_group`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "sid" in params:
            body_params = params["sid"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(  # noqa: E501
            ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}/activedirectorygroups",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 user_groups_add_users_to_group(self, user_group_id, user_ids, **kwargs):  # noqa: E501
        """Add one or more existing users to an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_add_users_to_group(user_group_id, user_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param list[str] user_ids: List of user ids to add to the group, separated by commas. (required)
        :return: UserGroupAddedUsersView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_add_users_to_group_with_http_info(user_group_id, user_ids, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_add_users_to_group_with_http_info(user_group_id, user_ids, **kwargs)  # noqa: E501
            return data

    def user_groups_add_users_to_group_with_http_info(self, user_group_id, user_ids, **kwargs):  # noqa: E501
        """Add one or more existing users to an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_add_users_to_group_with_http_info(user_group_id, user_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param list[str] user_ids: List of user ids to add to the group, separated by commas. (required)
        :return: UserGroupAddedUsersView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "user_ids"]  # 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 user_groups_add_users_to_group" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling `user_groups_add_users_to_group`"
            )  # noqa: E501
        # verify the required parameter 'user_ids' is set
        if self.api_client.client_side_validation and ("user_ids" not in params or params["user_ids"] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `user_ids` when calling `user_groups_add_users_to_group`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "user_ids" in params:
            body_params = params["user_ids"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(  # noqa: E501
            ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}/users",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="UserGroupAddedUsersView",  # 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 user_groups_create_user_group(self, contract, **kwargs):  # noqa: E501
        """Create a new user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_create_user_group(contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateUserGroupContract contract:  (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_create_user_group_with_http_info(contract, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_create_user_group_with_http_info(contract, **kwargs)  # noqa: E501
            return data

    def user_groups_create_user_group_with_http_info(self, contract, **kwargs):  # noqa: E501
        """Create a new user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_create_user_group_with_http_info(contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateUserGroupContract contract:  (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["contract"]  # 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 user_groups_create_user_group" % key)
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'contract' is set
        if self.api_client.client_side_validation and ("contract" not in params or params["contract"] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `contract` when calling `user_groups_create_user_group`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "contract" in params:
            body_params = params["contract"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(  # noqa: E501
            ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="str",  # 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 user_groups_delete_user_group(self, user_group_id, **kwargs):  # noqa: E501
        """Delete an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  Will return a 400 Bad Request if the user group is not empty 
        and the forceDelete query param is false.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_delete_user_group(user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param bool force_delete: Delete the user group even if the group is not empty
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_delete_user_group_with_http_info(user_group_id, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_delete_user_group_with_http_info(user_group_id, **kwargs)  # noqa: E501
            return data

    def user_groups_delete_user_group_with_http_info(self, user_group_id, **kwargs):  # noqa: E501
        """Delete an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  Will return a 400 Bad Request if the user group is not empty 
        and the forceDelete query param is false.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_delete_user_group_with_http_info(user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param bool force_delete: Delete the user group even if the group is not empty
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "force_delete"]  # 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 user_groups_delete_user_group" % key)
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling `user_groups_delete_user_group`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501

        query_params = []
        if "force_delete" in params:
            query_params.append(("forceDelete", params["force_delete"]))  # 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", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 user_groups_get_user_group(self, user_group_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing user group.  # noqa: E501

        Only Curators can use this API endpoint. Only works for Server user groups.   
        Active Directory groups cannot be retrieved from this endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_get_user_group(user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :return: UserGroupView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_get_user_group_with_http_info(user_group_id, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_get_user_group_with_http_info(user_group_id, **kwargs)  # noqa: E501
            return data

    def user_groups_get_user_group_with_http_info(self, user_group_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing user group.  # noqa: E501

        Only Curators can use this API endpoint. Only works for Server user groups.
              Active Directory groups cannot be retrieved from this endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_get_user_group_with_http_info(user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :return: UserGroupView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_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 user_groups_get_user_group" % key)
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError("Missing the required parameter `user_group_id` when calling `user_groups_get_user_group`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_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", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="UserGroupView",  # 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 user_groups_get_user_groups(self, **kwargs):  # noqa: E501
        """Retrieve all accessible user group records.  # noqa: E501

        Only Curators can use this API endpoint.  Only Custom User Groups will be retrieved. 
        No Active Directory Groups will be returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_get_user_groups(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: list[ReducedUserGroupView]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_get_user_groups_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_get_user_groups_with_http_info(**kwargs)  # noqa: E501
            return data

    def user_groups_get_user_groups_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve all accessible user group records.  # noqa: E501

        Only Curators can use this API endpoint.  Only Custom User Groups will be retrieved.
          No Active Directory Groups will be returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_get_user_groups_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: list[ReducedUserGroupView]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # 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 user_groups_get_user_groups" % key)
            params[key] = val
        del params["kwargs"]

        collection_formats = {}

        path_params = {}

        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", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="list[ReducedUserGroupView]",  # 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 user_groups_remove_active_directory_group_from_custom_group(self, user_group_id, ad_group_sid, **kwargs):  # noqa: E501
        """Remove an Active Directory group from an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  This endpoint can only be used for Windows Authentication 
        configured Server instances.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_remove_active_directory_group_from_custom_group(user_group_id,
          ad_group_sid, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str ad_group_sid: Security identifer for an existing Microsoft Active Directory group. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_remove_active_directory_group_from_custom_group_with_http_info(
                user_group_id, ad_group_sid, **kwargs
            )  # noqa: E501
        else:
            (data) = self.user_groups_remove_active_directory_group_from_custom_group_with_http_info(
                user_group_id, ad_group_sid, **kwargs
            )  # noqa: E501
            return data

    def user_groups_remove_active_directory_group_from_custom_group_with_http_info(
        self, user_group_id, ad_group_sid, **kwargs
    ):  # noqa: E501
        """Remove an Active Directory group from an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  This endpoint can only be used for Windows Authentication configured
          Server instances.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_remove_active_directory_group_from_custom_group_with_http_info(user_group_id,
          ad_group_sid, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str ad_group_sid: Security identifer for an existing Microsoft Active Directory group. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "ad_group_sid"]  # 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 user_groups_remove_active_directory_group_from_custom_group" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling "
                "`user_groups_remove_active_directory_group_from_custom_group`"
            )  # noqa: E501
        # verify the required parameter 'ad_group_sid' is set
        if self.api_client.client_side_validation and ("ad_group_sid" not in params or params["ad_group_sid"] is None):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `ad_group_sid` when calling "
                "`user_groups_remove_active_directory_group_from_custom_group`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501
        if "ad_group_sid" in params:
            path_params["adGroupSid"] = params["ad_group_sid"]  # 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", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}/activedirectorygroups/{adGroupSid}",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 user_groups_remove_user_from_group(self, user_group_id, user_id, **kwargs):  # noqa: E501
        """Remove a user from an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  If the user is not a part of the user group, 
        then an OK response will be returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_remove_user_from_group(user_group_id, user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str user_id: Identifier for an existing user. (required)
        :return: UserGroupView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_remove_user_from_group_with_http_info(user_group_id, user_id, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_remove_user_from_group_with_http_info(user_group_id, user_id, **kwargs)  # noqa: E501
            return data

    def user_groups_remove_user_from_group_with_http_info(self, user_group_id, user_id, **kwargs):  # noqa: E501
        """Remove a user from an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  If the user is not a part of the user group, 
        then an OK response will be returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_remove_user_from_group_with_http_info(user_group_id, user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param str user_id: Identifier for an existing user. (required)
        :return: UserGroupView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "user_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 user_groups_remove_user_from_group" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling "
                "`user_groups_remove_user_from_group`"
            )  # noqa: E501
        # verify the required parameter 'user_id' is set
        if self.api_client.client_side_validation and ("user_id" not in params or params["user_id"] is None):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_id` when calling "
                "`user_groups_remove_user_from_group`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501
        if "user_id" in params:
            path_params["userId"] = params["user_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", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}/users/{userId}",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="UserGroupView",  # 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 user_groups_update_user_group(self, user_group_id, contract, **kwargs):  # noqa: E501
        """Update name and/or role of an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_update_user_group(user_group_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param UpdateUserGroupContract contract:  (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.user_groups_update_user_group_with_http_info(user_group_id, contract, **kwargs)  # noqa: E501
        else:
            (data) = self.user_groups_update_user_group_with_http_info(user_group_id, contract, **kwargs)  # noqa: E501
            return data

    def user_groups_update_user_group_with_http_info(self, user_group_id, contract, **kwargs):  # noqa: E501
        """Update name and/or role of an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_groups_update_user_group_with_http_info(user_group_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_group_id: Identifier for an existing user group. (required)
        :param UpdateUserGroupContract contract:  (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["user_group_id", "contract"]  # 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 user_groups_update_user_group" % key)
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'user_group_id' is set
        if self.api_client.client_side_validation and (
            "user_group_id" not in params or params["user_group_id"] is None
        ):  # noqa: E501
            raise ValueError(
                "Missing the required parameter `user_group_id` when calling `user_groups_update_user_group`"
            )  # noqa: E501
        # verify the required parameter 'contract' is set
        if self.api_client.client_side_validation and ("contract" not in params or params["contract"] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `contract` when calling `user_groups_update_user_group`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "user_group_id" in params:
            path_params["userGroupId"] = params["user_group_id"]  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "contract" in params:
            body_params = params["contract"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "application/xml", "text/xml"]
        )  # noqa: E501

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(  # noqa: E501
            ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"]
        )  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        return self.api_client.call_api(
            "/v3/usergroups/{userGroupId}",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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,
        )
