|
| 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 | + unmarshalServiceInfo, |
| 7 | + urlParams, |
| 8 | + validatePathParam, |
| 9 | +} from '../../../bridge' |
| 10 | +import type { Region, ServiceInfo } from '../../../bridge' |
| 11 | +import { |
| 12 | + marshalCreateJobDefinitionRequest, |
| 13 | + marshalUpdateJobDefinitionRequest, |
| 14 | + unmarshalJobDefinition, |
| 15 | + unmarshalJobRun, |
| 16 | + unmarshalListJobDefinitionsResponse, |
| 17 | + unmarshalListJobRunsResponse, |
| 18 | +} from './marshalling.gen' |
| 19 | +import type { |
| 20 | + CreateJobDefinitionRequest, |
| 21 | + DeleteJobDefinitionRequest, |
| 22 | + GetJobDefinitionRequest, |
| 23 | + GetJobRunRequest, |
| 24 | + GetServiceInfoRequest, |
| 25 | + JobDefinition, |
| 26 | + JobRun, |
| 27 | + ListJobDefinitionsRequest, |
| 28 | + ListJobDefinitionsResponse, |
| 29 | + ListJobRunsRequest, |
| 30 | + ListJobRunsResponse, |
| 31 | + StartJobDefinitionRequest, |
| 32 | + StopJobRunRequest, |
| 33 | + UpdateJobDefinitionRequest, |
| 34 | +} from './types.gen' |
| 35 | + |
| 36 | +const jsonContentHeaders = { |
| 37 | + 'Content-Type': 'application/json; charset=utf-8', |
| 38 | +} |
| 39 | + |
| 40 | +/** Serverless Jobs API. */ |
| 41 | +export class API extends ParentAPI { |
| 42 | + /** Lists the available regions of the API. */ |
| 43 | + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] |
| 44 | + |
| 45 | + getServiceInfo = (request: Readonly<GetServiceInfoRequest> = {}) => |
| 46 | + this.client.fetch<ServiceInfo>( |
| 47 | + { |
| 48 | + method: 'GET', |
| 49 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 50 | + 'region', |
| 51 | + request.region ?? this.client.settings.defaultRegion, |
| 52 | + )}`, |
| 53 | + }, |
| 54 | + unmarshalServiceInfo, |
| 55 | + ) |
| 56 | + |
| 57 | + createJobDefinition = (request: Readonly<CreateJobDefinitionRequest>) => |
| 58 | + this.client.fetch<JobDefinition>( |
| 59 | + { |
| 60 | + body: JSON.stringify( |
| 61 | + marshalCreateJobDefinitionRequest(request, this.client.settings), |
| 62 | + ), |
| 63 | + headers: jsonContentHeaders, |
| 64 | + method: 'POST', |
| 65 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 66 | + 'region', |
| 67 | + request.region ?? this.client.settings.defaultRegion, |
| 68 | + )}/job-definitions`, |
| 69 | + }, |
| 70 | + unmarshalJobDefinition, |
| 71 | + ) |
| 72 | + |
| 73 | + getJobDefinition = (request: Readonly<GetJobDefinitionRequest>) => |
| 74 | + this.client.fetch<JobDefinition>( |
| 75 | + { |
| 76 | + method: 'GET', |
| 77 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 78 | + 'region', |
| 79 | + request.region ?? this.client.settings.defaultRegion, |
| 80 | + )}/job-definitions/${validatePathParam( |
| 81 | + 'jobDefinitionId', |
| 82 | + request.jobDefinitionId, |
| 83 | + )}`, |
| 84 | + }, |
| 85 | + unmarshalJobDefinition, |
| 86 | + ) |
| 87 | + |
| 88 | + protected pageOfListJobDefinitions = ( |
| 89 | + request: Readonly<ListJobDefinitionsRequest> = {}, |
| 90 | + ) => |
| 91 | + this.client.fetch<ListJobDefinitionsResponse>( |
| 92 | + { |
| 93 | + method: 'GET', |
| 94 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 95 | + 'region', |
| 96 | + request.region ?? this.client.settings.defaultRegion, |
| 97 | + )}/job-definitions`, |
| 98 | + urlParams: urlParams( |
| 99 | + ['order_by', request.orderBy ?? 'created_at_asc'], |
| 100 | + ['page', request.page], |
| 101 | + [ |
| 102 | + 'page_size', |
| 103 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 104 | + ], |
| 105 | + ['project_id', request.projectId], |
| 106 | + ), |
| 107 | + }, |
| 108 | + unmarshalListJobDefinitionsResponse, |
| 109 | + ) |
| 110 | + |
| 111 | + listJobDefinitions = (request: Readonly<ListJobDefinitionsRequest> = {}) => |
| 112 | + enrichForPagination( |
| 113 | + 'jobDefinitions', |
| 114 | + this.pageOfListJobDefinitions, |
| 115 | + request, |
| 116 | + ) |
| 117 | + |
| 118 | + updateJobDefinition = (request: Readonly<UpdateJobDefinitionRequest>) => |
| 119 | + this.client.fetch<JobDefinition>( |
| 120 | + { |
| 121 | + body: JSON.stringify( |
| 122 | + marshalUpdateJobDefinitionRequest(request, this.client.settings), |
| 123 | + ), |
| 124 | + headers: jsonContentHeaders, |
| 125 | + method: 'PATCH', |
| 126 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 127 | + 'region', |
| 128 | + request.region ?? this.client.settings.defaultRegion, |
| 129 | + )}/job-definitions/${validatePathParam( |
| 130 | + 'jobDefinitionId', |
| 131 | + request.jobDefinitionId, |
| 132 | + )}`, |
| 133 | + }, |
| 134 | + unmarshalJobDefinition, |
| 135 | + ) |
| 136 | + |
| 137 | + deleteJobDefinition = (request: Readonly<DeleteJobDefinitionRequest>) => |
| 138 | + this.client.fetch<void>({ |
| 139 | + method: 'DELETE', |
| 140 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 141 | + 'region', |
| 142 | + request.region ?? this.client.settings.defaultRegion, |
| 143 | + )}/job-definitions/${validatePathParam( |
| 144 | + 'jobDefinitionId', |
| 145 | + request.jobDefinitionId, |
| 146 | + )}`, |
| 147 | + }) |
| 148 | + |
| 149 | + startJobDefinition = (request: Readonly<StartJobDefinitionRequest>) => |
| 150 | + this.client.fetch<JobRun>( |
| 151 | + { |
| 152 | + body: '{}', |
| 153 | + headers: jsonContentHeaders, |
| 154 | + method: 'POST', |
| 155 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 156 | + 'region', |
| 157 | + request.region ?? this.client.settings.defaultRegion, |
| 158 | + )}/job-definitions/${validatePathParam( |
| 159 | + 'jobDefinitionId', |
| 160 | + request.jobDefinitionId, |
| 161 | + )}/start`, |
| 162 | + }, |
| 163 | + unmarshalJobRun, |
| 164 | + ) |
| 165 | + |
| 166 | + getJobRun = (request: Readonly<GetJobRunRequest>) => |
| 167 | + this.client.fetch<JobRun>( |
| 168 | + { |
| 169 | + method: 'GET', |
| 170 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 171 | + 'region', |
| 172 | + request.region ?? this.client.settings.defaultRegion, |
| 173 | + )}/job-runs/${validatePathParam('jobRunId', request.jobRunId)}`, |
| 174 | + }, |
| 175 | + unmarshalJobRun, |
| 176 | + ) |
| 177 | + |
| 178 | + stopJobRun = (request: Readonly<StopJobRunRequest>) => |
| 179 | + this.client.fetch<JobRun>( |
| 180 | + { |
| 181 | + body: '{}', |
| 182 | + headers: jsonContentHeaders, |
| 183 | + method: 'POST', |
| 184 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 185 | + 'region', |
| 186 | + request.region ?? this.client.settings.defaultRegion, |
| 187 | + )}/job-runs/${validatePathParam('jobRunId', request.jobRunId)}/stop`, |
| 188 | + }, |
| 189 | + unmarshalJobRun, |
| 190 | + ) |
| 191 | + |
| 192 | + protected pageOfListJobRuns = (request: Readonly<ListJobRunsRequest> = {}) => |
| 193 | + this.client.fetch<ListJobRunsResponse>( |
| 194 | + { |
| 195 | + method: 'GET', |
| 196 | + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam( |
| 197 | + 'region', |
| 198 | + request.region ?? this.client.settings.defaultRegion, |
| 199 | + )}/job-runs`, |
| 200 | + urlParams: urlParams( |
| 201 | + ['job_definition_id', request.jobDefinitionId], |
| 202 | + ['order_by', request.orderBy ?? 'created_at_asc'], |
| 203 | + ['page', request.page], |
| 204 | + [ |
| 205 | + 'page_size', |
| 206 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 207 | + ], |
| 208 | + ['project_id', request.projectId], |
| 209 | + ), |
| 210 | + }, |
| 211 | + unmarshalListJobRunsResponse, |
| 212 | + ) |
| 213 | + |
| 214 | + listJobRuns = (request: Readonly<ListJobRunsRequest> = {}) => |
| 215 | + enrichForPagination('jobRuns', this.pageOfListJobRuns, request) |
| 216 | +} |
0 commit comments