diff --git a/src/object.ts b/src/object.ts index 64ffb7493a2..86ef8a30eab 100644 --- a/src/object.ts +++ b/src/object.ts @@ -20,7 +20,7 @@ type KubernetesObjectResponseBody = | V1APIResourceList; /** Kubernetes API verbs. */ -type KubernetesApiAction = 'create' | 'delete' | 'patch' | 'read' | 'replace'; +type KubernetesApiAction = 'create' | 'delete' | 'patch' | 'read' | 'replace' | 'list'; /** * Valid Content-Type header values for patch operations. See @@ -315,6 +315,57 @@ export class KubernetesObjectApi extends ApisApi { return this.requestPromise(localVarRequestOptions); } + /** + * List any Kubernetes resources. + * @param spec Kubernetes resource spec + * @param pretty If \'true\', then the output is pretty printed. + * @param exact Should the export be exact. Exact export maintains cluster-specific fields like + * \'Namespace\'. Deprecated. Planned for removal in 1.18. + * @param exportt Should this value be exported. Export strips fields that a user can not + * specify. Deprecated. Planned for removal in 1.18. + * @param options Optional headers to use in the request. + * @return Promise containing the request response and list of [[KubernetesObject]]. + */ + public async list( + spec: KubernetesObject, + pretty?: string, + exact?: boolean, + exportt?: boolean, + options: { headers: { [name: string]: string } } = { headers: {} }, + ): Promise<{ body: KubernetesListObject; response: http.IncomingMessage }> { + // verify required parameter 'spec' is not null or undefined + if (spec === null || spec === undefined) { + throw new Error('Required parameter spec was null or undefined when calling list.'); + } + + const localVarPath = await this.specUriPath(spec, 'list'); + const localVarQueryParameters: any = {}; + const localVarHeaderParams = this.generateHeaders(options.headers); + + if (pretty !== undefined) { + localVarQueryParameters.pretty = ObjectSerializer.serialize(pretty, 'string'); + } + + if (exact !== undefined) { + localVarQueryParameters.exact = ObjectSerializer.serialize(exact, 'boolean'); + } + + if (exportt !== undefined) { + localVarQueryParameters.export = ObjectSerializer.serialize(exportt, 'boolean'); + } + + const localVarRequestOptions: request.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + return this.requestPromise(localVarRequestOptions); + } + /** * Replace any Kubernetes resource. * @param spec Kubernetes resource spec @@ -411,7 +462,7 @@ export class KubernetesObjectApi extends ApisApi { parts.push('namespaces', encodeURIComponent(String(spec.metadata.namespace))); } parts.push(resource.name); - if (action !== 'create') { + if (action !== 'create' && action !== 'list') { if (!spec.metadata.name) { throw new Error('Required spec property name is not set'); }