/* tslint:disable */
/* eslint-disable */
/**
 * AssistedInstall
 * Assisted installation
 *
 * The version of the OpenAPI document: 1.0.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import {
  DUMMY_BASE_URL,
  assertParamExists,
  setApiKeyToObject,
  setBasicAuthToObject,
  setBearerAuthToObject,
  setOAuthToObject,
  setSearchParams,
  serializeDataIfNeeded,
  toPathString,
  createRequestFunction,
} from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { EventList } from '../models';
// @ts-ignore
import { InfraError } from '../models';
// @ts-ignore
import { ModelError } from '../models';
/**
 * EventsApi - axios parameter creator
 * @export
 */
export const EventsApiAxiosParamCreator = function (configuration?: Configuration) {
  return {
    /**
     * Lists events for a cluster.
     * @param {string} [clusterId] The cluster to return events for.
     * @param {string} [hostId] A host in the specified cluster to return events for (DEPRECATED. Use &#x60;host_ids&#x60; instead).
     * @param {Array<string>} [hostIds] Hosts in the specified cluster to return events for.
     * @param {string} [infraEnvId] The infra-env to return events for.
     * @param {number} [limit] The maximum number of records to retrieve.
     * @param {number} [offset] Number of records to skip before starting to return the records.
     * @param {V2ListEventsOrderEnum} [order] Order by event_time of events retrieved.
     * @param {Array<V2ListEventsSeveritiesEnum>} [severities] Retrieved events severities.
     * @param {string} [message] Retrieved events message pattern.
     * @param {boolean} [deletedHosts] Deleted hosts flag.
     * @param {boolean} [clusterLevel] Cluster level events flag.
     * @param {Array<string>} [categories] A comma-separated list of event categories.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListEvents: async (
      clusterId?: string,
      hostId?: string,
      hostIds?: Array<string>,
      infraEnvId?: string,
      limit?: number,
      offset?: number,
      order?: V2ListEventsOrderEnum,
      severities?: Array<V2ListEventsSeveritiesEnum>,
      message?: string,
      deletedHosts?: boolean,
      clusterLevel?: boolean,
      categories?: Array<string>,
      options: AxiosRequestConfig = {},
    ): Promise<RequestArgs> => {
      const localVarPath = `/v2/events`;
      // use dummy base URL string because the URL constructor only accepts absolute URLs.
      const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
      let baseOptions;
      if (configuration) {
        baseOptions = configuration.baseOptions;
      }

      const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
      const localVarHeaderParameter = {} as any;
      const localVarQueryParameter = {} as any;

      // authentication urlAuth required
      await setApiKeyToObject(localVarQueryParameter, 'api_key', configuration);

      // authentication userAuth required
      await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);

      if (clusterId !== undefined) {
        localVarQueryParameter['cluster_id'] = clusterId;
      }

      if (hostId !== undefined) {
        localVarQueryParameter['host_id'] = hostId;
      }

      if (hostIds) {
        localVarQueryParameter['host_ids'] = hostIds.join(COLLECTION_FORMATS.csv);
      }

      if (infraEnvId !== undefined) {
        localVarQueryParameter['infra_env_id'] = infraEnvId;
      }

      if (limit !== undefined) {
        localVarQueryParameter['limit'] = limit;
      }

      if (offset !== undefined) {
        localVarQueryParameter['offset'] = offset;
      }

      if (order !== undefined) {
        localVarQueryParameter['order'] = order;
      }

      if (severities) {
        localVarQueryParameter['severities'] = severities.join(COLLECTION_FORMATS.csv);
      }

      if (message !== undefined) {
        localVarQueryParameter['message'] = message;
      }

      if (deletedHosts !== undefined) {
        localVarQueryParameter['deleted_hosts'] = deletedHosts;
      }

      if (clusterLevel !== undefined) {
        localVarQueryParameter['cluster_level'] = clusterLevel;
      }

      if (categories) {
        localVarQueryParameter['categories'] = categories.join(COLLECTION_FORMATS.csv);
      }

      setSearchParams(localVarUrlObj, localVarQueryParameter);
      let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
      localVarRequestOptions.headers = {
        ...localVarHeaderParameter,
        ...headersFromBaseOptions,
        ...options.headers,
      };

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
  };
};

/**
 * EventsApi - functional programming interface
 * @export
 */
export const EventsApiFp = function (configuration?: Configuration) {
  const localVarAxiosParamCreator = EventsApiAxiosParamCreator(configuration);
  return {
    /**
     * Lists events for a cluster.
     * @param {string} [clusterId] The cluster to return events for.
     * @param {string} [hostId] A host in the specified cluster to return events for (DEPRECATED. Use &#x60;host_ids&#x60; instead).
     * @param {Array<string>} [hostIds] Hosts in the specified cluster to return events for.
     * @param {string} [infraEnvId] The infra-env to return events for.
     * @param {number} [limit] The maximum number of records to retrieve.
     * @param {number} [offset] Number of records to skip before starting to return the records.
     * @param {V2ListEventsOrderEnum} [order] Order by event_time of events retrieved.
     * @param {Array<V2ListEventsSeveritiesEnum>} [severities] Retrieved events severities.
     * @param {string} [message] Retrieved events message pattern.
     * @param {boolean} [deletedHosts] Deleted hosts flag.
     * @param {boolean} [clusterLevel] Cluster level events flag.
     * @param {Array<string>} [categories] A comma-separated list of event categories.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async v2ListEvents(
      clusterId?: string,
      hostId?: string,
      hostIds?: Array<string>,
      infraEnvId?: string,
      limit?: number,
      offset?: number,
      order?: V2ListEventsOrderEnum,
      severities?: Array<V2ListEventsSeveritiesEnum>,
      message?: string,
      deletedHosts?: boolean,
      clusterLevel?: boolean,
      categories?: Array<string>,
      options?: AxiosRequestConfig,
    ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EventList>> {
      const localVarAxiosArgs = await localVarAxiosParamCreator.v2ListEvents(
        clusterId,
        hostId,
        hostIds,
        infraEnvId,
        limit,
        offset,
        order,
        severities,
        message,
        deletedHosts,
        clusterLevel,
        categories,
        options,
      );
      return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
    },
  };
};

/**
 * EventsApi - factory interface
 * @export
 */
export const EventsApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance,
) {
  const localVarFp = EventsApiFp(configuration);
  return {
    /**
     * Lists events for a cluster.
     * @param {EventsApiV2ListEventsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListEvents(
      requestParameters: EventsApiV2ListEventsRequest = {},
      options?: AxiosRequestConfig,
    ): AxiosPromise<EventList> {
      return localVarFp
        .v2ListEvents(
          requestParameters.clusterId,
          requestParameters.hostId,
          requestParameters.hostIds,
          requestParameters.infraEnvId,
          requestParameters.limit,
          requestParameters.offset,
          requestParameters.order,
          requestParameters.severities,
          requestParameters.message,
          requestParameters.deletedHosts,
          requestParameters.clusterLevel,
          requestParameters.categories,
          options,
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for v2ListEvents operation in EventsApi.
 * @export
 * @interface EventsApiV2ListEventsRequest
 */
export interface EventsApiV2ListEventsRequest {
  /**
   * The cluster to return events for.
   * @type {string}
   * @memberof EventsApiV2ListEvents
   */
  readonly clusterId?: string;

  /**
   * A host in the specified cluster to return events for (DEPRECATED. Use &#x60;host_ids&#x60; instead).
   * @type {string}
   * @memberof EventsApiV2ListEvents
   */
  readonly hostId?: string;

  /**
   * Hosts in the specified cluster to return events for.
   * @type {Array<string>}
   * @memberof EventsApiV2ListEvents
   */
  readonly hostIds?: Array<string>;

  /**
   * The infra-env to return events for.
   * @type {string}
   * @memberof EventsApiV2ListEvents
   */
  readonly infraEnvId?: string;

  /**
   * The maximum number of records to retrieve.
   * @type {number}
   * @memberof EventsApiV2ListEvents
   */
  readonly limit?: number;

  /**
   * Number of records to skip before starting to return the records.
   * @type {number}
   * @memberof EventsApiV2ListEvents
   */
  readonly offset?: number;

  /**
   * Order by event_time of events retrieved.
   * @type {'ascending' | 'descending'}
   * @memberof EventsApiV2ListEvents
   */
  readonly order?: V2ListEventsOrderEnum;

  /**
   * Retrieved events severities.
   * @type {Array<'info' | 'warning' | 'error' | 'critical'>}
   * @memberof EventsApiV2ListEvents
   */
  readonly severities?: Array<V2ListEventsSeveritiesEnum>;

  /**
   * Retrieved events message pattern.
   * @type {string}
   * @memberof EventsApiV2ListEvents
   */
  readonly message?: string;

  /**
   * Deleted hosts flag.
   * @type {boolean}
   * @memberof EventsApiV2ListEvents
   */
  readonly deletedHosts?: boolean;

  /**
   * Cluster level events flag.
   * @type {boolean}
   * @memberof EventsApiV2ListEvents
   */
  readonly clusterLevel?: boolean;

  /**
   * A comma-separated list of event categories.
   * @type {Array<string>}
   * @memberof EventsApiV2ListEvents
   */
  readonly categories?: Array<string>;
}

/**
 * EventsApi - object-oriented interface
 * @export
 * @class EventsApi
 * @extends {BaseAPI}
 */
export class EventsApi extends BaseAPI {
  /**
   * Lists events for a cluster.
   * @param {EventsApiV2ListEventsRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof EventsApi
   */
  public v2ListEvents(
    requestParameters: EventsApiV2ListEventsRequest = {},
    options?: AxiosRequestConfig,
  ) {
    return EventsApiFp(this.configuration)
      .v2ListEvents(
        requestParameters.clusterId,
        requestParameters.hostId,
        requestParameters.hostIds,
        requestParameters.infraEnvId,
        requestParameters.limit,
        requestParameters.offset,
        requestParameters.order,
        requestParameters.severities,
        requestParameters.message,
        requestParameters.deletedHosts,
        requestParameters.clusterLevel,
        requestParameters.categories,
        options,
      )
      .then((request) => request(this.axios, this.basePath));
  }
}

/**
 * @export
 * @enum {string}
 */
export enum V2ListEventsOrderEnum {
  Ascending = 'ascending',
  Descending = 'descending',
}
/**
 * @export
 * @enum {string}
 */
export enum V2ListEventsSeveritiesEnum {
  Info = 'info',
  Warning = 'warning',
  Error = 'error',
  Critical = 'critical',
}
