@fonoster/sdk 0.6.1 → 0.6.2

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.
Files changed (70) hide show
  1. package/README.md +2301 -169
  2. package/dist/node/Acls.d.ts +150 -0
  3. package/dist/node/Acls.js +227 -0
  4. package/dist/node/Agents.d.ts +163 -0
  5. package/dist/node/Agents.js +211 -0
  6. package/dist/node/ApiKeys.d.ts +120 -0
  7. package/dist/node/ApiKeys.js +178 -0
  8. package/dist/node/Applications.d.ts +31 -27
  9. package/dist/node/Applications.js +30 -26
  10. package/dist/node/Calls.d.ts +109 -0
  11. package/dist/node/Calls.js +165 -0
  12. package/dist/node/Credentials.d.ts +148 -0
  13. package/dist/node/Credentials.js +194 -0
  14. package/dist/node/Domains.d.ts +152 -0
  15. package/dist/node/Domains.js +198 -0
  16. package/dist/node/Numbers.d.ts +152 -0
  17. package/dist/node/Numbers.js +198 -0
  18. package/dist/node/Secrets.d.ts +144 -0
  19. package/dist/node/Secrets.js +190 -0
  20. package/dist/node/Trunks.d.ts +181 -0
  21. package/dist/node/Trunks.js +275 -0
  22. package/dist/node/Users.d.ts +132 -0
  23. package/dist/node/Users.js +169 -0
  24. package/dist/node/Workspaces.d.ts +195 -0
  25. package/dist/node/Workspaces.js +265 -0
  26. package/dist/node/client/AbstractClient.d.ts +16 -2
  27. package/dist/node/client/AbstractClient.js +0 -1
  28. package/dist/node/client/Client.d.ts +8 -0
  29. package/dist/node/client/Client.js +48 -0
  30. package/dist/node/client/types/AclsClient.d.ts +10 -0
  31. package/dist/node/client/types/AgentsClient.d.ts +10 -0
  32. package/dist/node/client/types/AgentsClient.js +2 -0
  33. package/dist/node/client/types/ApplicationsClient.d.ts +10 -0
  34. package/dist/node/client/types/ApplicationsClient.js +2 -0
  35. package/dist/node/client/types/CallsClient.d.ts +8 -0
  36. package/dist/node/client/types/CallsClient.js +2 -0
  37. package/dist/node/client/types/CredentialsClient.d.ts +10 -0
  38. package/dist/node/client/types/CredentialsClient.js +2 -0
  39. package/dist/node/client/types/DomainsClient.d.ts +10 -0
  40. package/dist/node/client/types/DomainsClient.js +2 -0
  41. package/dist/node/client/types/FonosterClient.d.ts +27 -0
  42. package/dist/node/client/types/FonosterClient.js +2 -0
  43. package/dist/node/client/types/IdentityClient.d.ts +24 -0
  44. package/dist/node/client/types/IdentityClient.js +2 -0
  45. package/dist/node/client/types/NumbersClient.d.ts +10 -0
  46. package/dist/node/client/types/NumbersClient.js +2 -0
  47. package/dist/node/client/types/SecretsClient.d.ts +10 -0
  48. package/dist/node/client/types/SecretsClient.js +2 -0
  49. package/dist/node/client/types/TrunksClient.d.ts +10 -0
  50. package/dist/node/client/types/TrunksClient.js +2 -0
  51. package/dist/node/client/types/common.d.ts +4 -0
  52. package/dist/node/client/types/common.js +2 -0
  53. package/dist/node/client/types/index.d.ts +6 -0
  54. package/dist/node/client/types/index.js +40 -0
  55. package/dist/node/generated/node/identity_pb.js +9 -9
  56. package/dist/node/generated/node/trunks_grpc_pb.js +8 -8
  57. package/dist/node/generated/node/trunks_pb.js +25 -25
  58. package/dist/node/generated/web/TrunksServiceClientPb.ts +5 -5
  59. package/dist/node/generated/web/identity_pb.d.ts +5 -5
  60. package/dist/node/generated/web/identity_pb.js +9 -9
  61. package/dist/node/generated/web/trunks_pb.d.ts +9 -9
  62. package/dist/node/generated/web/trunks_pb.js +25 -25
  63. package/dist/node/node.d.ts +11 -0
  64. package/dist/node/node.js +11 -0
  65. package/dist/node/tsconfig.node.tsbuildinfo +1 -1
  66. package/dist/web/fonoster.min.js +1 -1
  67. package/dist/web/index.esm.js +1 -1
  68. package/package.json +3 -3
  69. package/dist/node/client/types.d.ts +0 -26
  70. /package/dist/node/client/{types.js → types/AclsClient.js} +0 -0
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Credentials = void 0;
4
+ const makeRpcRequest_1 = require("./client/makeRpcRequest");
5
+ const credentials_pb_1 = require("./generated/node/credentials_pb");
6
+ /**
7
+ * @classdesc Fonoster Credentials, part of the Fonoster SIP Proxy subsystem,
8
+ * allows you to create, update, retrieve, and delete SIP Credentials for your deployment.
9
+ * Note that an active Fonoster deployment is required.
10
+ *
11
+ * @example
12
+ *
13
+ * const SDK = require("@fonoster/sdk");
14
+ *
15
+ * async function main(request) {
16
+ * const apiKey = "your-api-key";
17
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
18
+ *
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId });
21
+ * await client.loginWithApiKey(apiKey);
22
+ *
23
+ * const credentials = new SDK.Credentials(client);
24
+ * const response = await apiKeys.createCredentials(request);
25
+ *
26
+ * console.log(response); // successful response
27
+ * } catch (e) {
28
+ * console.error(e); // an error occurred
29
+ * }
30
+ * }
31
+ *
32
+ * const request = {
33
+ * name: "My Credentials",
34
+ * username: "myusername",
35
+ * password: "mysecret"
36
+ * };
37
+ *
38
+ * main(request).catch(console.error);
39
+ */
40
+ class Credentials {
41
+ client;
42
+ /**
43
+ * Constructs a new Credentials object.
44
+ *
45
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
46
+ * @see AbstractClient
47
+ * @see FonosterClient
48
+ */
49
+ constructor(client) {
50
+ this.client = client;
51
+ }
52
+ /**
53
+ * Creates a new set of Credentials in the Workspace.
54
+ *
55
+ * @param {CreateCredentialsRequest} request - The request object that contains the necessary information to create a new set of Credentials
56
+ * @param {string} request.name - The name of the Credentials
57
+ * @param {string} request.username - The username of the Credentials
58
+ * @param {string} request.password - The password of the Credentials
59
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Credentials
60
+ * @example
61
+ *
62
+ * const request = {
63
+ * name: "My Credentials",
64
+ * username: "myusername",
65
+ * password: "mysecret"
66
+ * };
67
+ *
68
+ * const credentials = new SDK.Credentials(client); // Existing client object
69
+ *
70
+ * credentials.createCredentials(request)
71
+ * .then(console.log) // successful response
72
+ * .catch(console.error); // an error occurred
73
+ */
74
+ async createCredentials(request) {
75
+ const client = this.client.getCredentialsClient();
76
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
77
+ method: client.createCredentials.bind(client),
78
+ requestPBObjectConstructor: credentials_pb_1.CreateCredentialsRequest,
79
+ metadata: this.client.getMetadata(),
80
+ request
81
+ });
82
+ }
83
+ /**
84
+ * Retrieves an existing set of Credentials in the Workspace.
85
+ *
86
+ * @param {string} ref - The reference of the Credentials to retrieve
87
+ * @return {Promise<Acl>} - The response object that contains the Credentials
88
+ * @example
89
+ *
90
+ * const ref = "00000000-0000-0000-0000-000000000000"
91
+ *
92
+ * const credentials = new SDK.Credentials(client); // Existing client object
93
+ *
94
+ * credentials.getCredentials(ref)
95
+ * .then(console.log) // successful response
96
+ * .catch(console.error); // an error occurred
97
+ */
98
+ async getCredentials(ref) {
99
+ const client = this.client.getCredentialsClient();
100
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
101
+ method: client.getCredentials.bind(client),
102
+ requestPBObjectConstructor: credentials_pb_1.GetCredentialsRequest,
103
+ metadata: this.client.getMetadata(),
104
+ request: { ref }
105
+ });
106
+ }
107
+ /**
108
+ * Updates an existing set of Credentials in the Workspace.
109
+ *
110
+ * @param {UpdateCredentialsRequest} request - The request object that contains the necessary information to update an existing set of Credentials
111
+ * @param {string} request.ref - The reference of the Credentials to update
112
+ * @param {string} request.name - The name of the Credentials
113
+ * @param {string} request.password - The password of the Credentials
114
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Credentials
115
+ * @example
116
+ *
117
+ * const request = {
118
+ * ref: "00000000-0000-0000-0000-000000000000",
119
+ * name: "My Credentials",
120
+ * password: "mysecret"
121
+ * };
122
+ *
123
+ * const credentials = new SDK.Credentials(client); // Existing client object
124
+ *
125
+ * credentials.updateCredentials(request)
126
+ * .then(console.log) // successful response
127
+ * .catch(console.error); // an error occurred
128
+ */
129
+ async updateCredentials(request) {
130
+ const client = this.client.getCredentialsClient();
131
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
132
+ method: client.updateCredentials.bind(client),
133
+ requestPBObjectConstructor: credentials_pb_1.UpdateCredentialsRequest,
134
+ metadata: this.client.getMetadata(),
135
+ request
136
+ });
137
+ }
138
+ /**
139
+ * Retrieves a list of Credentials from a Workspace.
140
+ *
141
+ * @param {ListCredentialsRequest} request - The request object that contains the necessary information to retrieve a list of Credentials
142
+ * @param {number} request.pageSize - The number of Credentials to retrieve
143
+ * @param {string} request.pageToken - The token to retrieve the next page of Credentials
144
+ * @return {Promise<ListCredentialsResponse>} - The response object that contains the list of Credentials
145
+ * @example
146
+ *
147
+ * const request = {
148
+ * pageSize: 10,
149
+ * pageToken: "00000000-0000-0000-0000-000000000000"
150
+ * };
151
+ *
152
+ * const credentials = new SDK.Credentials(client); // Existing client object
153
+ *
154
+ * credentials.listCredentials(request)
155
+ * .then(console.log) // successful response
156
+ * .catch(console.error); // an error occurred
157
+ */
158
+ async listCredentials(request) {
159
+ const client = this.client.getCredentialsClient();
160
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
161
+ method: client.listCredentials.bind(client),
162
+ requestPBObjectConstructor: credentials_pb_1.ListCredentialsRequest,
163
+ metadata: this.client.getMetadata(),
164
+ request,
165
+ repeatableObjectMapping: [["itemsList", credentials_pb_1.Credentials]]
166
+ });
167
+ }
168
+ /**
169
+ * Deletes an existing set of Credentials from Fonoster.
170
+ * Note that this operation is irreversible.
171
+ *
172
+ * @param {string} ref - The reference of the Credentials to delete
173
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Credentials
174
+ * @example
175
+ *
176
+ * const ref = "00000000-0000-0000-0000-000000000000"
177
+ *
178
+ * const credentials = new SDK.Credentials(client); // Existing client object
179
+ *
180
+ * credentials.deleteCredentials(ref)
181
+ * .then(console.log) // successful response
182
+ * .catch(console.error); // an error occurred
183
+ */
184
+ async deleteCredentials(ref) {
185
+ const applicationsClient = this.client.getCredentialsClient();
186
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
187
+ method: applicationsClient.deleteCredentials.bind(applicationsClient),
188
+ requestPBObjectConstructor: credentials_pb_1.DeleteCredentialsRequest,
189
+ metadata: this.client.getMetadata(),
190
+ request: { ref }
191
+ });
192
+ }
193
+ }
194
+ exports.Credentials = Credentials;
@@ -0,0 +1,152 @@
1
+ import { BaseApiObject, CreateDomainRequest, Domain, ListDomainsRequest, ListDomainsResponse, UpdateDomainRequest } from "@fonoster/types";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Domains, part of the Fonoster SIP Proxy subsystem,
5
+ * allows you to create, update, retrieve, and delete SIP Domain for your deployment.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * async function main(request) {
13
+ * const apiKey = "your-api-key";
14
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
15
+ *
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId });
18
+ * await client.loginWithApiKey(apiKey);
19
+ *
20
+ * const domains = new SDK.Domains(client);
21
+ * const response = await domains.createDomain(request);
22
+ *
23
+ * console.log(response); // successful response
24
+ * } catch (e) {
25
+ * console.error(e); // an error occurred
26
+ * }
27
+ * }
28
+ *
29
+ * const request = {
30
+ * name: "My Domain",
31
+ * domainUri: "sip.project.fonoster.io"
32
+ * };
33
+ *
34
+ * main(request).catch(console.error);
35
+ */
36
+ declare class Domains {
37
+ private client;
38
+ /**
39
+ * Constructs a new Domains object.
40
+ *
41
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
42
+ * @see AbstractClient
43
+ * @see FonosterClient
44
+ */
45
+ constructor(client: FonosterClient);
46
+ /**
47
+ * Creates a new Domain in the Workspace.
48
+ *
49
+ * @param {CreateDomainRequest} request - The request object that contains the necessary information to create a new Domain
50
+ * @param {string} request.name - The name of the Domain
51
+ * @param {string} request.domainUri - The URI of the Domain
52
+ * @param {AccessControlListRef} request.accessControlListRef - The reference to the Access Control List (ACL) to associate with the Domain
53
+ * @param {EgressPolicy[]} request.egressPolicy - The egress policy of the Domain
54
+ * @param {string} request.egressPolicy[].rule - A regular expression that defines which calls to send to the PSTN
55
+ * @param {string} request.egressPolicy[].numberRef - The Number that will be used to send the call to the PSTN
56
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Domain
57
+ * @example
58
+ *
59
+ * const request = {
60
+ * name: "My Domain",
61
+ * domainUri: "sip.project.fonoster.io"
62
+ * };
63
+ *
64
+ * const domains = new SDK.Domains(client); // Existing client object
65
+ *
66
+ * domains.createDomain(request)
67
+ * .then(console.log) // successful response
68
+ * .catch(console.error); // an error occurred
69
+ */
70
+ createDomain(request: CreateDomainRequest): Promise<BaseApiObject>;
71
+ /**
72
+ * Retrieves an existing Domain in the Workspace.
73
+ *
74
+ * @param {string} ref - The reference of the Domain to retrieve
75
+ * @return {Promise<Acl>} - The response object that contains the Domain
76
+ * @example
77
+ *
78
+ * const ref = "00000000-0000-0000-0000-000000000000"
79
+ *
80
+ * const domains = new SDK.Domains(client); // Existing client object
81
+ *
82
+ * domains.getDomain(ref)
83
+ * .then(console.log) // successful response
84
+ * .catch(console.error); // an error occurred
85
+ */
86
+ getDomain(ref: string): Promise<Domain>;
87
+ /**
88
+ * Updates an existing Domain in the Workspace.
89
+ *
90
+ * @param {UpdateDomainRequest} request - The request object that contains the necessary information to update an existing Domain
91
+ * @param {string} request.ref - The reference of the Domain to update
92
+ * @param {string} request.name - The name of the Domain
93
+ * @param {string} request.domainUri - The URI of the Domain
94
+ * @param {AccessControlListRef} request.accessControlListRef - The reference to the Access Control List (ACL) to associate with the Domain
95
+ * @param {EgressPolicy[]} request.egressPolicy - The egress policy of the Domain
96
+ * @param {string} request.egressPolicy[].rule - A regular expression that defines which calls to send to the PSTN
97
+ * @param {string} request.egressPolicy[].numberRef - The Number that will be used to send the call to the PSTN
98
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Domain
99
+ * @example
100
+ *
101
+ * const request = {
102
+ * ref: "00000000-0000-0000-0000-000000000000",
103
+ * accessControlListRef: "00000000-0000-0000-0000-000000000001"
104
+ * };
105
+ *
106
+ * const domains = new SDK.Domains(client); // Existing client object
107
+ *
108
+ * domains.updateDomain(request)
109
+ * .then(console.log) // successful response
110
+ * .catch(console.error); // an error occurred
111
+ */
112
+ updateDomain(request: UpdateDomainRequest): Promise<BaseApiObject>;
113
+ /**
114
+ * Retrieves a list of Domains from a Workspace.
115
+ *
116
+ * @param {ListDomainsRequest} request - The request object that contains the necessary information to retrieve a list of Domains
117
+ * @param {number} request.pageSize - The number of Domains to retrieve
118
+ * @param {string} request.pageToken - The token to retrieve the next page of Domains
119
+ * @return {Promise<ListDomainsResponse>} - The response object that contains the list of Domains
120
+ * @example
121
+ *
122
+ * const request = {
123
+ * pageSize: 10,
124
+ * pageToken: "00000000-0000-0000-0000-000000000000"
125
+ * };
126
+ *
127
+ * const domains = new SDK.Domains(client); // Existing client object
128
+ *
129
+ * domains.listDomains(request)
130
+ * .then(console.log) // successful response
131
+ * .catch(console.error); // an error occurred
132
+ */
133
+ listDomains(request: ListDomainsRequest): Promise<ListDomainsResponse>;
134
+ /**
135
+ * Deletes an existing Domain from Fonoster.
136
+ * Note that this operation is irreversible.
137
+ *
138
+ * @param {string} ref - The reference of the Domain to delete
139
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Domain
140
+ * @example
141
+ *
142
+ * const ref = "00000000-0000-0000-0000-000000000000"
143
+ *
144
+ * const domains = new SDK.Domains(client); // Existing client object
145
+ *
146
+ * domains.deleteDomain(ref)
147
+ * .then(console.log) // successful response
148
+ * .catch(console.error); // an error occurred
149
+ */
150
+ deleteDomain(ref: string): Promise<BaseApiObject>;
151
+ }
152
+ export { Domains };
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Domains = void 0;
4
+ const makeRpcRequest_1 = require("./client/makeRpcRequest");
5
+ const domains_pb_1 = require("./generated/node/domains_pb");
6
+ /**
7
+ * @classdesc Fonoster Domains, part of the Fonoster SIP Proxy subsystem,
8
+ * allows you to create, update, retrieve, and delete SIP Domain for your deployment.
9
+ * Note that an active Fonoster deployment is required.
10
+ *
11
+ * @example
12
+ *
13
+ * const SDK = require("@fonoster/sdk");
14
+ *
15
+ * async function main(request) {
16
+ * const apiKey = "your-api-key";
17
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
18
+ *
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId });
21
+ * await client.loginWithApiKey(apiKey);
22
+ *
23
+ * const domains = new SDK.Domains(client);
24
+ * const response = await domains.createDomain(request);
25
+ *
26
+ * console.log(response); // successful response
27
+ * } catch (e) {
28
+ * console.error(e); // an error occurred
29
+ * }
30
+ * }
31
+ *
32
+ * const request = {
33
+ * name: "My Domain",
34
+ * domainUri: "sip.project.fonoster.io"
35
+ * };
36
+ *
37
+ * main(request).catch(console.error);
38
+ */
39
+ class Domains {
40
+ client;
41
+ /**
42
+ * Constructs a new Domains object.
43
+ *
44
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
45
+ * @see AbstractClient
46
+ * @see FonosterClient
47
+ */
48
+ constructor(client) {
49
+ this.client = client;
50
+ }
51
+ /**
52
+ * Creates a new Domain in the Workspace.
53
+ *
54
+ * @param {CreateDomainRequest} request - The request object that contains the necessary information to create a new Domain
55
+ * @param {string} request.name - The name of the Domain
56
+ * @param {string} request.domainUri - The URI of the Domain
57
+ * @param {AccessControlListRef} request.accessControlListRef - The reference to the Access Control List (ACL) to associate with the Domain
58
+ * @param {EgressPolicy[]} request.egressPolicy - The egress policy of the Domain
59
+ * @param {string} request.egressPolicy[].rule - A regular expression that defines which calls to send to the PSTN
60
+ * @param {string} request.egressPolicy[].numberRef - The Number that will be used to send the call to the PSTN
61
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Domain
62
+ * @example
63
+ *
64
+ * const request = {
65
+ * name: "My Domain",
66
+ * domainUri: "sip.project.fonoster.io"
67
+ * };
68
+ *
69
+ * const domains = new SDK.Domains(client); // Existing client object
70
+ *
71
+ * domains.createDomain(request)
72
+ * .then(console.log) // successful response
73
+ * .catch(console.error); // an error occurred
74
+ */
75
+ async createDomain(request) {
76
+ const client = this.client.getDomainsClient();
77
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
78
+ method: client.createDomain.bind(client),
79
+ requestPBObjectConstructor: domains_pb_1.CreateDomainRequest,
80
+ metadata: this.client.getMetadata(),
81
+ request
82
+ });
83
+ }
84
+ /**
85
+ * Retrieves an existing Domain in the Workspace.
86
+ *
87
+ * @param {string} ref - The reference of the Domain to retrieve
88
+ * @return {Promise<Acl>} - The response object that contains the Domain
89
+ * @example
90
+ *
91
+ * const ref = "00000000-0000-0000-0000-000000000000"
92
+ *
93
+ * const domains = new SDK.Domains(client); // Existing client object
94
+ *
95
+ * domains.getDomain(ref)
96
+ * .then(console.log) // successful response
97
+ * .catch(console.error); // an error occurred
98
+ */
99
+ async getDomain(ref) {
100
+ const client = this.client.getDomainsClient();
101
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
102
+ method: client.getDomain.bind(client),
103
+ requestPBObjectConstructor: domains_pb_1.GetDomainRequest,
104
+ metadata: this.client.getMetadata(),
105
+ request: { ref }
106
+ });
107
+ }
108
+ /**
109
+ * Updates an existing Domain in the Workspace.
110
+ *
111
+ * @param {UpdateDomainRequest} request - The request object that contains the necessary information to update an existing Domain
112
+ * @param {string} request.ref - The reference of the Domain to update
113
+ * @param {string} request.name - The name of the Domain
114
+ * @param {string} request.domainUri - The URI of the Domain
115
+ * @param {AccessControlListRef} request.accessControlListRef - The reference to the Access Control List (ACL) to associate with the Domain
116
+ * @param {EgressPolicy[]} request.egressPolicy - The egress policy of the Domain
117
+ * @param {string} request.egressPolicy[].rule - A regular expression that defines which calls to send to the PSTN
118
+ * @param {string} request.egressPolicy[].numberRef - The Number that will be used to send the call to the PSTN
119
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Domain
120
+ * @example
121
+ *
122
+ * const request = {
123
+ * ref: "00000000-0000-0000-0000-000000000000",
124
+ * accessControlListRef: "00000000-0000-0000-0000-000000000001"
125
+ * };
126
+ *
127
+ * const domains = new SDK.Domains(client); // Existing client object
128
+ *
129
+ * domains.updateDomain(request)
130
+ * .then(console.log) // successful response
131
+ * .catch(console.error); // an error occurred
132
+ */
133
+ async updateDomain(request) {
134
+ const client = this.client.getDomainsClient();
135
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
136
+ method: client.updateDomain.bind(client),
137
+ requestPBObjectConstructor: domains_pb_1.UpdateDomainRequest,
138
+ metadata: this.client.getMetadata(),
139
+ request
140
+ });
141
+ }
142
+ /**
143
+ * Retrieves a list of Domains from a Workspace.
144
+ *
145
+ * @param {ListDomainsRequest} request - The request object that contains the necessary information to retrieve a list of Domains
146
+ * @param {number} request.pageSize - The number of Domains to retrieve
147
+ * @param {string} request.pageToken - The token to retrieve the next page of Domains
148
+ * @return {Promise<ListDomainsResponse>} - The response object that contains the list of Domains
149
+ * @example
150
+ *
151
+ * const request = {
152
+ * pageSize: 10,
153
+ * pageToken: "00000000-0000-0000-0000-000000000000"
154
+ * };
155
+ *
156
+ * const domains = new SDK.Domains(client); // Existing client object
157
+ *
158
+ * domains.listDomains(request)
159
+ * .then(console.log) // successful response
160
+ * .catch(console.error); // an error occurred
161
+ */
162
+ async listDomains(request) {
163
+ const client = this.client.getDomainsClient();
164
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
165
+ method: client.listDomains.bind(client),
166
+ requestPBObjectConstructor: domains_pb_1.ListDomainsRequest,
167
+ metadata: this.client.getMetadata(),
168
+ request,
169
+ repeatableObjectMapping: [["itemsList", domains_pb_1.Domain]]
170
+ });
171
+ }
172
+ /**
173
+ * Deletes an existing Domain from Fonoster.
174
+ * Note that this operation is irreversible.
175
+ *
176
+ * @param {string} ref - The reference of the Domain to delete
177
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Domain
178
+ * @example
179
+ *
180
+ * const ref = "00000000-0000-0000-0000-000000000000"
181
+ *
182
+ * const domains = new SDK.Domains(client); // Existing client object
183
+ *
184
+ * domains.deleteDomain(ref)
185
+ * .then(console.log) // successful response
186
+ * .catch(console.error); // an error occurred
187
+ */
188
+ async deleteDomain(ref) {
189
+ const applicationsClient = this.client.getDomainsClient();
190
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
191
+ method: applicationsClient.deleteDomain.bind(applicationsClient),
192
+ requestPBObjectConstructor: domains_pb_1.DeleteDomainRequest,
193
+ metadata: this.client.getMetadata(),
194
+ request: { ref }
195
+ });
196
+ }
197
+ }
198
+ exports.Domains = Domains;
@@ -0,0 +1,152 @@
1
+ import { BaseApiObject, CreateNumberRequest, INumber, ListNumbersRequest, ListNumbersResponse, UpdateNumberRequest } from "@fonoster/types";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Numbers, part of the Fonoster SIP Proxy subsystem,
5
+ * allows you to create, update, retrieve, and delete SIP Number for your deployment.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * async function main(request) {
13
+ * const apiKey = "your-api-key";
14
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
15
+ *
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId });
18
+ * await client.loginWithApiKey(apiKey);
19
+ *
20
+ * const numbers = new SDK.Numbers(client);
21
+ * const response = await numbers.createNumber(request);
22
+ *
23
+ * console.log(response); // successful response
24
+ * } catch (e) {
25
+ * console.error(e); // an error occurred
26
+ * }
27
+ * }
28
+ *
29
+ * const request = {
30
+ * name: "My Number",
31
+ * telUrl: "tel:+17853178070",
32
+ * city: "Asheville",
33
+ * country: "United States",
34
+ * countryIsoCode: "US"
35
+ * };
36
+ *
37
+ * main(request).catch(console.error);
38
+ */
39
+ declare class Numbers {
40
+ private client;
41
+ /**
42
+ * Constructs a new Numbers object.
43
+ *
44
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
45
+ * @see AbstractClient
46
+ * @see FonosterClient
47
+ */
48
+ constructor(client: FonosterClient);
49
+ /**
50
+ * Creates a new Number in the Workspace.
51
+ *
52
+ * @param {CreateNumberRequest} request - The request object that contains the necessary information to create a new Number
53
+ * @param {string} request.name - The name of the Number
54
+ * @param {string} request.telUrl - The telUrl of the Number
55
+ * @param {string} request.city - The city of the Number
56
+ * @param {string} request.country - The country of the Number
57
+ * @param {string} request.countryIsoCode - The countryIsoCode of the Number
58
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Number
59
+ * @example
60
+ *
61
+ * const request = {
62
+ * name: "My Number",
63
+ * telUrl: "tel:+17853178070",
64
+ * city: "Asheville",
65
+ * country: "United States",
66
+ * countryIsoCode: "US"
67
+ * };
68
+ *
69
+ * const numbers = new SDK.Numbers(client); // Existing client object
70
+ *
71
+ * numbers.createNumber(request)
72
+ * .then(console.log) // successful response
73
+ * .catch(console.error); // an error occurred
74
+ */
75
+ createNumber(request: CreateNumberRequest): Promise<BaseApiObject>;
76
+ /**
77
+ * Retrieves an existing Number in the Workspace.
78
+ *
79
+ * @param {string} ref - The reference of the Number to retrieve
80
+ * @return {Promise<Acl>} - The response object that contains the Number
81
+ * @example
82
+ *
83
+ * const ref = "00000000-0000-0000-0000-000000000000"
84
+ *
85
+ * const numbers = new SDK.Numbers(client); // Existing client object
86
+ *
87
+ * numbers.getNumber(ref)
88
+ * .then(console.log) // successful response
89
+ * .catch(console.error); // an error occurred
90
+ */
91
+ getNumber(ref: string): Promise<INumber>;
92
+ /**
93
+ * Updates an existing Number in the Workspace.
94
+ *
95
+ * @param {UpdateNumberRequest} request - The request object that contains the necessary information to update an existing Number
96
+ * @param {string} request.ref - The reference of the Number to update
97
+ * @param {string} request.name - The name of the Number
98
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Number
99
+ * @example
100
+ *
101
+ * const request = {
102
+ * ref: "00000000-0000-0000-0000-000000000000",
103
+ * name: "My Number"
104
+ * };
105
+ *
106
+ * const numbers = new SDK.Numbers(client); // Existing client object
107
+ *
108
+ * numbers.updateNumber(request)
109
+ * .then(console.log) // successful response
110
+ * .catch(console.error); // an error occurred
111
+ */
112
+ updateNumber(request: UpdateNumberRequest): Promise<BaseApiObject>;
113
+ /**
114
+ * Retrieves a list of Numbers from a Workspace.
115
+ *
116
+ * @param {ListNumbersRequest} request - The request object that contains the necessary information to retrieve a list of Numbers
117
+ * @param {number} request.pageSize - The number of Numbers to retrieve
118
+ * @param {string} request.pageToken - The token to retrieve the next page of Numbers
119
+ * @return {Promise<ListNumbersResponse>} - The response object that contains the list of Numbers
120
+ * @example
121
+ *
122
+ * const request = {
123
+ * pageSize: 10,
124
+ * pageToken: "00000000-0000-0000-0000-000000000000"
125
+ * };
126
+ *
127
+ * const numbers = new SDK.Numbers(client); // Existing client object
128
+ *
129
+ * numbers.listNumbers(request)
130
+ * .then(console.log) // successful response
131
+ * .catch(console.error); // an error occurred
132
+ */
133
+ listNumbers(request: ListNumbersRequest): Promise<ListNumbersResponse>;
134
+ /**
135
+ * Deletes an existing Number from Fonoster.
136
+ * Note that this operation is irreversible.
137
+ *
138
+ * @param {string} ref - The reference of the Number to delete
139
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Number
140
+ * @example
141
+ *
142
+ * const ref = "00000000-0000-0000-0000-000000000000"
143
+ *
144
+ * const numbers = new SDK.Numbers(client); // Existing client object
145
+ *
146
+ * numbers.deleteDomain(ref)
147
+ * .then(console.log) // successful response
148
+ * .catch(console.error); // an error occurred
149
+ */
150
+ deleteNumber(ref: string): Promise<BaseApiObject>;
151
+ }
152
+ export { Numbers };