@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.
- package/README.md +2301 -169
- package/dist/node/Acls.d.ts +150 -0
- package/dist/node/Acls.js +227 -0
- package/dist/node/Agents.d.ts +163 -0
- package/dist/node/Agents.js +211 -0
- package/dist/node/ApiKeys.d.ts +120 -0
- package/dist/node/ApiKeys.js +178 -0
- package/dist/node/Applications.d.ts +31 -27
- package/dist/node/Applications.js +30 -26
- package/dist/node/Calls.d.ts +109 -0
- package/dist/node/Calls.js +165 -0
- package/dist/node/Credentials.d.ts +148 -0
- package/dist/node/Credentials.js +194 -0
- package/dist/node/Domains.d.ts +152 -0
- package/dist/node/Domains.js +198 -0
- package/dist/node/Numbers.d.ts +152 -0
- package/dist/node/Numbers.js +198 -0
- package/dist/node/Secrets.d.ts +144 -0
- package/dist/node/Secrets.js +190 -0
- package/dist/node/Trunks.d.ts +181 -0
- package/dist/node/Trunks.js +275 -0
- package/dist/node/Users.d.ts +132 -0
- package/dist/node/Users.js +169 -0
- package/dist/node/Workspaces.d.ts +195 -0
- package/dist/node/Workspaces.js +265 -0
- package/dist/node/client/AbstractClient.d.ts +16 -2
- package/dist/node/client/AbstractClient.js +0 -1
- package/dist/node/client/Client.d.ts +8 -0
- package/dist/node/client/Client.js +48 -0
- package/dist/node/client/types/AclsClient.d.ts +10 -0
- package/dist/node/client/types/AgentsClient.d.ts +10 -0
- package/dist/node/client/types/AgentsClient.js +2 -0
- package/dist/node/client/types/ApplicationsClient.d.ts +10 -0
- package/dist/node/client/types/ApplicationsClient.js +2 -0
- package/dist/node/client/types/CallsClient.d.ts +8 -0
- package/dist/node/client/types/CallsClient.js +2 -0
- package/dist/node/client/types/CredentialsClient.d.ts +10 -0
- package/dist/node/client/types/CredentialsClient.js +2 -0
- package/dist/node/client/types/DomainsClient.d.ts +10 -0
- package/dist/node/client/types/DomainsClient.js +2 -0
- package/dist/node/client/types/FonosterClient.d.ts +27 -0
- package/dist/node/client/types/FonosterClient.js +2 -0
- package/dist/node/client/types/IdentityClient.d.ts +24 -0
- package/dist/node/client/types/IdentityClient.js +2 -0
- package/dist/node/client/types/NumbersClient.d.ts +10 -0
- package/dist/node/client/types/NumbersClient.js +2 -0
- package/dist/node/client/types/SecretsClient.d.ts +10 -0
- package/dist/node/client/types/SecretsClient.js +2 -0
- package/dist/node/client/types/TrunksClient.d.ts +10 -0
- package/dist/node/client/types/TrunksClient.js +2 -0
- package/dist/node/client/types/common.d.ts +4 -0
- package/dist/node/client/types/common.js +2 -0
- package/dist/node/client/types/index.d.ts +6 -0
- package/dist/node/client/types/index.js +40 -0
- package/dist/node/generated/node/identity_pb.js +9 -9
- package/dist/node/generated/node/trunks_grpc_pb.js +8 -8
- package/dist/node/generated/node/trunks_pb.js +25 -25
- package/dist/node/generated/web/TrunksServiceClientPb.ts +5 -5
- package/dist/node/generated/web/identity_pb.d.ts +5 -5
- package/dist/node/generated/web/identity_pb.js +9 -9
- package/dist/node/generated/web/trunks_pb.d.ts +9 -9
- package/dist/node/generated/web/trunks_pb.js +25 -25
- package/dist/node/node.d.ts +11 -0
- package/dist/node/node.js +11 -0
- package/dist/node/tsconfig.node.tsbuildinfo +1 -1
- package/dist/web/fonoster.min.js +1 -1
- package/dist/web/index.esm.js +1 -1
- package/package.json +3 -3
- package/dist/node/client/types.d.ts +0 -26
- /package/dist/node/client/{types.js → types/AclsClient.js} +0 -0
|
@@ -13,6 +13,23 @@ const utils_1 = require("./utils");
|
|
|
13
13
|
*
|
|
14
14
|
* const SDK = require("@fonoster/sdk");
|
|
15
15
|
*
|
|
16
|
+
* async function main(request) {
|
|
17
|
+
* const apiKey = "your-api-key";
|
|
18
|
+
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
19
|
+
*
|
|
20
|
+
* try {
|
|
21
|
+
* const client = SDK.Client({ accessKeyId });
|
|
22
|
+
* await client.loginWithApiKey(apiKey);
|
|
23
|
+
*
|
|
24
|
+
* const apps = new SDK.Applications(client);
|
|
25
|
+
* const response = await apps.createApplication(request);
|
|
26
|
+
*
|
|
27
|
+
* console.log(response); // successful response
|
|
28
|
+
* } catch (e) {
|
|
29
|
+
* console.error(e); // an error occurred
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
16
33
|
* const request = {
|
|
17
34
|
* name: "My application",
|
|
18
35
|
* type: "PROGRAMMABLE_VOICE",
|
|
@@ -40,18 +57,7 @@ const utils_1 = require("./utils");
|
|
|
40
57
|
* }
|
|
41
58
|
* };
|
|
42
59
|
*
|
|
43
|
-
*
|
|
44
|
-
* const password = "changeme";
|
|
45
|
-
* const accessKeyId = "WO00000000000000000000000000000000";
|
|
46
|
-
*
|
|
47
|
-
* const client = new SDK.Client({ accessKeyId });
|
|
48
|
-
*
|
|
49
|
-
* client.login(username, password)
|
|
50
|
-
* .then(async () => {
|
|
51
|
-
* const apps = new SDK.Applications(client);
|
|
52
|
-
* const result = await apps.createApplication(request);
|
|
53
|
-
* console.log(result); // successful response
|
|
54
|
-
* }).catch(console.error); // an error occurred
|
|
60
|
+
* main(request).catch(console.error);
|
|
55
61
|
*/
|
|
56
62
|
class Applications {
|
|
57
63
|
client;
|
|
@@ -135,19 +141,17 @@ class Applications {
|
|
|
135
141
|
});
|
|
136
142
|
}
|
|
137
143
|
/**
|
|
138
|
-
* Retrieves an existing
|
|
144
|
+
* Retrieves an existing Application in the Workspace.
|
|
139
145
|
*
|
|
140
|
-
* @param {string} ref - The reference of the
|
|
141
|
-
* @return {Promise<Application>} - The response object that contains the
|
|
146
|
+
* @param {string} ref - The reference of the Application to retrieve
|
|
147
|
+
* @return {Promise<Application>} - The response object that contains the Application information
|
|
142
148
|
* @example
|
|
143
149
|
*
|
|
144
|
-
* const
|
|
145
|
-
* ref: "00000000-0000-0000-0000-000000000000"
|
|
146
|
-
* };
|
|
150
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
147
151
|
*
|
|
148
152
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
149
153
|
*
|
|
150
|
-
* apps.getApplication(
|
|
154
|
+
* apps.getApplication(ref)
|
|
151
155
|
* .then(console.log) // successful response
|
|
152
156
|
* .catch(console.error); // an error occurred
|
|
153
157
|
*/
|
|
@@ -209,12 +213,12 @@ class Applications {
|
|
|
209
213
|
});
|
|
210
214
|
}
|
|
211
215
|
/**
|
|
212
|
-
* Retrieves a list of
|
|
216
|
+
* Retrieves a list of Applications from Fonoster.
|
|
213
217
|
*
|
|
214
|
-
* @param {ListApplicationsRequest} request - The request object that contains the necessary information to retrieve a list of
|
|
215
|
-
* @param {number} request.pageSize - The number of
|
|
216
|
-
* @param {string} request.pageToken - The token to retrieve the next page of
|
|
217
|
-
* @return {Promise<ListApplicationsResponse>} - The response object that contains the list of
|
|
218
|
+
* @param {ListApplicationsRequest} request - The request object that contains the necessary information to retrieve a list of Applications
|
|
219
|
+
* @param {number} request.pageSize - The number of Applications to retrieve
|
|
220
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Applications
|
|
221
|
+
* @return {Promise<ListApplicationsResponse>} - The response object that contains the list of Applications
|
|
218
222
|
* @example
|
|
219
223
|
*
|
|
220
224
|
* const request = {
|
|
@@ -239,10 +243,10 @@ class Applications {
|
|
|
239
243
|
});
|
|
240
244
|
}
|
|
241
245
|
/**
|
|
242
|
-
* Deletes an existing
|
|
246
|
+
* Deletes an existing Application from Fonoster.
|
|
243
247
|
* Note that this operation is irreversible.
|
|
244
248
|
*
|
|
245
|
-
* @param {string} ref - The reference of the
|
|
249
|
+
* @param {string} ref - The reference of the Application to delete
|
|
246
250
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted application
|
|
247
251
|
* @example
|
|
248
252
|
*
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CallDetailRecord, CreateCallRequest, CreateCallResponse, ListCallsRequest, ListCallsResponse } from "@fonoster/types";
|
|
2
|
+
import { FonosterClient } from "./client/types";
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Fonoster Calls, part of the Fonoster Media subsystem,
|
|
5
|
+
* allows you to create, list, and track calls in 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 username = "admin";
|
|
14
|
+
* const password = "yourpassword";
|
|
15
|
+
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
16
|
+
*
|
|
17
|
+
* try {
|
|
18
|
+
* const client = SDK.Client({ accessKeyId });
|
|
19
|
+
* await client.login({ username, password });
|
|
20
|
+
*
|
|
21
|
+
* const calls = new SDK.Calls(client);
|
|
22
|
+
* const response = await apiKeys.createCall(request);
|
|
23
|
+
*
|
|
24
|
+
* console.log(response); // successful response
|
|
25
|
+
* } catch (e) {
|
|
26
|
+
* console.error(e); // an error occurred
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* const request = {
|
|
31
|
+
* from: "8287854037",
|
|
32
|
+
* to: "+17853178070",
|
|
33
|
+
* appRef: "00000000-0000-0000-0000-000000000000"
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* main(request).catch(console.error);
|
|
37
|
+
*/
|
|
38
|
+
declare class Calls {
|
|
39
|
+
private client;
|
|
40
|
+
/**
|
|
41
|
+
* Constructs a new Calls object.
|
|
42
|
+
*
|
|
43
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
44
|
+
* @see AbstractClient
|
|
45
|
+
* @see FonosterClient
|
|
46
|
+
*/
|
|
47
|
+
constructor(client: FonosterClient);
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new Call in the Workspace.
|
|
50
|
+
*
|
|
51
|
+
* @param {CreateCallRequest} request - The request object that contains the necessary information to create a new Call
|
|
52
|
+
* @param {string} request.from - The number that originated the call
|
|
53
|
+
* @param {string} request.to - The number that received the call
|
|
54
|
+
* @param {string} request.appRef - The reference of the App that will handle the call
|
|
55
|
+
* @return {Promise<CreateCallResponse>} - The response object that contains the reference to the created Call
|
|
56
|
+
* @example
|
|
57
|
+
*
|
|
58
|
+
* const request = {
|
|
59
|
+
* from: "8287854037",
|
|
60
|
+
* to: "+17853178070",
|
|
61
|
+
* appRef: "00000000-0000-0000-0000-000000000000"
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
65
|
+
*
|
|
66
|
+
* calls.createCall(request)
|
|
67
|
+
* .then(console.log) // successful response
|
|
68
|
+
* .catch(console.error); // an error occurred
|
|
69
|
+
*/
|
|
70
|
+
createCall(request: CreateCallRequest): Promise<CreateCallResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves an existing Call in the Workspace.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} ref - The reference of the Call to retrieve
|
|
75
|
+
* @return {Promise<Acl>} - The response object that contains the Call detail
|
|
76
|
+
* @example
|
|
77
|
+
*
|
|
78
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
79
|
+
*
|
|
80
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
81
|
+
*
|
|
82
|
+
* calls.getCall(ref)
|
|
83
|
+
* .then(console.log) // successful response
|
|
84
|
+
* .catch(console.error); // an error occurred
|
|
85
|
+
*/
|
|
86
|
+
getCall(ref: string): Promise<CallDetailRecord>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a list of Calls from a Workspace.
|
|
89
|
+
*
|
|
90
|
+
* @param {ListCallsRequest} request - The request object that contains the necessary information to retrieve a list of Calls
|
|
91
|
+
* @param {number} request.pageSize - The number of Calls to retrieve
|
|
92
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Calls
|
|
93
|
+
* @return {Promise<ListCallsResponse>} - The response object that contains the list of Calls
|
|
94
|
+
* @example
|
|
95
|
+
*
|
|
96
|
+
* const request = {
|
|
97
|
+
* pageSize: 10,
|
|
98
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
99
|
+
* };
|
|
100
|
+
*
|
|
101
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
102
|
+
*
|
|
103
|
+
* calls.listCalls(request)
|
|
104
|
+
* .then(console.log) // successful response
|
|
105
|
+
* .catch(console.error); // an error occurred
|
|
106
|
+
*/
|
|
107
|
+
listCalls(request: ListCallsRequest): Promise<ListCallsResponse>;
|
|
108
|
+
}
|
|
109
|
+
export { Calls };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Calls = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const types_1 = require("@fonoster/types");
|
|
23
|
+
const makeRpcRequest_1 = require("./client/makeRpcRequest");
|
|
24
|
+
const calls_pb_1 = require("./generated/node/calls_pb");
|
|
25
|
+
/**
|
|
26
|
+
* @classdesc Fonoster Calls, part of the Fonoster Media subsystem,
|
|
27
|
+
* allows you to create, list, and track calls in your deployment.
|
|
28
|
+
* Note that an active Fonoster deployment is required.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* const SDK = require("@fonoster/sdk");
|
|
33
|
+
*
|
|
34
|
+
* async function main(request) {
|
|
35
|
+
* const username = "admin";
|
|
36
|
+
* const password = "yourpassword";
|
|
37
|
+
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
38
|
+
*
|
|
39
|
+
* try {
|
|
40
|
+
* const client = SDK.Client({ accessKeyId });
|
|
41
|
+
* await client.login({ username, password });
|
|
42
|
+
*
|
|
43
|
+
* const calls = new SDK.Calls(client);
|
|
44
|
+
* const response = await apiKeys.createCall(request);
|
|
45
|
+
*
|
|
46
|
+
* console.log(response); // successful response
|
|
47
|
+
* } catch (e) {
|
|
48
|
+
* console.error(e); // an error occurred
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* const request = {
|
|
53
|
+
* from: "8287854037",
|
|
54
|
+
* to: "+17853178070",
|
|
55
|
+
* appRef: "00000000-0000-0000-0000-000000000000"
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* main(request).catch(console.error);
|
|
59
|
+
*/
|
|
60
|
+
class Calls {
|
|
61
|
+
client;
|
|
62
|
+
/**
|
|
63
|
+
* Constructs a new Calls object.
|
|
64
|
+
*
|
|
65
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
66
|
+
* @see AbstractClient
|
|
67
|
+
* @see FonosterClient
|
|
68
|
+
*/
|
|
69
|
+
constructor(client) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new Call in the Workspace.
|
|
74
|
+
*
|
|
75
|
+
* @param {CreateCallRequest} request - The request object that contains the necessary information to create a new Call
|
|
76
|
+
* @param {string} request.from - The number that originated the call
|
|
77
|
+
* @param {string} request.to - The number that received the call
|
|
78
|
+
* @param {string} request.appRef - The reference of the App that will handle the call
|
|
79
|
+
* @return {Promise<CreateCallResponse>} - The response object that contains the reference to the created Call
|
|
80
|
+
* @example
|
|
81
|
+
*
|
|
82
|
+
* const request = {
|
|
83
|
+
* from: "8287854037",
|
|
84
|
+
* to: "+17853178070",
|
|
85
|
+
* appRef: "00000000-0000-0000-0000-000000000000"
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
89
|
+
*
|
|
90
|
+
* calls.createCall(request)
|
|
91
|
+
* .then(console.log) // successful response
|
|
92
|
+
* .catch(console.error); // an error occurred
|
|
93
|
+
*/
|
|
94
|
+
async createCall(request) {
|
|
95
|
+
const client = this.client.getCallsClient();
|
|
96
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
97
|
+
method: client.createCall.bind(client),
|
|
98
|
+
requestPBObjectConstructor: calls_pb_1.CreateCallRequest,
|
|
99
|
+
metadata: this.client.getMetadata(),
|
|
100
|
+
request,
|
|
101
|
+
enumMapping: [["type", types_1.CallType]]
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves an existing Call in the Workspace.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} ref - The reference of the Call to retrieve
|
|
108
|
+
* @return {Promise<Acl>} - The response object that contains the Call detail
|
|
109
|
+
* @example
|
|
110
|
+
*
|
|
111
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
112
|
+
*
|
|
113
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
114
|
+
*
|
|
115
|
+
* calls.getCall(ref)
|
|
116
|
+
* .then(console.log) // successful response
|
|
117
|
+
* .catch(console.error); // an error occurred
|
|
118
|
+
*/
|
|
119
|
+
async getCall(ref) {
|
|
120
|
+
const client = this.client.getCallsClient();
|
|
121
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
122
|
+
method: client.getCall.bind(client),
|
|
123
|
+
requestPBObjectConstructor: calls_pb_1.GetCallRequest,
|
|
124
|
+
metadata: this.client.getMetadata(),
|
|
125
|
+
request: { ref },
|
|
126
|
+
enumMapping: [
|
|
127
|
+
["type", types_1.CallType],
|
|
128
|
+
["callStatus", types_1.CallStatus],
|
|
129
|
+
["hangupCause", types_1.HangupCause],
|
|
130
|
+
["callDirection", types_1.CallDirection]
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves a list of Calls from a Workspace.
|
|
136
|
+
*
|
|
137
|
+
* @param {ListCallsRequest} request - The request object that contains the necessary information to retrieve a list of Calls
|
|
138
|
+
* @param {number} request.pageSize - The number of Calls to retrieve
|
|
139
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Calls
|
|
140
|
+
* @return {Promise<ListCallsResponse>} - The response object that contains the list of Calls
|
|
141
|
+
* @example
|
|
142
|
+
*
|
|
143
|
+
* const request = {
|
|
144
|
+
* pageSize: 10,
|
|
145
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
146
|
+
* };
|
|
147
|
+
*
|
|
148
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
149
|
+
*
|
|
150
|
+
* calls.listCalls(request)
|
|
151
|
+
* .then(console.log) // successful response
|
|
152
|
+
* .catch(console.error); // an error occurred
|
|
153
|
+
*/
|
|
154
|
+
async listCalls(request) {
|
|
155
|
+
const client = this.client.getCallsClient();
|
|
156
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
157
|
+
method: client.listCalls.bind(client),
|
|
158
|
+
requestPBObjectConstructor: calls_pb_1.ListCallsRequest,
|
|
159
|
+
metadata: this.client.getMetadata(),
|
|
160
|
+
request,
|
|
161
|
+
repeatableObjectMapping: [["itemsList", calls_pb_1.Call]]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.Calls = Calls;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { BaseApiObject, CreateCredentialsRequest, Credentials as CredentialsType, ListCredentialsRequest, ListCredentialsResponse, UpdateCredentialsRequest } from "@fonoster/types";
|
|
2
|
+
import { FonosterClient } from "./client/types";
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Fonoster Credentials, part of the Fonoster SIP Proxy subsystem,
|
|
5
|
+
* allows you to create, update, retrieve, and delete SIP Credentials 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 credentials = new SDK.Credentials(client);
|
|
21
|
+
* const response = await apiKeys.createCredentials(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 Credentials",
|
|
31
|
+
* username: "myusername",
|
|
32
|
+
* password: "mysecret"
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* main(request).catch(console.error);
|
|
36
|
+
*/
|
|
37
|
+
declare class Credentials {
|
|
38
|
+
private client;
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a new Credentials object.
|
|
41
|
+
*
|
|
42
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
43
|
+
* @see AbstractClient
|
|
44
|
+
* @see FonosterClient
|
|
45
|
+
*/
|
|
46
|
+
constructor(client: FonosterClient);
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new set of Credentials in the Workspace.
|
|
49
|
+
*
|
|
50
|
+
* @param {CreateCredentialsRequest} request - The request object that contains the necessary information to create a new set of Credentials
|
|
51
|
+
* @param {string} request.name - The name of the Credentials
|
|
52
|
+
* @param {string} request.username - The username of the Credentials
|
|
53
|
+
* @param {string} request.password - The password of the Credentials
|
|
54
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Credentials
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* const request = {
|
|
58
|
+
* name: "My Credentials",
|
|
59
|
+
* username: "myusername",
|
|
60
|
+
* password: "mysecret"
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
64
|
+
*
|
|
65
|
+
* credentials.createCredentials(request)
|
|
66
|
+
* .then(console.log) // successful response
|
|
67
|
+
* .catch(console.error); // an error occurred
|
|
68
|
+
*/
|
|
69
|
+
createCredentials(request: CreateCredentialsRequest): Promise<BaseApiObject>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves an existing set of Credentials in the Workspace.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} ref - The reference of the Credentials to retrieve
|
|
74
|
+
* @return {Promise<Acl>} - The response object that contains the Credentials
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
78
|
+
*
|
|
79
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
80
|
+
*
|
|
81
|
+
* credentials.getCredentials(ref)
|
|
82
|
+
* .then(console.log) // successful response
|
|
83
|
+
* .catch(console.error); // an error occurred
|
|
84
|
+
*/
|
|
85
|
+
getCredentials(ref: string): Promise<CredentialsType>;
|
|
86
|
+
/**
|
|
87
|
+
* Updates an existing set of Credentials in the Workspace.
|
|
88
|
+
*
|
|
89
|
+
* @param {UpdateCredentialsRequest} request - The request object that contains the necessary information to update an existing set of Credentials
|
|
90
|
+
* @param {string} request.ref - The reference of the Credentials to update
|
|
91
|
+
* @param {string} request.name - The name of the Credentials
|
|
92
|
+
* @param {string} request.password - The password of the Credentials
|
|
93
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Credentials
|
|
94
|
+
* @example
|
|
95
|
+
*
|
|
96
|
+
* const request = {
|
|
97
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
98
|
+
* name: "My Credentials",
|
|
99
|
+
* password: "mysecret"
|
|
100
|
+
* };
|
|
101
|
+
*
|
|
102
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
103
|
+
*
|
|
104
|
+
* credentials.updateCredentials(request)
|
|
105
|
+
* .then(console.log) // successful response
|
|
106
|
+
* .catch(console.error); // an error occurred
|
|
107
|
+
*/
|
|
108
|
+
updateCredentials(request: UpdateCredentialsRequest): Promise<BaseApiObject>;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a list of Credentials from a Workspace.
|
|
111
|
+
*
|
|
112
|
+
* @param {ListCredentialsRequest} request - The request object that contains the necessary information to retrieve a list of Credentials
|
|
113
|
+
* @param {number} request.pageSize - The number of Credentials to retrieve
|
|
114
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Credentials
|
|
115
|
+
* @return {Promise<ListCredentialsResponse>} - The response object that contains the list of Credentials
|
|
116
|
+
* @example
|
|
117
|
+
*
|
|
118
|
+
* const request = {
|
|
119
|
+
* pageSize: 10,
|
|
120
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
121
|
+
* };
|
|
122
|
+
*
|
|
123
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
124
|
+
*
|
|
125
|
+
* credentials.listCredentials(request)
|
|
126
|
+
* .then(console.log) // successful response
|
|
127
|
+
* .catch(console.error); // an error occurred
|
|
128
|
+
*/
|
|
129
|
+
listCredentials(request: ListCredentialsRequest): Promise<ListCredentialsResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Deletes an existing set of Credentials from Fonoster.
|
|
132
|
+
* Note that this operation is irreversible.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} ref - The reference of the Credentials to delete
|
|
135
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Credentials
|
|
136
|
+
* @example
|
|
137
|
+
*
|
|
138
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
139
|
+
*
|
|
140
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
141
|
+
*
|
|
142
|
+
* credentials.deleteCredentials(ref)
|
|
143
|
+
* .then(console.log) // successful response
|
|
144
|
+
* .catch(console.error); // an error occurred
|
|
145
|
+
*/
|
|
146
|
+
deleteCredentials(ref: string): Promise<BaseApiObject>;
|
|
147
|
+
}
|
|
148
|
+
export { Credentials };
|