/* tslint:disable */
/* eslint-disable */
/**
 * Hexiosec Transfer API
 * API description for Hexiosec Transfer  ## Testing Requests  Endpoints that require authentication will use your session cookie from the main application if an API key is not provided. This is fine for testing GET requests, however POST/DELETE requests will require a CSRF token when using a session cookie. It is not possible to provide a CSRF token from this page, and so an API key must be used.
 *
 * The version of the OpenAPI document: 0.0.1
 * Contact: support@hexiosec.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
import * as runtime from '../runtime.js';
import { AdminGroupsUpdateRequestToJSON, CreateGroupRequestToJSON, GroupResponseFromJSON, } from '../models/index.js';
/**
 *
 */
export class AdminGroupsApi extends runtime.BaseAPI {
    /**
     * Add role to group
     */
    async addRoleToGroupRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling addRoleToGroup().');
        }
        if (requestParameters['role'] == null) {
            throw new runtime.RequiredError('role', 'Required parameter "role" was null or undefined when calling addRoleToGroup().');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups/{id}/roles/{role}`
                .replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))
                .replace(`{${'role'}}`, encodeURIComponent(String(requestParameters['role']))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Add role to group
     */
    async addRoleToGroup(requestParameters, initOverrides) {
        await this.addRoleToGroupRaw(requestParameters, initOverrides);
    }
    /**
     * Create new group
     */
    async createGroupRaw(requestParameters, initOverrides) {
        if (requestParameters['createGroupRequest'] == null) {
            throw new runtime.RequiredError('createGroupRequest', 'Required parameter "createGroupRequest" was null or undefined when calling createGroup().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: CreateGroupRequestToJSON(requestParameters['createGroupRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => GroupResponseFromJSON(jsonValue));
    }
    /**
     * Create new group
     */
    async createGroup(requestParameters, initOverrides) {
        const response = await this.createGroupRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Get group
     */
    async getGroupByIDRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling getGroupByID().');
        }
        const queryParameters = {};
        if (requestParameters['expand'] != null) {
            queryParameters['expand'] = requestParameters['expand'];
        }
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => GroupResponseFromJSON(jsonValue));
    }
    /**
     * Get group
     */
    async getGroupByID(requestParameters, initOverrides) {
        const response = await this.getGroupByIDRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Get all groups
     */
    async getGroupsRaw(requestParameters, initOverrides) {
        const queryParameters = {};
        if (requestParameters['tenantId'] != null) {
            queryParameters['tenant_id'] = requestParameters['tenantId'];
        }
        if (requestParameters['expand'] != null) {
            queryParameters['expand'] = requestParameters['expand'];
        }
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupResponseFromJSON));
    }
    /**
     * Get all groups
     */
    async getGroups(requestParameters = {}, initOverrides) {
        const response = await this.getGroupsRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Remove role from group
     */
    async removeRoleFromGroupRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling removeRoleFromGroup().');
        }
        if (requestParameters['role'] == null) {
            throw new runtime.RequiredError('role', 'Required parameter "role" was null or undefined when calling removeRoleFromGroup().');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups/{id}/roles/{role}`
                .replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))
                .replace(`{${'role'}}`, encodeURIComponent(String(requestParameters['role']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Remove role from group
     */
    async removeRoleFromGroup(requestParameters, initOverrides) {
        await this.removeRoleFromGroupRaw(requestParameters, initOverrides);
    }
    /**
     * Update group
     */
    async updateGroupByIDRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling updateGroupByID().');
        }
        if (requestParameters['adminGroupsUpdateRequest'] == null) {
            throw new runtime.RequiredError('adminGroupsUpdateRequest', 'Required parameter "adminGroupsUpdateRequest" was null or undefined when calling updateGroupByID().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/admin/groups/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: AdminGroupsUpdateRequestToJSON(requestParameters['adminGroupsUpdateRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => GroupResponseFromJSON(jsonValue));
    }
    /**
     * Update group
     */
    async updateGroupByID(requestParameters, initOverrides) {
        const response = await this.updateGroupByIDRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
/**
 * @export
 */
export const GetGroupByIDExpandEnum = {
    Roles: 'roles',
};
/**
 * @export
 */
export const GetGroupsExpandEnum = {
    EnabledUsersCount: 'enabled_users_count',
};
