|
| 1 | +// This file was automatically generated. DO NOT EDIT. |
| 2 | +// If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | +import { |
| 4 | + API as ParentAPI, |
| 5 | + enrichForPagination, |
| 6 | + urlParams, |
| 7 | + validatePathParam, |
| 8 | +} from '../../../bridge' |
| 9 | +import { |
| 10 | + marshalProjectApiCreateProjectRequest, |
| 11 | + marshalProjectApiUpdateProjectRequest, |
| 12 | + unmarshalListProjectsResponse, |
| 13 | + unmarshalProject, |
| 14 | +} from './marshalling.gen' |
| 15 | +import type { |
| 16 | + ListProjectsResponse, |
| 17 | + Project, |
| 18 | + ProjectApiCreateProjectRequest, |
| 19 | + ProjectApiDeleteProjectRequest, |
| 20 | + ProjectApiGetProjectRequest, |
| 21 | + ProjectApiListProjectsRequest, |
| 22 | + ProjectApiUpdateProjectRequest, |
| 23 | +} from './types.gen' |
| 24 | + |
| 25 | +const jsonContentHeaders = { |
| 26 | + 'Content-Type': 'application/json; charset=utf-8', |
| 27 | +} |
| 28 | + |
| 29 | +/** |
| 30 | + * Account API. |
| 31 | + * |
| 32 | + * This API allows you to manage projects. |
| 33 | + */ |
| 34 | +export class ProjectAPI extends ParentAPI { |
| 35 | + /** |
| 36 | + * Create a new Project for an Organization. Generate a new Project for an |
| 37 | + * Organization, specifying its configuration including name and description. |
| 38 | + * |
| 39 | + * @param request - The request {@link ProjectApiCreateProjectRequest} |
| 40 | + * @returns A Promise of Project |
| 41 | + */ |
| 42 | + createProject = (request: Readonly<ProjectApiCreateProjectRequest>) => |
| 43 | + this.client.fetch<Project>( |
| 44 | + { |
| 45 | + body: JSON.stringify( |
| 46 | + marshalProjectApiCreateProjectRequest(request, this.client.settings), |
| 47 | + ), |
| 48 | + headers: jsonContentHeaders, |
| 49 | + method: 'POST', |
| 50 | + path: `/account/v3/projects`, |
| 51 | + }, |
| 52 | + unmarshalProject, |
| 53 | + ) |
| 54 | + |
| 55 | + protected pageOfListProjects = ( |
| 56 | + request: Readonly<ProjectApiListProjectsRequest> = {}, |
| 57 | + ) => |
| 58 | + this.client.fetch<ListProjectsResponse>( |
| 59 | + { |
| 60 | + method: 'GET', |
| 61 | + path: `/account/v3/projects`, |
| 62 | + urlParams: urlParams( |
| 63 | + ['name', request.name], |
| 64 | + ['order_by', request.orderBy ?? 'created_at_asc'], |
| 65 | + [ |
| 66 | + 'organization_id', |
| 67 | + request.organizationId ?? |
| 68 | + this.client.settings.defaultOrganizationId, |
| 69 | + ], |
| 70 | + ['page', request.page], |
| 71 | + [ |
| 72 | + 'page_size', |
| 73 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 74 | + ], |
| 75 | + ['project_ids', request.projectIds], |
| 76 | + ), |
| 77 | + }, |
| 78 | + unmarshalListProjectsResponse, |
| 79 | + ) |
| 80 | + |
| 81 | + /** |
| 82 | + * List all Projects of an Organization. List all Projects of an Organization. |
| 83 | + * The response will include the total number of Projects as well as their |
| 84 | + * associated Organizations, names, and IDs. Other information includes the |
| 85 | + * creation and update date of the Project. |
| 86 | + * |
| 87 | + * @param request - The request {@link ProjectApiListProjectsRequest} |
| 88 | + * @returns A Promise of ListProjectsResponse |
| 89 | + */ |
| 90 | + listProjects = (request: Readonly<ProjectApiListProjectsRequest> = {}) => |
| 91 | + enrichForPagination('projects', this.pageOfListProjects, request) |
| 92 | + |
| 93 | + /** |
| 94 | + * Get an existing Project. Retrieve information about an existing Project, |
| 95 | + * specified by its Project ID. Its full details, including ID, name and |
| 96 | + * description, are returned in the response object. |
| 97 | + * |
| 98 | + * @param request - The request {@link ProjectApiGetProjectRequest} |
| 99 | + * @returns A Promise of Project |
| 100 | + */ |
| 101 | + getProject = (request: Readonly<ProjectApiGetProjectRequest> = {}) => |
| 102 | + this.client.fetch<Project>( |
| 103 | + { |
| 104 | + method: 'GET', |
| 105 | + path: `/account/v3/projects/${validatePathParam( |
| 106 | + 'projectId', |
| 107 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 108 | + )}`, |
| 109 | + }, |
| 110 | + unmarshalProject, |
| 111 | + ) |
| 112 | + |
| 113 | + /** |
| 114 | + * Delete an existing Project. Delete an existing Project, specified by its |
| 115 | + * Project ID. The Project needs to be empty (meaning there are no resources |
| 116 | + * left in it) to be deleted effectively. Note that deleting a Project is |
| 117 | + * permanent, and cannot be undone. |
| 118 | + * |
| 119 | + * @param request - The request {@link ProjectApiDeleteProjectRequest} |
| 120 | + */ |
| 121 | + deleteProject = (request: Readonly<ProjectApiDeleteProjectRequest> = {}) => |
| 122 | + this.client.fetch<void>({ |
| 123 | + method: 'DELETE', |
| 124 | + path: `/account/v3/projects/${validatePathParam( |
| 125 | + 'projectId', |
| 126 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 127 | + )}`, |
| 128 | + }) |
| 129 | + |
| 130 | + /** |
| 131 | + * Update Project. Update the parameters of an existing Project, specified by |
| 132 | + * its Project ID. These parameters include the name and description. |
| 133 | + * |
| 134 | + * @param request - The request {@link ProjectApiUpdateProjectRequest} |
| 135 | + * @returns A Promise of Project |
| 136 | + */ |
| 137 | + updateProject = (request: Readonly<ProjectApiUpdateProjectRequest> = {}) => |
| 138 | + this.client.fetch<Project>( |
| 139 | + { |
| 140 | + body: JSON.stringify( |
| 141 | + marshalProjectApiUpdateProjectRequest(request, this.client.settings), |
| 142 | + ), |
| 143 | + headers: jsonContentHeaders, |
| 144 | + method: 'PATCH', |
| 145 | + path: `/account/v3/projects/${validatePathParam( |
| 146 | + 'projectId', |
| 147 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 148 | + )}`, |
| 149 | + }, |
| 150 | + unmarshalProject, |
| 151 | + ) |
| 152 | +} |
0 commit comments