@scaleway/sdk 0.1.0-alpha.3 → 0.1.0-alpha.4

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.
@@ -0,0 +1,154 @@
1
+ import { validatePathParam, urlParams, resolveOneOf, unmarshalAnyRes } from '../../../scw/marshalling.js';
2
+ import { fetchAll, fetchPaginated } from '../../../scw/fetch/resource-paginator.js';
3
+ import { API } from '../../../helpers/API.js';
4
+
5
+ // This file was automatically generated. DO NOT EDIT.
6
+
7
+ const unmarshalCredential = data => unmarshalAnyRes(data);
8
+
9
+ const unmarshalListCredentialsResponse = data => unmarshalAnyRes(data);
10
+
11
+ const unmarshalListNamespacesResponse = data => unmarshalAnyRes(data);
12
+
13
+ const unmarshalNamespace = data => unmarshalAnyRes(data);
14
+
15
+ const jsonContentHeaders = {
16
+ 'Content-Type': 'application/json; charset=utf-8'
17
+ };
18
+ class MnqAPI extends API {
19
+ constructor() {
20
+ var _this;
21
+
22
+ super(...arguments);
23
+ _this = this;
24
+
25
+ this.pageOfListNamespaces = function (request) {
26
+ if (request === void 0) {
27
+ request = {};
28
+ }
29
+
30
+ return _this.client.fetch({
31
+ method: 'GET',
32
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/namespaces`,
33
+ urlParams: urlParams(['order_by', request.orderBy ?? 'id_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId])
34
+ }, unmarshalListNamespacesResponse);
35
+ };
36
+
37
+ this.listNamespaces = function (request) {
38
+ if (request === void 0) {
39
+ request = {};
40
+ }
41
+
42
+ return Object.assign(_this.pageOfListNamespaces(request), {
43
+ all: () => fetchAll('namespaces', _this.pageOfListNamespaces, request),
44
+ [Symbol.asyncIterator]: () => fetchPaginated('namespaces', _this.pageOfListNamespaces, request),
45
+ page: async num => (await _this.pageOfListNamespaces({ ...request,
46
+ page: num
47
+ })).namespaces
48
+ });
49
+ };
50
+
51
+ this.createNamespace = request => this.client.fetch({
52
+ body: JSON.stringify({
53
+ name: request.name,
54
+ project_id: request.projectId ?? this.client.settings.defaultProjectId,
55
+ protocol: request.protocol ?? 'unknown'
56
+ }),
57
+ headers: jsonContentHeaders,
58
+ method: 'POST',
59
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/namespaces`
60
+ }, unmarshalNamespace);
61
+
62
+ this.updateNamespace = request => this.client.fetch({
63
+ body: JSON.stringify({
64
+ name: request.name,
65
+ namespace_id: request.namespaceId
66
+ }),
67
+ headers: jsonContentHeaders,
68
+ method: 'PATCH',
69
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/namespaces`
70
+ }, unmarshalNamespace);
71
+
72
+ this.getNamespace = request => this.client.fetch({
73
+ method: 'GET',
74
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam('namespaceId', request.namespaceId)}`
75
+ }, unmarshalNamespace);
76
+
77
+ this.deleteNamespace = request => this.client.fetch({
78
+ method: 'DELETE',
79
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/namespaces/${validatePathParam('namespaceId', request.namespaceId)}`
80
+ });
81
+
82
+ this.createCredential = request => {
83
+ const optionalPermissions = resolveOneOf([{
84
+ param: 'permissions',
85
+ value: request.permissions
86
+ }]);
87
+ return this.client.fetch({
88
+ body: JSON.stringify({
89
+ name: request.name,
90
+ namespace_id: request.namespaceId,
91
+ ...optionalPermissions
92
+ }),
93
+ headers: jsonContentHeaders,
94
+ method: 'POST',
95
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/credentials`
96
+ }, unmarshalCredential);
97
+ };
98
+
99
+ this.deleteCredential = request => this.client.fetch({
100
+ method: 'DELETE',
101
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/credentials/${validatePathParam('credentialId', request.credentialId)}`
102
+ });
103
+
104
+ this.pageOfListCredentials = function (request) {
105
+ if (request === void 0) {
106
+ request = {};
107
+ }
108
+
109
+ return _this.client.fetch({
110
+ method: 'GET',
111
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/credentials`,
112
+ urlParams: urlParams(['namespace_id', request.namespaceId], ['order_by', request.orderBy ?? 'id_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize])
113
+ }, unmarshalListCredentialsResponse);
114
+ };
115
+
116
+ this.listCredentials = function (request) {
117
+ if (request === void 0) {
118
+ request = {};
119
+ }
120
+
121
+ return Object.assign(_this.pageOfListCredentials(request), {
122
+ all: () => fetchAll('credentials', _this.pageOfListCredentials, request),
123
+ [Symbol.asyncIterator]: () => fetchPaginated('credentials', _this.pageOfListCredentials, request),
124
+ page: async num => (await _this.pageOfListCredentials({ ...request,
125
+ page: num
126
+ })).credentials
127
+ });
128
+ };
129
+
130
+ this.updateCredential = request => {
131
+ const optionalPermissions = resolveOneOf([{
132
+ param: 'permissions',
133
+ value: request.permissions
134
+ }]);
135
+ return this.client.fetch({
136
+ body: JSON.stringify({
137
+ name: request.name,
138
+ ...optionalPermissions
139
+ }),
140
+ headers: jsonContentHeaders,
141
+ method: 'PATCH',
142
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/credentials/${validatePathParam('credentialId', request.credentialId)}`
143
+ }, unmarshalCredential);
144
+ };
145
+
146
+ this.getCredential = request => this.client.fetch({
147
+ method: 'GET',
148
+ path: `/mnq/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/credentials/${validatePathParam('credentialId', request.credentialId)}`
149
+ }, unmarshalCredential);
150
+ }
151
+
152
+ }
153
+
154
+ export { MnqAPI };
@@ -0,0 +1 @@
1
+