@scaleway/sdk-function 1.3.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,12 +7,13 @@ const jsonContentHeaders = {
7
7
  "Content-Type": "application/json; charset=utf-8"
8
8
  };
9
9
  class API extends sdkClient.API {
10
- /** Lists the available regions of the API. */
11
- static LOCALITIES = [
12
- "fr-par",
13
- "nl-ams",
14
- "pl-waw"
15
- ];
10
+ /**
11
+ * Locality of this API.
12
+ * type ∈ {'zone','region','global','unspecified'}
13
+ */
14
+ static LOCALITY = sdkClient.toApiLocality({
15
+ regions: ["fr-par", "nl-ams", "pl-waw"]
16
+ });
16
17
  pageOfListNamespaces = (request = {}) => this.client.fetch(
17
18
  {
18
19
  method: "GET",
@@ -185,11 +186,14 @@ class API extends sdkClient.API {
185
186
  marshalling_gen.unmarshalFunction
186
187
  );
187
188
  /**
188
- * Update an existing function. Update the function associated with the specified ID.
189
- *
190
- * @param request - The request {@link UpdateFunctionRequest}
191
- * @returns A Promise of Function
192
- */
189
+ * Update an existing function. Update the function associated with the specified ID.
190
+
191
+ When updating a function, the function is automatically redeployed to apply the changes.
192
+ This behavior can be changed by setting the `redeploy` field to `false` in the request.
193
+ *
194
+ * @param request - The request {@link UpdateFunctionRequest}
195
+ * @returns A Promise of Function
196
+ */
193
197
  updateFunction = (request) => this.client.fetch(
194
198
  {
195
199
  body: JSON.stringify(
@@ -1,5 +1,5 @@
1
+ import type { ApiLocality, WaitForOptions } from '@scaleway/sdk-client';
1
2
  import { API as ParentAPI } from '@scaleway/sdk-client';
2
- import type { Region as ScwRegion, WaitForOptions } from '@scaleway/sdk-client';
3
3
  import type { CreateCronRequest, CreateDomainRequest, CreateFunctionRequest, CreateNamespaceRequest, CreateTokenRequest, CreateTriggerRequest, Cron, DeleteCronRequest, DeleteDomainRequest, DeleteFunctionRequest, DeleteNamespaceRequest, DeleteTokenRequest, DeleteTriggerRequest, DeployFunctionRequest, Domain, DownloadURL, Function, GetCronRequest, GetDomainRequest, GetFunctionDownloadURLRequest, GetFunctionRequest, GetFunctionUploadURLRequest, GetNamespaceRequest, GetTokenRequest, GetTriggerRequest, ListCronsRequest, ListCronsResponse, ListDomainsRequest, ListDomainsResponse, ListFunctionRuntimesRequest, ListFunctionRuntimesResponse, ListFunctionsRequest, ListFunctionsResponse, ListNamespacesRequest, ListNamespacesResponse, ListTokensRequest, ListTokensResponse, ListTriggersRequest, ListTriggersResponse, Namespace, Token, Trigger, UpdateCronRequest, UpdateFunctionRequest, UpdateNamespaceRequest, UpdateTriggerRequest, UploadURL } from './types.gen';
4
4
  /**
5
5
  * Serverless Functions API.
@@ -7,8 +7,11 @@ import type { CreateCronRequest, CreateDomainRequest, CreateFunctionRequest, Cre
7
7
  This API allows you to manage your Serverless Functions.
8
8
  */
9
9
  export declare class API extends ParentAPI {
10
- /** Lists the available regions of the API. */
11
- static readonly LOCALITIES: ScwRegion[];
10
+ /**
11
+ * Locality of this API.
12
+ * type ∈ {'zone','region','global','unspecified'}
13
+ */
14
+ static readonly LOCALITY: ApiLocality;
12
15
  protected pageOfListNamespaces: (request?: Readonly<ListNamespacesRequest>) => Promise<ListNamespacesResponse>;
13
16
  /**
14
17
  * List all your namespaces. List all existing namespaces in the specified region.
@@ -91,6 +94,9 @@ export declare class API extends ParentAPI {
91
94
  createFunction: (request: Readonly<CreateFunctionRequest>) => Promise<Function>;
92
95
  /**
93
96
  * Update an existing function. Update the function associated with the specified ID.
97
+
98
+ When updating a function, the function is automatically redeployed to apply the changes.
99
+ This behavior can be changed by setting the `redeploy` field to `false` in the request.
94
100
  *
95
101
  * @param request - The request {@link UpdateFunctionRequest}
96
102
  * @returns A Promise of Function
@@ -1,16 +1,17 @@
1
- import { API as API$1, urlParams, validatePathParam, enrichForPagination, waitForResource, resolveOneOf } from "@scaleway/sdk-client";
1
+ import { API as API$1, toApiLocality, urlParams, validatePathParam, enrichForPagination, waitForResource, resolveOneOf } from "@scaleway/sdk-client";
2
2
  import { NAMESPACE_TRANSIENT_STATUSES, FUNCTION_TRANSIENT_STATUSES, CRON_TRANSIENT_STATUSES, DOMAIN_TRANSIENT_STATUSES, TOKEN_TRANSIENT_STATUSES, TRIGGER_TRANSIENT_STATUSES } from "./content.gen.js";
3
3
  import { unmarshalListNamespacesResponse, unmarshalNamespace, marshalCreateNamespaceRequest, marshalUpdateNamespaceRequest, unmarshalListFunctionsResponse, unmarshalFunction, marshalCreateFunctionRequest, marshalUpdateFunctionRequest, unmarshalListFunctionRuntimesResponse, unmarshalUploadURL, unmarshalDownloadURL, unmarshalListCronsResponse, unmarshalCron, marshalCreateCronRequest, marshalUpdateCronRequest, unmarshalListDomainsResponse, unmarshalDomain, marshalCreateDomainRequest, marshalCreateTokenRequest, unmarshalToken, unmarshalListTokensResponse, marshalCreateTriggerRequest, unmarshalTrigger, unmarshalListTriggersResponse, marshalUpdateTriggerRequest } from "./marshalling.gen.js";
4
4
  const jsonContentHeaders = {
5
5
  "Content-Type": "application/json; charset=utf-8"
6
6
  };
7
7
  class API extends API$1 {
8
- /** Lists the available regions of the API. */
9
- static LOCALITIES = [
10
- "fr-par",
11
- "nl-ams",
12
- "pl-waw"
13
- ];
8
+ /**
9
+ * Locality of this API.
10
+ * type ∈ {'zone','region','global','unspecified'}
11
+ */
12
+ static LOCALITY = toApiLocality({
13
+ regions: ["fr-par", "nl-ams", "pl-waw"]
14
+ });
14
15
  pageOfListNamespaces = (request = {}) => this.client.fetch(
15
16
  {
16
17
  method: "GET",
@@ -183,11 +184,14 @@ class API extends API$1 {
183
184
  unmarshalFunction
184
185
  );
185
186
  /**
186
- * Update an existing function. Update the function associated with the specified ID.
187
- *
188
- * @param request - The request {@link UpdateFunctionRequest}
189
- * @returns A Promise of Function
190
- */
187
+ * Update an existing function. Update the function associated with the specified ID.
188
+
189
+ When updating a function, the function is automatically redeployed to apply the changes.
190
+ This behavior can be changed by setting the `redeploy` field to `false` in the request.
191
+ *
192
+ * @param request - The request {@link UpdateFunctionRequest}
193
+ * @returns A Promise of Function
194
+ */
191
195
  updateFunction = (request) => this.client.fetch(
192
196
  {
193
197
  body: JSON.stringify(
@@ -66,6 +66,7 @@ const unmarshalFunction = (data) => {
66
66
  name: data.name,
67
67
  namespaceId: data.namespace_id,
68
68
  privacy: data.privacy,
69
+ privateNetworkId: data.private_network_id,
69
70
  readyAt: sdkClient.unmarshalDate(data.ready_at),
70
71
  region: data.region,
71
72
  runtime: data.runtime,
@@ -105,7 +106,8 @@ const unmarshalNamespace = (data) => {
105
106
  ),
106
107
  status: data.status,
107
108
  tags: data.tags,
108
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
109
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
110
+ vpcIntegrationActivated: data.vpc_integration_activated
109
111
  };
110
112
  };
111
113
  const unmarshalToken = (data) => {
@@ -327,6 +329,7 @@ const marshalCreateFunctionRequest = (request, defaults) => ({
327
329
  name: request.name || randomName("fn"),
328
330
  namespace_id: request.namespaceId,
329
331
  privacy: request.privacy,
332
+ private_network_id: request.privateNetworkId,
330
333
  runtime: request.runtime,
331
334
  sandbox: request.sandbox,
332
335
  secret_environment_variables: request.secretEnvironmentVariables !== void 0 ? request.secretEnvironmentVariables.map(
@@ -336,6 +339,7 @@ const marshalCreateFunctionRequest = (request, defaults) => ({
336
339
  timeout: request.timeout
337
340
  });
338
341
  const marshalCreateNamespaceRequest = (request, defaults) => ({
342
+ activate_vpc_integration: request.activateVpcIntegration,
339
343
  description: request.description,
340
344
  environment_variables: request.environmentVariables,
341
345
  name: request.name || randomName("ns"),
@@ -410,6 +414,7 @@ const marshalUpdateFunctionRequest = (request, defaults) => ({
410
414
  memory_limit: request.memoryLimit,
411
415
  min_scale: request.minScale,
412
416
  privacy: request.privacy,
417
+ private_network_id: request.privateNetworkId,
413
418
  redeploy: request.redeploy,
414
419
  runtime: request.runtime,
415
420
  sandbox: request.sandbox,
@@ -1,5 +1,5 @@
1
1
  import randomName from "@scaleway/random-name";
2
- import { resolveOneOf, isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ import { resolveOneOf, isJSONObject, unmarshalArrayOfObject, unmarshalDate } from "@scaleway/sdk-client";
3
3
  const unmarshalCron = (data) => {
4
4
  if (!isJSONObject(data)) {
5
5
  throw new TypeError(
@@ -64,6 +64,7 @@ const unmarshalFunction = (data) => {
64
64
  name: data.name,
65
65
  namespaceId: data.namespace_id,
66
66
  privacy: data.privacy,
67
+ privateNetworkId: data.private_network_id,
67
68
  readyAt: unmarshalDate(data.ready_at),
68
69
  region: data.region,
69
70
  runtime: data.runtime,
@@ -103,7 +104,8 @@ const unmarshalNamespace = (data) => {
103
104
  ),
104
105
  status: data.status,
105
106
  tags: data.tags,
106
- updatedAt: unmarshalDate(data.updated_at)
107
+ updatedAt: unmarshalDate(data.updated_at),
108
+ vpcIntegrationActivated: data.vpc_integration_activated
107
109
  };
108
110
  };
109
111
  const unmarshalToken = (data) => {
@@ -325,6 +327,7 @@ const marshalCreateFunctionRequest = (request, defaults) => ({
325
327
  name: request.name || randomName("fn"),
326
328
  namespace_id: request.namespaceId,
327
329
  privacy: request.privacy,
330
+ private_network_id: request.privateNetworkId,
328
331
  runtime: request.runtime,
329
332
  sandbox: request.sandbox,
330
333
  secret_environment_variables: request.secretEnvironmentVariables !== void 0 ? request.secretEnvironmentVariables.map(
@@ -334,6 +337,7 @@ const marshalCreateFunctionRequest = (request, defaults) => ({
334
337
  timeout: request.timeout
335
338
  });
336
339
  const marshalCreateNamespaceRequest = (request, defaults) => ({
340
+ activate_vpc_integration: request.activateVpcIntegration,
337
341
  description: request.description,
338
342
  environment_variables: request.environmentVariables,
339
343
  name: request.name || randomName("ns"),
@@ -408,6 +412,7 @@ const marshalUpdateFunctionRequest = (request, defaults) => ({
408
412
  memory_limit: request.memoryLimit,
409
413
  min_scale: request.minScale,
410
414
  privacy: request.privacy,
415
+ private_network_id: request.privateNetworkId,
411
416
  redeploy: request.redeploy,
412
417
  runtime: request.runtime,
413
418
  sandbox: request.sandbox,
@@ -277,6 +277,10 @@ export interface Function {
277
277
  * List of tags applied to the Serverless Function.
278
278
  */
279
279
  tags: string[];
280
+ /**
281
+ * When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
282
+ */
283
+ privateNetworkId?: string;
280
284
  }
281
285
  export interface Namespace {
282
286
  /**
@@ -339,6 +343,10 @@ export interface Namespace {
339
343
  * Last update date of the namespace.
340
344
  */
341
345
  updatedAt?: Date;
346
+ /**
347
+ * @deprecated The value of this field doesn't matter anymore, and will be removed in a near future.
348
+ */
349
+ vpcIntegrationActivated?: boolean;
342
350
  }
343
351
  export interface Token {
344
352
  /**
@@ -530,6 +538,10 @@ export type CreateFunctionRequest = {
530
538
  * Tags of the Serverless Function.
531
539
  */
532
540
  tags?: string[];
541
+ /**
542
+ * When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
543
+ */
544
+ privateNetworkId?: string;
533
545
  };
534
546
  export type CreateNamespaceRequest = {
535
547
  /**
@@ -557,6 +569,10 @@ export type CreateNamespaceRequest = {
557
569
  * Tags of the Serverless Function Namespace.
558
570
  */
559
571
  tags?: string[];
572
+ /**
573
+ * @deprecated Setting this field to true doesn't matter anymore. It will be removed in a near future.
574
+ */
575
+ activateVpcIntegration?: boolean;
560
576
  };
561
577
  export type CreateTokenRequest = {
562
578
  /**
@@ -1091,7 +1107,18 @@ export type UpdateFunctionRequest = {
1091
1107
  */
1092
1108
  description?: string;
1093
1109
  /**
1094
- * Secret environment variables of the function.
1110
+ * During an update, secret environment variables that are not specified in this field will be kept unchanged.
1111
+
1112
+ In order to delete a specific secret environment variable, you must reference its key, but not provide any value for it.
1113
+ For example, the following payload will delete the `TO_DELETE` secret environment variable:
1114
+
1115
+ ```json
1116
+ {
1117
+ "secret_environment_variables":[
1118
+ {"key":"TO_DELETE"}
1119
+ ]
1120
+ }
1121
+ ```.
1095
1122
  */
1096
1123
  secretEnvironmentVariables?: Secret[];
1097
1124
  /**
@@ -1108,6 +1135,10 @@ export type UpdateFunctionRequest = {
1108
1135
  * Tags of the Serverless Function.
1109
1136
  */
1110
1137
  tags?: string[];
1138
+ /**
1139
+ * When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
1140
+ */
1141
+ privateNetworkId?: string;
1111
1142
  };
1112
1143
  export type UpdateNamespaceRequest = {
1113
1144
  /**
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const CreateFunctionRequest = {
4
+ privateNetworkId: {
5
+ ignoreEmpty: true
6
+ }
7
+ };
3
8
  const CreateTriggerRequest = {
4
9
  description: {
5
10
  maxLength: 255
@@ -30,6 +35,11 @@ const CreateTriggerRequestMnqSqsClientConfig = {
30
35
  minLength: 1
31
36
  }
32
37
  };
38
+ const UpdateFunctionRequest = {
39
+ privateNetworkId: {
40
+ ignoreEmpty: true
41
+ }
42
+ };
33
43
  const UpdateTriggerRequest = {
34
44
  description: {
35
45
  maxLength: 255
@@ -39,7 +49,9 @@ const UpdateTriggerRequest = {
39
49
  minLength: 1
40
50
  }
41
51
  };
52
+ exports.CreateFunctionRequest = CreateFunctionRequest;
42
53
  exports.CreateTriggerRequest = CreateTriggerRequest;
43
54
  exports.CreateTriggerRequestMnqNatsClientConfig = CreateTriggerRequestMnqNatsClientConfig;
44
55
  exports.CreateTriggerRequestMnqSqsClientConfig = CreateTriggerRequestMnqSqsClientConfig;
56
+ exports.UpdateFunctionRequest = UpdateFunctionRequest;
45
57
  exports.UpdateTriggerRequest = UpdateTriggerRequest;
@@ -1,3 +1,8 @@
1
+ export declare const CreateFunctionRequest: {
2
+ privateNetworkId: {
3
+ ignoreEmpty: boolean;
4
+ };
5
+ };
1
6
  export declare const CreateTriggerRequest: {
2
7
  description: {
3
8
  maxLength: number;
@@ -28,6 +33,11 @@ export declare const CreateTriggerRequestMnqSqsClientConfig: {
28
33
  minLength: number;
29
34
  };
30
35
  };
36
+ export declare const UpdateFunctionRequest: {
37
+ privateNetworkId: {
38
+ ignoreEmpty: boolean;
39
+ };
40
+ };
31
41
  export declare const UpdateTriggerRequest: {
32
42
  description: {
33
43
  maxLength: number;
@@ -1,3 +1,8 @@
1
+ const CreateFunctionRequest = {
2
+ privateNetworkId: {
3
+ ignoreEmpty: true
4
+ }
5
+ };
1
6
  const CreateTriggerRequest = {
2
7
  description: {
3
8
  maxLength: 255
@@ -28,6 +33,11 @@ const CreateTriggerRequestMnqSqsClientConfig = {
28
33
  minLength: 1
29
34
  }
30
35
  };
36
+ const UpdateFunctionRequest = {
37
+ privateNetworkId: {
38
+ ignoreEmpty: true
39
+ }
40
+ };
31
41
  const UpdateTriggerRequest = {
32
42
  description: {
33
43
  maxLength: 255
@@ -38,8 +48,10 @@ const UpdateTriggerRequest = {
38
48
  }
39
49
  };
40
50
  export {
51
+ CreateFunctionRequest,
41
52
  CreateTriggerRequest,
42
53
  CreateTriggerRequestMnqNatsClientConfig,
43
54
  CreateTriggerRequestMnqSqsClientConfig,
55
+ UpdateFunctionRequest,
44
56
  UpdateTriggerRequest
45
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-function",
3
- "version": "1.3.2",
3
+ "version": "1.5.0",
4
4
  "description": "Scaleway SDK function",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
@@ -26,17 +26,17 @@
26
26
  "directory": "packages_generated/function"
27
27
  },
28
28
  "engines": {
29
- "node": ">=20.19.1"
29
+ "node": ">=20.19.4"
30
30
  },
31
31
  "dependencies": {
32
- "@scaleway/random-name": "5.1.1",
33
- "@scaleway/sdk-std": "1.0.4"
32
+ "@scaleway/random-name": "5.1.2",
33
+ "@scaleway/sdk-std": "1.0.6"
34
34
  },
35
35
  "peerDependencies": {
36
- "@scaleway/sdk-client": "^1.2.3"
36
+ "@scaleway/sdk-client": "^1.3.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@scaleway/sdk-client": "^1.2.3"
39
+ "@scaleway/sdk-client": "^1.3.1"
40
40
  },
41
41
  "scripts": {
42
42
  "package:check": "pnpm publint",