/* tslint:disable */
/* eslint-disable */
/**
 * AutoGlue API
 * API for managing K3s clusters across cloud providers
 *
 * The version of the OpenAPI document: dev
 *
 *
 * 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 {
  DtoAnnotationResponse,
  DtoAttachAnnotationsRequest,
  DtoAttachLabelsRequest,
  DtoAttachServersRequest,
  DtoAttachTaintsRequest,
  DtoCreateNodePoolRequest,
  DtoLabelResponse,
  DtoNodePoolResponse,
  DtoServerResponse,
  DtoTaintResponse,
  DtoUpdateNodePoolRequest,
} from "../models/index";
import {
  DtoAnnotationResponseFromJSON,
  DtoAnnotationResponseToJSON,
  DtoAttachAnnotationsRequestFromJSON,
  DtoAttachAnnotationsRequestToJSON,
  DtoAttachLabelsRequestFromJSON,
  DtoAttachLabelsRequestToJSON,
  DtoAttachServersRequestFromJSON,
  DtoAttachServersRequestToJSON,
  DtoAttachTaintsRequestFromJSON,
  DtoAttachTaintsRequestToJSON,
  DtoCreateNodePoolRequestFromJSON,
  DtoCreateNodePoolRequestToJSON,
  DtoLabelResponseFromJSON,
  DtoLabelResponseToJSON,
  DtoNodePoolResponseFromJSON,
  DtoNodePoolResponseToJSON,
  DtoServerResponseFromJSON,
  DtoServerResponseToJSON,
  DtoTaintResponseFromJSON,
  DtoTaintResponseToJSON,
  DtoUpdateNodePoolRequestFromJSON,
  DtoUpdateNodePoolRequestToJSON,
} from "../models/index";

export interface AttachNodePoolAnnotationsRequest {
  id: string;
  dtoAttachAnnotationsRequest: DtoAttachAnnotationsRequest;
  xOrgID?: string;
}

export interface AttachNodePoolLabelsRequest {
  id: string;
  dtoAttachLabelsRequest: DtoAttachLabelsRequest;
  xOrgID?: string;
}

export interface AttachNodePoolServersRequest {
  id: string;
  dtoAttachServersRequest: DtoAttachServersRequest;
  xOrgID?: string;
}

export interface AttachNodePoolTaintsRequest {
  id: string;
  dtoAttachTaintsRequest: DtoAttachTaintsRequest;
  xOrgID?: string;
}

export interface CreateNodePoolRequest {
  dtoCreateNodePoolRequest: DtoCreateNodePoolRequest;
  xOrgID?: string;
}

export interface DeleteNodePoolRequest {
  id: string;
  xOrgID?: string;
}

export interface DetachNodePoolAnnotationRequest {
  id: string;
  annotationId: string;
  xOrgID?: string;
}

export interface DetachNodePoolLabelRequest {
  id: string;
  labelId: string;
  xOrgID?: string;
}

export interface DetachNodePoolServerRequest {
  id: string;
  serverId: string;
  xOrgID?: string;
}

export interface DetachNodePoolTaintRequest {
  id: string;
  taintId: string;
  xOrgID?: string;
}

export interface GetNodePoolRequest {
  id: string;
  xOrgID?: string;
}

export interface ListNodePoolAnnotationsRequest {
  id: string;
  xOrgID?: string;
}

export interface ListNodePoolLabelsRequest {
  id: string;
  xOrgID?: string;
}

export interface ListNodePoolServersRequest {
  id: string;
  xOrgID?: string;
}

export interface ListNodePoolTaintsRequest {
  id: string;
  xOrgID?: string;
}

export interface ListNodePoolsRequest {
  xOrgID?: string;
  q?: string;
}

export interface UpdateNodePoolRequest {
  id: string;
  dtoUpdateNodePoolRequest: DtoUpdateNodePoolRequest;
  xOrgID?: string;
}

/**
 *
 */
export class NodePoolsApi extends runtime.BaseAPI {
  /**
   * Attach annotation to a node pool (org scoped)
   */
  async attachNodePoolAnnotationsRaw(
    requestParameters: AttachNodePoolAnnotationsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling attachNodePoolAnnotations().',
      );
    }

    if (requestParameters["dtoAttachAnnotationsRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoAttachAnnotationsRequest",
        'Required parameter "dtoAttachAnnotationsRequest" was null or undefined when calling attachNodePoolAnnotations().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/annotations`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: DtoAttachAnnotationsRequestToJSON(
          requestParameters["dtoAttachAnnotationsRequest"],
        ),
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Attach annotation to a node pool (org scoped)
   */
  async attachNodePoolAnnotations(
    requestParameters: AttachNodePoolAnnotationsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.attachNodePoolAnnotationsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Attach labels to a node pool (org scoped)
   */
  async attachNodePoolLabelsRaw(
    requestParameters: AttachNodePoolLabelsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling attachNodePoolLabels().',
      );
    }

    if (requestParameters["dtoAttachLabelsRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoAttachLabelsRequest",
        'Required parameter "dtoAttachLabelsRequest" was null or undefined when calling attachNodePoolLabels().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/labels`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: DtoAttachLabelsRequestToJSON(
          requestParameters["dtoAttachLabelsRequest"],
        ),
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Attach labels to a node pool (org scoped)
   */
  async attachNodePoolLabels(
    requestParameters: AttachNodePoolLabelsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.attachNodePoolLabelsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Attach servers to a node pool (org scoped)
   */
  async attachNodePoolServersRaw(
    requestParameters: AttachNodePoolServersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling attachNodePoolServers().',
      );
    }

    if (requestParameters["dtoAttachServersRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoAttachServersRequest",
        'Required parameter "dtoAttachServersRequest" was null or undefined when calling attachNodePoolServers().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/servers`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: DtoAttachServersRequestToJSON(
          requestParameters["dtoAttachServersRequest"],
        ),
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Attach servers to a node pool (org scoped)
   */
  async attachNodePoolServers(
    requestParameters: AttachNodePoolServersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.attachNodePoolServersRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Attach taints to a node pool (org scoped)
   */
  async attachNodePoolTaintsRaw(
    requestParameters: AttachNodePoolTaintsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling attachNodePoolTaints().',
      );
    }

    if (requestParameters["dtoAttachTaintsRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoAttachTaintsRequest",
        'Required parameter "dtoAttachTaintsRequest" was null or undefined when calling attachNodePoolTaints().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/taints`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: DtoAttachTaintsRequestToJSON(
          requestParameters["dtoAttachTaintsRequest"],
        ),
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Attach taints to a node pool (org scoped)
   */
  async attachNodePoolTaints(
    requestParameters: AttachNodePoolTaintsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.attachNodePoolTaintsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Creates a node pool. Optionally attach initial servers.
   * Create node pool (org scoped)
   */
  async createNodePoolRaw(
    requestParameters: CreateNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<DtoNodePoolResponse>> {
    if (requestParameters["dtoCreateNodePoolRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoCreateNodePoolRequest",
        'Required parameter "dtoCreateNodePoolRequest" was null or undefined when calling createNodePool().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools`;

    const response = await this.request(
      {
        path: urlPath,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: DtoCreateNodePoolRequestToJSON(
          requestParameters["dtoCreateNodePoolRequest"],
        ),
      },
      initOverrides,
    );

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

  /**
   * Creates a node pool. Optionally attach initial servers.
   * Create node pool (org scoped)
   */
  async createNodePool(
    requestParameters: CreateNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<DtoNodePoolResponse> {
    const response = await this.createNodePoolRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Permanently deletes the node pool.
   * Delete node pool (org scoped)
   */
  async deleteNodePoolRaw(
    requestParameters: DeleteNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling deleteNodePool().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    return new runtime.VoidApiResponse(response);
  }

  /**
   * Permanently deletes the node pool.
   * Delete node pool (org scoped)
   */
  async deleteNodePool(
    requestParameters: DeleteNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.deleteNodePoolRaw(requestParameters, initOverrides);
  }

  /**
   * Detach one annotation from a node pool (org scoped)
   */
  async detachNodePoolAnnotationRaw(
    requestParameters: DetachNodePoolAnnotationRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling detachNodePoolAnnotation().',
      );
    }

    if (requestParameters["annotationId"] == null) {
      throw new runtime.RequiredError(
        "annotationId",
        'Required parameter "annotationId" was null or undefined when calling detachNodePoolAnnotation().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/annotations/{annotationId}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );
    urlPath = urlPath.replace(
      `{${"annotationId"}}`,
      encodeURIComponent(String(requestParameters["annotationId"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Detach one annotation from a node pool (org scoped)
   */
  async detachNodePoolAnnotation(
    requestParameters: DetachNodePoolAnnotationRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.detachNodePoolAnnotationRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Detach one label from a node pool (org scoped)
   */
  async detachNodePoolLabelRaw(
    requestParameters: DetachNodePoolLabelRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling detachNodePoolLabel().',
      );
    }

    if (requestParameters["labelId"] == null) {
      throw new runtime.RequiredError(
        "labelId",
        'Required parameter "labelId" was null or undefined when calling detachNodePoolLabel().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/labels/{labelId}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );
    urlPath = urlPath.replace(
      `{${"labelId"}}`,
      encodeURIComponent(String(requestParameters["labelId"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Detach one label from a node pool (org scoped)
   */
  async detachNodePoolLabel(
    requestParameters: DetachNodePoolLabelRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.detachNodePoolLabelRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Detach one server from a node pool (org scoped)
   */
  async detachNodePoolServerRaw(
    requestParameters: DetachNodePoolServerRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling detachNodePoolServer().',
      );
    }

    if (requestParameters["serverId"] == null) {
      throw new runtime.RequiredError(
        "serverId",
        'Required parameter "serverId" was null or undefined when calling detachNodePoolServer().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/servers/{serverId}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );
    urlPath = urlPath.replace(
      `{${"serverId"}}`,
      encodeURIComponent(String(requestParameters["serverId"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Detach one server from a node pool (org scoped)
   */
  async detachNodePoolServer(
    requestParameters: DetachNodePoolServerRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.detachNodePoolServerRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Detach one taint from a node pool (org scoped)
   */
  async detachNodePoolTaintRaw(
    requestParameters: DetachNodePoolTaintRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling detachNodePoolTaint().',
      );
    }

    if (requestParameters["taintId"] == null) {
      throw new runtime.RequiredError(
        "taintId",
        'Required parameter "taintId" was null or undefined when calling detachNodePoolTaint().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/taints/{taintId}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );
    urlPath = urlPath.replace(
      `{${"taintId"}}`,
      encodeURIComponent(String(requestParameters["taintId"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Detach one taint from a node pool (org scoped)
   */
  async detachNodePoolTaint(
    requestParameters: DetachNodePoolTaintRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.detachNodePoolTaintRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Returns one node pool. Add `include=servers` to include servers.
   * Get node pool by ID (org scoped)
   */
  async getNodePoolRaw(
    requestParameters: GetNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<DtoNodePoolResponse>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling getNodePool().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * Returns one node pool. Add `include=servers` to include servers.
   * Get node pool by ID (org scoped)
   */
  async getNodePool(
    requestParameters: GetNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<DtoNodePoolResponse> {
    const response = await this.getNodePoolRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * List annotations attached to a node pool (org scoped)
   */
  async listNodePoolAnnotationsRaw(
    requestParameters: ListNodePoolAnnotationsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<DtoAnnotationResponse>>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling listNodePoolAnnotations().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/annotations`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * List annotations attached to a node pool (org scoped)
   */
  async listNodePoolAnnotations(
    requestParameters: ListNodePoolAnnotationsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<DtoAnnotationResponse>> {
    const response = await this.listNodePoolAnnotationsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * List labels attached to a node pool (org scoped)
   */
  async listNodePoolLabelsRaw(
    requestParameters: ListNodePoolLabelsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<DtoLabelResponse>>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling listNodePoolLabels().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/labels`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * List labels attached to a node pool (org scoped)
   */
  async listNodePoolLabels(
    requestParameters: ListNodePoolLabelsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<DtoLabelResponse>> {
    const response = await this.listNodePoolLabelsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * List servers attached to a node pool (org scoped)
   */
  async listNodePoolServersRaw(
    requestParameters: ListNodePoolServersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<DtoServerResponse>>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling listNodePoolServers().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/servers`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * List servers attached to a node pool (org scoped)
   */
  async listNodePoolServers(
    requestParameters: ListNodePoolServersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<DtoServerResponse>> {
    const response = await this.listNodePoolServersRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * List taints attached to a node pool (org scoped)
   */
  async listNodePoolTaintsRaw(
    requestParameters: ListNodePoolTaintsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<DtoTaintResponse>>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling listNodePoolTaints().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}/taints`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * List taints attached to a node pool (org scoped)
   */
  async listNodePoolTaints(
    requestParameters: ListNodePoolTaintsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<DtoTaintResponse>> {
    const response = await this.listNodePoolTaintsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Returns node pools for the organization in X-Org-ID.
   * List node pools (org scoped)
   */
  async listNodePoolsRaw(
    requestParameters: ListNodePoolsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<DtoNodePoolResponse>>> {
    const queryParameters: any = {};

    if (requestParameters["q"] != null) {
      queryParameters["q"] = requestParameters["q"];
    }

    const headerParameters: runtime.HTTPHeaders = {};

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools`;

    const response = await this.request(
      {
        path: urlPath,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * Returns node pools for the organization in X-Org-ID.
   * List node pools (org scoped)
   */
  async listNodePools(
    requestParameters: ListNodePoolsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<DtoNodePoolResponse>> {
    const response = await this.listNodePoolsRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Partially update node pool fields.
   * Update node pool (org scoped)
   */
  async updateNodePoolRaw(
    requestParameters: UpdateNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<DtoNodePoolResponse>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling updateNodePool().',
      );
    }

    if (requestParameters["dtoUpdateNodePoolRequest"] == null) {
      throw new runtime.RequiredError(
        "dtoUpdateNodePoolRequest",
        'Required parameter "dtoUpdateNodePoolRequest" was null or undefined when calling updateNodePool().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    if (requestParameters["xOrgID"] != null) {
      headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-KEY"] =
        await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["X-ORG-SECRET"] =
        await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
    }

    if (this.configuration && this.configuration.apiKey) {
      headerParameters["Authorization"] =
        await this.configuration.apiKey("Authorization"); // BearerAuth authentication
    }

    let urlPath = `/node-pools/{id}`;
    urlPath = urlPath.replace(
      `{${"id"}}`,
      encodeURIComponent(String(requestParameters["id"])),
    );

    const response = await this.request(
      {
        path: urlPath,
        method: "PATCH",
        headers: headerParameters,
        query: queryParameters,
        body: DtoUpdateNodePoolRequestToJSON(
          requestParameters["dtoUpdateNodePoolRequest"],
        ),
      },
      initOverrides,
    );

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

  /**
   * Partially update node pool fields.
   * Update node pool (org scoped)
   */
  async updateNodePool(
    requestParameters: UpdateNodePoolRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<DtoNodePoolResponse> {
    const response = await this.updateNodePoolRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }
}
