@scaleway/sdk 1.1.0 → 1.2.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.
@@ -0,0 +1,140 @@
1
+ import { isJSONObject } from '../../../helpers/json.js';
2
+ import { unmarshalMoney } from '../../../scw/custom-marshalling.js';
3
+ import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
4
+
5
+ // This file was automatically generated. DO NOT EDIT.
6
+ const unmarshalHostingCpanelUrls = data => {
7
+ if (!isJSONObject(data)) {
8
+ throw new TypeError(`Unmarshalling the type 'HostingCpanelUrls' failed as data isn't a dictionary.`);
9
+ }
10
+ return {
11
+ dashboard: data.dashboard,
12
+ webmail: data.webmail
13
+ };
14
+ };
15
+ const unmarshalHostingOption = data => {
16
+ if (!isJSONObject(data)) {
17
+ throw new TypeError(`Unmarshalling the type 'HostingOption' failed as data isn't a dictionary.`);
18
+ }
19
+ return {
20
+ id: data.id,
21
+ name: data.name
22
+ };
23
+ };
24
+ const unmarshalOfferProduct = data => {
25
+ if (!isJSONObject(data)) {
26
+ throw new TypeError(`Unmarshalling the type 'OfferProduct' failed as data isn't a dictionary.`);
27
+ }
28
+ return {
29
+ databasesQuota: data.databases_quota,
30
+ emailAccountsQuota: data.email_accounts_quota,
31
+ emailStorageQuota: data.email_storage_quota,
32
+ hostingStorageQuota: data.hosting_storage_quota,
33
+ name: data.name,
34
+ option: data.option,
35
+ ram: data.ram,
36
+ supportIncluded: data.support_included,
37
+ vCpu: data.v_cpu
38
+ };
39
+ };
40
+ const unmarshalDnsRecord = data => {
41
+ if (!isJSONObject(data)) {
42
+ throw new TypeError(`Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary.`);
43
+ }
44
+ return {
45
+ name: data.name,
46
+ priority: data.priority,
47
+ status: data.status,
48
+ ttl: data.ttl,
49
+ type: data.type,
50
+ value: data.value
51
+ };
52
+ };
53
+ const unmarshalHosting = data => {
54
+ if (!isJSONObject(data)) {
55
+ throw new TypeError(`Unmarshalling the type 'Hosting' failed as data isn't a dictionary.`);
56
+ }
57
+ return {
58
+ cpanelUrls: data.cpanel_urls ? unmarshalHostingCpanelUrls(data.cpanel_urls) : undefined,
59
+ createdAt: unmarshalDate(data.created_at),
60
+ dnsStatus: data.dns_status,
61
+ domain: data.domain,
62
+ id: data.id,
63
+ offerId: data.offer_id,
64
+ offerName: data.offer_name,
65
+ options: unmarshalArrayOfObject(data.options, unmarshalHostingOption),
66
+ organizationId: data.organization_id,
67
+ platformHostname: data.platform_hostname,
68
+ platformNumber: data.platform_number,
69
+ projectId: data.project_id,
70
+ region: data.region,
71
+ status: data.status,
72
+ tags: data.tags,
73
+ updatedAt: unmarshalDate(data.updated_at),
74
+ username: data.username
75
+ };
76
+ };
77
+ const unmarshalNameserver = data => {
78
+ if (!isJSONObject(data)) {
79
+ throw new TypeError(`Unmarshalling the type 'Nameserver' failed as data isn't a dictionary.`);
80
+ }
81
+ return {
82
+ hostname: data.hostname,
83
+ isDefault: data.is_default,
84
+ status: data.status
85
+ };
86
+ };
87
+ const unmarshalOffer = data => {
88
+ if (!isJSONObject(data)) {
89
+ throw new TypeError(`Unmarshalling the type 'Offer' failed as data isn't a dictionary.`);
90
+ }
91
+ return {
92
+ billingOperationPath: data.billing_operation_path,
93
+ id: data.id,
94
+ price: data.price ? unmarshalMoney(data.price) : undefined,
95
+ product: data.product ? unmarshalOfferProduct(data.product) : undefined
96
+ };
97
+ };
98
+ const unmarshalDnsRecords = data => {
99
+ if (!isJSONObject(data)) {
100
+ throw new TypeError(`Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary.`);
101
+ }
102
+ return {
103
+ nameServers: unmarshalArrayOfObject(data.name_servers, unmarshalNameserver),
104
+ records: unmarshalArrayOfObject(data.records, unmarshalDnsRecord),
105
+ status: data.status
106
+ };
107
+ };
108
+ const unmarshalListHostingsResponse = data => {
109
+ if (!isJSONObject(data)) {
110
+ throw new TypeError(`Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary.`);
111
+ }
112
+ return {
113
+ hostings: unmarshalArrayOfObject(data.hostings, unmarshalHosting),
114
+ totalCount: data.total_count
115
+ };
116
+ };
117
+ const unmarshalListOffersResponse = data => {
118
+ if (!isJSONObject(data)) {
119
+ throw new TypeError(`Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`);
120
+ }
121
+ return {
122
+ offers: unmarshalArrayOfObject(data.offers, unmarshalOffer)
123
+ };
124
+ };
125
+ const marshalCreateHostingRequest = (request, defaults) => ({
126
+ domain: request.domain,
127
+ email: request.email,
128
+ offer_id: request.offerId,
129
+ option_ids: request.optionIds,
130
+ project_id: request.projectId ?? defaults.defaultProjectId,
131
+ tags: request.tags
132
+ });
133
+ const marshalUpdateHostingRequest = (request, defaults) => ({
134
+ email: request.email,
135
+ offer_id: request.offerId,
136
+ option_ids: request.optionIds,
137
+ tags: request.tags
138
+ });
139
+
140
+ export { marshalCreateHostingRequest, marshalUpdateHostingRequest, unmarshalDnsRecords, unmarshalHosting, unmarshalListHostingsResponse, unmarshalListOffersResponse };
@@ -0,0 +1,14 @@
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
+
4
+ const ListHostingsRequest = {
5
+ page: {
6
+ greaterThan: 0
7
+ },
8
+ pageSize: {
9
+ greaterThan: 0,
10
+ lessThanOrEqual: 100
11
+ }
12
+ };
13
+
14
+ export { ListHostingsRequest };