@scaleway/sdk-function 1.3.1 → 1.4.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",
@@ -72,7 +73,7 @@ class API extends sdkClient.API {
72
73
  * @param request - The request {@link CreateNamespaceRequest}
73
74
  * @returns A Promise of Namespace
74
75
  */
75
- createNamespace = (request = {}) => this.client.fetch(
76
+ createNamespace = (request) => this.client.fetch(
76
77
  {
77
78
  body: JSON.stringify(
78
79
  marshalling_gen.marshalCreateNamespaceRequest(request, this.client.settings)
@@ -1,5 +1,5 @@
1
1
  import { API as ParentAPI } from '@scaleway/sdk-client';
2
- import type { Region as ScwRegion, WaitForOptions } from '@scaleway/sdk-client';
2
+ import type { ApiLocality, 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.
@@ -41,7 +44,7 @@ export declare class API extends ParentAPI {
41
44
  * @param request - The request {@link CreateNamespaceRequest}
42
45
  * @returns A Promise of Namespace
43
46
  */
44
- createNamespace: (request?: Readonly<CreateNamespaceRequest>) => Promise<Namespace>;
47
+ createNamespace: (request: Readonly<CreateNamespaceRequest>) => Promise<Namespace>;
45
48
  /**
46
49
  * Update an existing namespace. Update the namespace associated with the specified ID.
47
50
  *
@@ -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",
@@ -70,7 +71,7 @@ class API extends API$1 {
70
71
  * @param request - The request {@link CreateNamespaceRequest}
71
72
  * @returns A Promise of Namespace
72
73
  */
73
- createNamespace = (request = {}) => this.client.fetch(
74
+ createNamespace = (request) => this.client.fetch(
74
75
  {
75
76
  body: JSON.stringify(
76
77
  marshalCreateNamespaceRequest(request, this.client.settings)
@@ -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,11 @@ export interface Namespace {
339
343
  * Last update date of the namespace.
340
344
  */
341
345
  updatedAt?: Date;
346
+ /**
347
+ * @deprecated When activated, functions in the namespace can be connected to a Private Network.
348
+ Note that activating the VPC integration can only be done when creating a new namespace.
349
+ */
350
+ vpcIntegrationActivated?: boolean;
342
351
  }
343
352
  export interface Token {
344
353
  /**
@@ -530,6 +539,12 @@ export type CreateFunctionRequest = {
530
539
  * Tags of the Serverless Function.
531
540
  */
532
541
  tags?: string[];
542
+ /**
543
+ * When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
544
+
545
+ Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
546
+ */
547
+ privateNetworkId?: string;
533
548
  };
534
549
  export type CreateNamespaceRequest = {
535
550
  /**
@@ -557,6 +572,10 @@ export type CreateNamespaceRequest = {
557
572
  * Tags of the Serverless Function Namespace.
558
573
  */
559
574
  tags?: string[];
575
+ /**
576
+ * When activated, functions in the namespace can be connected to a Private Network.
577
+ */
578
+ activateVpcIntegration: boolean;
560
579
  };
561
580
  export type CreateTokenRequest = {
562
581
  /**
@@ -1108,6 +1127,12 @@ export type UpdateFunctionRequest = {
1108
1127
  * Tags of the Serverless Function.
1109
1128
  */
1110
1129
  tags?: string[];
1130
+ /**
1131
+ * When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
1132
+
1133
+ Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
1134
+ */
1135
+ privateNetworkId?: string;
1111
1136
  };
1112
1137
  export type UpdateNamespaceRequest = {
1113
1138
  /**
@@ -30,6 +30,11 @@ const CreateTriggerRequestMnqSqsClientConfig = {
30
30
  minLength: 1
31
31
  }
32
32
  };
33
+ const UpdateFunctionRequest = {
34
+ privateNetworkId: {
35
+ ignoreEmpty: true
36
+ }
37
+ };
33
38
  const UpdateTriggerRequest = {
34
39
  description: {
35
40
  maxLength: 255
@@ -42,4 +47,5 @@ const UpdateTriggerRequest = {
42
47
  exports.CreateTriggerRequest = CreateTriggerRequest;
43
48
  exports.CreateTriggerRequestMnqNatsClientConfig = CreateTriggerRequestMnqNatsClientConfig;
44
49
  exports.CreateTriggerRequestMnqSqsClientConfig = CreateTriggerRequestMnqSqsClientConfig;
50
+ exports.UpdateFunctionRequest = UpdateFunctionRequest;
45
51
  exports.UpdateTriggerRequest = UpdateTriggerRequest;
@@ -28,6 +28,11 @@ export declare const CreateTriggerRequestMnqSqsClientConfig: {
28
28
  minLength: number;
29
29
  };
30
30
  };
31
+ export declare const UpdateFunctionRequest: {
32
+ privateNetworkId: {
33
+ ignoreEmpty: boolean;
34
+ };
35
+ };
31
36
  export declare const UpdateTriggerRequest: {
32
37
  description: {
33
38
  maxLength: number;
@@ -28,6 +28,11 @@ const CreateTriggerRequestMnqSqsClientConfig = {
28
28
  minLength: 1
29
29
  }
30
30
  };
31
+ const UpdateFunctionRequest = {
32
+ privateNetworkId: {
33
+ ignoreEmpty: true
34
+ }
35
+ };
31
36
  const UpdateTriggerRequest = {
32
37
  description: {
33
38
  maxLength: 255
@@ -41,5 +46,6 @@ export {
41
46
  CreateTriggerRequest,
42
47
  CreateTriggerRequestMnqNatsClientConfig,
43
48
  CreateTriggerRequestMnqSqsClientConfig,
49
+ UpdateFunctionRequest,
44
50
  UpdateTriggerRequest
45
51
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-function",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Scaleway SDK function",
5
- "types": "dist/index.d.ts",
5
+ "license": "Apache-2.0",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@scaleway/random-name": "5.1.1",
33
- "@scaleway/sdk-std": "1.0.3"
33
+ "@scaleway/sdk-std": "1.0.5"
34
34
  },
35
35
  "peerDependencies": {
36
- "@scaleway/sdk-client": "^1.2.2"
36
+ "@scaleway/sdk-client": "^1.3.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@scaleway/sdk-client": "^1.2.2"
39
+ "@scaleway/sdk-client": "^1.3.0"
40
40
  },
41
41
  "scripts": {
42
42
  "package:check": "pnpm publint",