Skip to content

add list method #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want a KubernetesObject here, instead pass in apiGroup apiVersion & kind as well as a namespaced parameter.

We'll need to refactor the specUriPath code also.

pretty?: string,
exact?: boolean,
exportt?: boolean,
options: { headers: { [name: string]: string } } = { headers: {} },
): Promise<{ body: KubernetesListObject<KubernetesObject>; 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
Expand Down Expand Up @@ -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');
}
Expand Down