/* tslint:disable */
/* eslint-disable */
/**
 * UCX Proxy
 * A single use API for the UCX Proxy.
 *
 * The version of the OpenAPI document: 0.0.12
 * Contact: customersuccess@equisoft.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';
import type {
  ConfiguredSourceSchema,
  ErrorSchema,
} from '../models/index';
import {
    ConfiguredSourceSchemaFromJSON,
    ConfiguredSourceSchemaToJSON,
    ErrorSchemaFromJSON,
    ErrorSchemaToJSON,
} from '../models/index';

export interface ListConfiguredSourcesRequest {
    organizationId?: string | null;
    includeInactive?: boolean | null;
}

/**
 * 
 */
export class ConfiguredSourceApi extends runtime.BaseAPI {

    /**
     * Creates request options for listConfiguredSources without sending the request
     */
    async listConfiguredSourcesRequestOpts(requestParameters: ListConfiguredSourcesRequest): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters['organizationId'] != null) {
            queryParameters['organizationId'] = requestParameters['organizationId'];
        }

        if (requestParameters['includeInactive'] != null) {
            queryParameters['includeInactive'] = requestParameters['includeInactive'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            const token = this.configuration.accessToken;
            const tokenString = await token("default", ["ucx:read"]);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }


        let urlPath = `/sources`;

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get all active (and inactive) sources for the current user / organization
     */
    async listConfiguredSourcesRaw(requestParameters: ListConfiguredSourcesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ConfiguredSourceSchema>>> {
        const requestOptions = await this.listConfiguredSourcesRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ConfiguredSourceSchemaFromJSON));
    }

    /**
     * Get all active (and inactive) sources for the current user / organization
     */
    async listConfiguredSources(requestParameters: ListConfiguredSourcesRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ConfiguredSourceSchema>> {
        const response = await this.listConfiguredSourcesRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
