@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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Agents = void 0;
|
|
4
|
+
const makeRpcRequest_1 = require("./client/makeRpcRequest");
|
|
5
|
+
const agents_pb_1 = require("./generated/node/agents_pb");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Fonoster Agents, part of the Fonoster SIP Proxy subsystem,
|
|
8
|
+
* allows you to create, update, retrieve, and delete SIP Agents 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 agents = new SDK.Agents(client);
|
|
24
|
+
* const response = await agents.createAgent(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: "John Doe",
|
|
34
|
+
* username: "1001",
|
|
35
|
+
* privacy: "PRIVATE",
|
|
36
|
+
* enabled: true,
|
|
37
|
+
* maxContacts: 3
|
|
38
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
39
|
+
* };
|
|
40
|
+
*
|
|
41
|
+
* main(request).catch(console.error);
|
|
42
|
+
*/
|
|
43
|
+
class Agents {
|
|
44
|
+
client;
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new Agents object.
|
|
47
|
+
*
|
|
48
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
49
|
+
* @see AbstractClient
|
|
50
|
+
* @see FonosterClient
|
|
51
|
+
*/
|
|
52
|
+
constructor(client) {
|
|
53
|
+
this.client = client;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new Agent in the Workspace.
|
|
57
|
+
*
|
|
58
|
+
* @param {CreateAgentRequest} request - The request object that contains the necessary information to create a new Agent
|
|
59
|
+
* @param {string} request.name - The name of the Agent
|
|
60
|
+
* @param {string} request.username - The username of the Agent
|
|
61
|
+
* @param {Privacy} request.privacy - The privacy of the Agent
|
|
62
|
+
* @param {boolean} request.enabled - The status of the Agent
|
|
63
|
+
* @param {number} request.maxContacts - The maximum number of contacts the Agent can have
|
|
64
|
+
* @param {string} request.domainRef - The reference of the Domain to associate the Agent
|
|
65
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Agent
|
|
66
|
+
* @example
|
|
67
|
+
*
|
|
68
|
+
* const request = {
|
|
69
|
+
* name: "John Doe",
|
|
70
|
+
* username: "1001",
|
|
71
|
+
* privacy: "PRIVATE",
|
|
72
|
+
* enabled: true,
|
|
73
|
+
* maxContacts: 3
|
|
74
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
75
|
+
* };
|
|
76
|
+
*
|
|
77
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
78
|
+
*
|
|
79
|
+
* agents.createAgent(request)
|
|
80
|
+
* .then(console.log) // successful response
|
|
81
|
+
* .catch(console.error); // an error occurred
|
|
82
|
+
*/
|
|
83
|
+
async createAgent(request) {
|
|
84
|
+
const client = this.client.getAgentsClient();
|
|
85
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
86
|
+
method: client.createAgent.bind(client),
|
|
87
|
+
requestPBObjectConstructor: agents_pb_1.CreateAgentRequest,
|
|
88
|
+
metadata: this.client.getMetadata(),
|
|
89
|
+
request,
|
|
90
|
+
enumMapping: [["privacy", agents_pb_1.Privacy]]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves an existing Agent in the Workspace.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} ref - The reference of the Agent to retrieve
|
|
97
|
+
* @return {Promise<Acl>} - The response object that contains the Agent information
|
|
98
|
+
* @example
|
|
99
|
+
*
|
|
100
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
101
|
+
*
|
|
102
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
103
|
+
*
|
|
104
|
+
* agents.getAgent(ref)
|
|
105
|
+
* .then(console.log) // successful response
|
|
106
|
+
* .catch(console.error); // an error occurred
|
|
107
|
+
*/
|
|
108
|
+
async getAgent(ref) {
|
|
109
|
+
const client = this.client.getAgentsClient();
|
|
110
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
111
|
+
method: client.getAgent.bind(client),
|
|
112
|
+
requestPBObjectConstructor: agents_pb_1.GetAgentRequest,
|
|
113
|
+
metadata: this.client.getMetadata(),
|
|
114
|
+
request: { ref }
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Updates an existing Agent in the Workspace.
|
|
119
|
+
*
|
|
120
|
+
* @param {UpdateAgentRequest} request - The request object that contains the necessary information to update an existing Agent
|
|
121
|
+
* @param {string} request.ref - The reference of the Agent to update
|
|
122
|
+
* @param {string} request.name - The name of the Agent
|
|
123
|
+
* @param {Privacy} request.privacy - The privacy of the Agent
|
|
124
|
+
* @param {boolean} request.enabled - The status of the Agent
|
|
125
|
+
* @param {number} request.maxContacts - The maximum number of contacts the Agent can have
|
|
126
|
+
* @param {string} request.domainRef - The reference of the Domain to associate the Agent
|
|
127
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Agent
|
|
128
|
+
* @example
|
|
129
|
+
*
|
|
130
|
+
* const request = {
|
|
131
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
132
|
+
* name: "John Doe",
|
|
133
|
+
* privacy: "PRIVATE",
|
|
134
|
+
* enabled: true,
|
|
135
|
+
* maxContacts: 3
|
|
136
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
137
|
+
* };
|
|
138
|
+
*
|
|
139
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
140
|
+
*
|
|
141
|
+
* agents.updateAgent(request)
|
|
142
|
+
* .then(console.log) // successful response
|
|
143
|
+
* .catch(console.error); // an error occurred
|
|
144
|
+
*/
|
|
145
|
+
async updateAgent(request) {
|
|
146
|
+
const client = this.client.getAgentsClient();
|
|
147
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
148
|
+
method: client.updateAgent.bind(client),
|
|
149
|
+
requestPBObjectConstructor: agents_pb_1.UpdateAgentRequest,
|
|
150
|
+
metadata: this.client.getMetadata(),
|
|
151
|
+
request,
|
|
152
|
+
enumMapping: [["privacy", agents_pb_1.Privacy]]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves a list of Agents from a Workspace.
|
|
157
|
+
*
|
|
158
|
+
* @param {ListAgentsRequest} request - The request object that contains the necessary information to retrieve a list of Agents
|
|
159
|
+
* @param {number} request.pageSize - The number of Agents to retrieve
|
|
160
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Agents
|
|
161
|
+
* @return {Promise<ListAgentsResponse>} - The response object that contains the list of Agents
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* const request = {
|
|
165
|
+
* pageSize: 10,
|
|
166
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
167
|
+
* };
|
|
168
|
+
*
|
|
169
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
170
|
+
*
|
|
171
|
+
* agents.listAgents(request)
|
|
172
|
+
* .then(console.log) // successful response
|
|
173
|
+
* .catch(console.error); // an error occurred
|
|
174
|
+
*/
|
|
175
|
+
async listAgents(request) {
|
|
176
|
+
const client = this.client.getAgentsClient();
|
|
177
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
178
|
+
method: client.listAgents.bind(client),
|
|
179
|
+
requestPBObjectConstructor: agents_pb_1.ListAgentsRequest,
|
|
180
|
+
metadata: this.client.getMetadata(),
|
|
181
|
+
request,
|
|
182
|
+
repeatableObjectMapping: [["itemsList", agents_pb_1.Agent]]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Deletes an existing Agent from Fonoster.
|
|
187
|
+
* Note that this operation is irreversible.
|
|
188
|
+
*
|
|
189
|
+
* @param {string} ref - The reference of the Agent to delete
|
|
190
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Agent
|
|
191
|
+
* @example
|
|
192
|
+
*
|
|
193
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
194
|
+
*
|
|
195
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
196
|
+
*
|
|
197
|
+
* agents.deleteAgent(ref)
|
|
198
|
+
* .then(console.log) // successful response
|
|
199
|
+
* .catch(console.error); // an error occurred
|
|
200
|
+
*/
|
|
201
|
+
async deleteAgent(ref) {
|
|
202
|
+
const applicationsClient = this.client.getAgentsClient();
|
|
203
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
204
|
+
method: applicationsClient.deleteAgent.bind(applicationsClient),
|
|
205
|
+
requestPBObjectConstructor: agents_pb_1.DeleteAgentRequest,
|
|
206
|
+
metadata: this.client.getMetadata(),
|
|
207
|
+
request: { ref }
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.Agents = Agents;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { BaseApiObject, CreateApiKeyRequest, CreateApiKeyResponse, ListApiKeysRequest, ListApiKeysResponse } from "@fonoster/types";
|
|
2
|
+
import { FonosterClient } from "./client/types";
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Fonoster ApiKeys, part of the Fonoster Identity subsystem,
|
|
5
|
+
* allows you to create, update, retrieve, and delete ApiKeys 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 apiKeys = new SDK.ApiKeys(client);
|
|
21
|
+
* const response = await apiKeys.createApiKey(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
|
+
* role: "WORKSPACE_ADMIN"
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* main(request).catch(console.error);
|
|
34
|
+
*/
|
|
35
|
+
declare class ApiKeys {
|
|
36
|
+
private client;
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new ApiKeys object.
|
|
39
|
+
*
|
|
40
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
41
|
+
* @see AbstractClient
|
|
42
|
+
* @see FonosterClient
|
|
43
|
+
*/
|
|
44
|
+
constructor(client: FonosterClient);
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new ApiKey for a Workspace.
|
|
47
|
+
*
|
|
48
|
+
* @param {CreateApiKeyRequest} request - The request object that contains the necessary information to create a new ApiKey
|
|
49
|
+
* @param {ApiRoleEnum} request.role - The role of the ApiKey
|
|
50
|
+
* @return {Promise<CreateApiKeyResponse>} - The response object that contains the reference to the created ApiKey
|
|
51
|
+
* @example
|
|
52
|
+
*
|
|
53
|
+
* const request = {
|
|
54
|
+
* role: "WORKSPACE_ADMIN"
|
|
55
|
+
* };
|
|
56
|
+
*
|
|
57
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
58
|
+
*
|
|
59
|
+
* apiKeys.createApiKey(request)
|
|
60
|
+
* .then(console.log) // successful response
|
|
61
|
+
* .catch(console.error); // an error occurred
|
|
62
|
+
*/
|
|
63
|
+
createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Regenerates an existing ApiKey for a Workspace.
|
|
66
|
+
* Note that this operation is irreversible.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} ref - The reference of the ApiKey to regenerate
|
|
69
|
+
* @return {Promise<CreateApiKeyResponse>} - The response object that contains the reference to the regenerated ApiKey
|
|
70
|
+
* @example
|
|
71
|
+
*
|
|
72
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
73
|
+
*
|
|
74
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
75
|
+
*
|
|
76
|
+
* apiKeys.regenerateApiKey(ref)
|
|
77
|
+
* .then(console.log) // successful response
|
|
78
|
+
* .catch(console.error); // an error occurred
|
|
79
|
+
*/
|
|
80
|
+
regenerateApiKey(ref: string): Promise<CreateApiKeyResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves a list of ApiKeys from a Workspace.
|
|
83
|
+
*
|
|
84
|
+
* @param {ListApiKeysRequest} request - The request object that contains the necessary information to retrieve a list of ApiKeys
|
|
85
|
+
* @param {number} request.pageSize - The number of ApiKeys to retrieve
|
|
86
|
+
* @param {string} request.pageToken - The token to retrieve the next page of ApiKeys
|
|
87
|
+
* @return {Promise<ListApiKeysResponse>} - The response object that contains the list of ApiKeys
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* const request = {
|
|
91
|
+
* pageSize: 10,
|
|
92
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
93
|
+
* };
|
|
94
|
+
*
|
|
95
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
96
|
+
*
|
|
97
|
+
* apiKeys.listApiKeys(request)
|
|
98
|
+
* .then(console.log) // successful response
|
|
99
|
+
* .catch(console.error); // an error occurred
|
|
100
|
+
*/
|
|
101
|
+
listApiKeys(request: ListApiKeysRequest): Promise<ListApiKeysResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Deletes an existing ApiKey from Fonoster.
|
|
104
|
+
* Note that this operation is irreversible.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} ref - The reference of the ApiKey to delete
|
|
107
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted ApiKey
|
|
108
|
+
* @example
|
|
109
|
+
*
|
|
110
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
111
|
+
*
|
|
112
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
113
|
+
*
|
|
114
|
+
* apiKeys.deleteApiKey(ref)
|
|
115
|
+
* .then(console.log) // successful response
|
|
116
|
+
* .catch(console.error); // an error occurred
|
|
117
|
+
*/
|
|
118
|
+
deleteApiKey(ref: string): Promise<BaseApiObject>;
|
|
119
|
+
}
|
|
120
|
+
export { ApiKeys };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiKeys = 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 identity_pb_1 = require("./generated/node/identity_pb");
|
|
25
|
+
/**
|
|
26
|
+
* @classdesc Fonoster ApiKeys, part of the Fonoster Identity subsystem,
|
|
27
|
+
* allows you to create, update, retrieve, and delete ApiKeys for 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 apiKey = "your-api-key";
|
|
36
|
+
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
37
|
+
*
|
|
38
|
+
* try {
|
|
39
|
+
* const client = SDK.Client({ accessKeyId });
|
|
40
|
+
* await client.loginWithApiKey(apiKey);
|
|
41
|
+
*
|
|
42
|
+
* const apiKeys = new SDK.ApiKeys(client);
|
|
43
|
+
* const response = await apiKeys.createApiKey(request);
|
|
44
|
+
*
|
|
45
|
+
* console.log(response); // successful response
|
|
46
|
+
* } catch (e) {
|
|
47
|
+
* console.error(e); // an error occurred
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* const request = {
|
|
52
|
+
* role: "WORKSPACE_ADMIN"
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* main(request).catch(console.error);
|
|
56
|
+
*/
|
|
57
|
+
class ApiKeys {
|
|
58
|
+
client;
|
|
59
|
+
/**
|
|
60
|
+
* Constructs a new ApiKeys object.
|
|
61
|
+
*
|
|
62
|
+
* @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
|
|
63
|
+
* @see AbstractClient
|
|
64
|
+
* @see FonosterClient
|
|
65
|
+
*/
|
|
66
|
+
constructor(client) {
|
|
67
|
+
this.client = client;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new ApiKey for a Workspace.
|
|
71
|
+
*
|
|
72
|
+
* @param {CreateApiKeyRequest} request - The request object that contains the necessary information to create a new ApiKey
|
|
73
|
+
* @param {ApiRoleEnum} request.role - The role of the ApiKey
|
|
74
|
+
* @return {Promise<CreateApiKeyResponse>} - The response object that contains the reference to the created ApiKey
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* const request = {
|
|
78
|
+
* role: "WORKSPACE_ADMIN"
|
|
79
|
+
* };
|
|
80
|
+
*
|
|
81
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
82
|
+
*
|
|
83
|
+
* apiKeys.createApiKey(request)
|
|
84
|
+
* .then(console.log) // successful response
|
|
85
|
+
* .catch(console.error); // an error occurred
|
|
86
|
+
*/
|
|
87
|
+
async createApiKey(request) {
|
|
88
|
+
const client = this.client.getIdentityClient();
|
|
89
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
90
|
+
method: client.createApiKey.bind(client),
|
|
91
|
+
requestPBObjectConstructor: identity_pb_1.CreateApiKeyRequest,
|
|
92
|
+
metadata: this.client.getMetadata(),
|
|
93
|
+
request,
|
|
94
|
+
enumMapping: [["role", types_1.ApiRoleEnum]]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Regenerates an existing ApiKey for a Workspace.
|
|
99
|
+
* Note that this operation is irreversible.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} ref - The reference of the ApiKey to regenerate
|
|
102
|
+
* @return {Promise<CreateApiKeyResponse>} - The response object that contains the reference to the regenerated ApiKey
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
106
|
+
*
|
|
107
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
108
|
+
*
|
|
109
|
+
* apiKeys.regenerateApiKey(ref)
|
|
110
|
+
* .then(console.log) // successful response
|
|
111
|
+
* .catch(console.error); // an error occurred
|
|
112
|
+
*/
|
|
113
|
+
async regenerateApiKey(ref) {
|
|
114
|
+
const client = this.client.getIdentityClient();
|
|
115
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
116
|
+
method: client.regenerateApiKey.bind(client),
|
|
117
|
+
requestPBObjectConstructor: identity_pb_1.RegenerateApiKeyRequest,
|
|
118
|
+
metadata: this.client.getMetadata(),
|
|
119
|
+
request: { ref }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retrieves a list of ApiKeys from a Workspace.
|
|
124
|
+
*
|
|
125
|
+
* @param {ListApiKeysRequest} request - The request object that contains the necessary information to retrieve a list of ApiKeys
|
|
126
|
+
* @param {number} request.pageSize - The number of ApiKeys to retrieve
|
|
127
|
+
* @param {string} request.pageToken - The token to retrieve the next page of ApiKeys
|
|
128
|
+
* @return {Promise<ListApiKeysResponse>} - The response object that contains the list of ApiKeys
|
|
129
|
+
* @example
|
|
130
|
+
*
|
|
131
|
+
* const request = {
|
|
132
|
+
* pageSize: 10,
|
|
133
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
134
|
+
* };
|
|
135
|
+
*
|
|
136
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
137
|
+
*
|
|
138
|
+
* apiKeys.listApiKeys(request)
|
|
139
|
+
* .then(console.log) // successful response
|
|
140
|
+
* .catch(console.error); // an error occurred
|
|
141
|
+
*/
|
|
142
|
+
async listApiKeys(request) {
|
|
143
|
+
const applicationsClient = this.client.getIdentityClient();
|
|
144
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
145
|
+
method: applicationsClient.listApiKeys.bind(applicationsClient),
|
|
146
|
+
requestPBObjectConstructor: identity_pb_1.ListApiKeysRequest,
|
|
147
|
+
metadata: this.client.getMetadata(),
|
|
148
|
+
request,
|
|
149
|
+
repeatableObjectMapping: [["itemsList", identity_pb_1.ApiKey]]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Deletes an existing ApiKey from Fonoster.
|
|
154
|
+
* Note that this operation is irreversible.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} ref - The reference of the ApiKey to delete
|
|
157
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted ApiKey
|
|
158
|
+
* @example
|
|
159
|
+
*
|
|
160
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
161
|
+
*
|
|
162
|
+
* const apiKeys = new SDK.ApiKeys(client); // Existing client object
|
|
163
|
+
*
|
|
164
|
+
* apiKeys.deleteApiKey(ref)
|
|
165
|
+
* .then(console.log) // successful response
|
|
166
|
+
* .catch(console.error); // an error occurred
|
|
167
|
+
*/
|
|
168
|
+
async deleteApiKey(ref) {
|
|
169
|
+
const client = this.client.getIdentityClient();
|
|
170
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
171
|
+
method: client.deleteApiKey.bind(client),
|
|
172
|
+
requestPBObjectConstructor: identity_pb_1.DeleteApiKeyRequest,
|
|
173
|
+
metadata: this.client.getMetadata(),
|
|
174
|
+
request: { ref }
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.ApiKeys = ApiKeys;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Application, BaseApiObject, CreateApplicationRequest, CreateApplicationResponse, ListApplicationsRequest, ListApplicationsResponse, UpdateApplicationRequest } from "@fonoster/
|
|
1
|
+
import { Application, BaseApiObject, CreateApplicationRequest, CreateApplicationResponse, ListApplicationsRequest, ListApplicationsResponse, UpdateApplicationRequest } from "@fonoster/types";
|
|
2
2
|
import { FonosterClient } from "./client/types";
|
|
3
3
|
/**
|
|
4
4
|
* @classdesc Fonoster Applications, part of the Fonoster Voice Subsystem,
|
|
@@ -9,6 +9,23 @@ import { FonosterClient } from "./client/types";
|
|
|
9
9
|
*
|
|
10
10
|
* const SDK = require("@fonoster/sdk");
|
|
11
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 apps = new SDK.Applications(client);
|
|
21
|
+
* const response = await apps.createApplication(request);
|
|
22
|
+
*
|
|
23
|
+
* console.log(response); // successful response
|
|
24
|
+
* } catch (e) {
|
|
25
|
+
* console.error(e); // an error occurred
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
12
29
|
* const request = {
|
|
13
30
|
* name: "My application",
|
|
14
31
|
* type: "PROGRAMMABLE_VOICE",
|
|
@@ -36,18 +53,7 @@ import { FonosterClient } from "./client/types";
|
|
|
36
53
|
* }
|
|
37
54
|
* };
|
|
38
55
|
*
|
|
39
|
-
*
|
|
40
|
-
* const password = "changeme";
|
|
41
|
-
* const accessKeyId = "WO00000000000000000000000000000000";
|
|
42
|
-
*
|
|
43
|
-
* const client = new SDK.Client({ accessKeyId });
|
|
44
|
-
*
|
|
45
|
-
* client.login(username, password)
|
|
46
|
-
* .then(async () => {
|
|
47
|
-
* const apps = new SDK.Applications(client);
|
|
48
|
-
* const result = await apps.createApplication(request);
|
|
49
|
-
* console.log(result); // successful response
|
|
50
|
-
* }).catch(console.error); // an error occurred
|
|
56
|
+
* main(request).catch(console.error);
|
|
51
57
|
*/
|
|
52
58
|
declare class Applications {
|
|
53
59
|
private client;
|
|
@@ -114,19 +120,17 @@ declare class Applications {
|
|
|
114
120
|
*/
|
|
115
121
|
createApplication(request: CreateApplicationRequest): Promise<CreateApplicationResponse>;
|
|
116
122
|
/**
|
|
117
|
-
* Retrieves an existing
|
|
123
|
+
* Retrieves an existing Application in the Workspace.
|
|
118
124
|
*
|
|
119
|
-
* @param {string} ref - The reference of the
|
|
120
|
-
* @return {Promise<Application>} - The response object that contains the
|
|
125
|
+
* @param {string} ref - The reference of the Application to retrieve
|
|
126
|
+
* @return {Promise<Application>} - The response object that contains the Application information
|
|
121
127
|
* @example
|
|
122
128
|
*
|
|
123
|
-
* const
|
|
124
|
-
* ref: "00000000-0000-0000-0000-000000000000"
|
|
125
|
-
* };
|
|
129
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
126
130
|
*
|
|
127
131
|
* const apps = new SDK.Applications(client); // Existing client object
|
|
128
132
|
*
|
|
129
|
-
* apps.getApplication(
|
|
133
|
+
* apps.getApplication(ref)
|
|
130
134
|
* .then(console.log) // successful response
|
|
131
135
|
* .catch(console.error); // an error occurred
|
|
132
136
|
*/
|
|
@@ -165,12 +169,12 @@ declare class Applications {
|
|
|
165
169
|
*/
|
|
166
170
|
updateApplication(request: UpdateApplicationRequest): Promise<BaseApiObject>;
|
|
167
171
|
/**
|
|
168
|
-
* Retrieves a list of
|
|
172
|
+
* Retrieves a list of Applications from Fonoster.
|
|
169
173
|
*
|
|
170
|
-
* @param {ListApplicationsRequest} request - The request object that contains the necessary information to retrieve a list of
|
|
171
|
-
* @param {number} request.pageSize - The number of
|
|
172
|
-
* @param {string} request.pageToken - The token to retrieve the next page of
|
|
173
|
-
* @return {Promise<ListApplicationsResponse>} - The response object that contains the list of
|
|
174
|
+
* @param {ListApplicationsRequest} request - The request object that contains the necessary information to retrieve a list of Applications
|
|
175
|
+
* @param {number} request.pageSize - The number of Applications to retrieve
|
|
176
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Applications
|
|
177
|
+
* @return {Promise<ListApplicationsResponse>} - The response object that contains the list of Applications
|
|
174
178
|
* @example
|
|
175
179
|
*
|
|
176
180
|
* const request = {
|
|
@@ -186,10 +190,10 @@ declare class Applications {
|
|
|
186
190
|
*/
|
|
187
191
|
listApplications(request: ListApplicationsRequest): Promise<ListApplicationsResponse>;
|
|
188
192
|
/**
|
|
189
|
-
* Deletes an existing
|
|
193
|
+
* Deletes an existing Application from Fonoster.
|
|
190
194
|
* Note that this operation is irreversible.
|
|
191
195
|
*
|
|
192
|
-
* @param {string} ref - The reference of the
|
|
196
|
+
* @param {string} ref - The reference of the Application to delete
|
|
193
197
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted application
|
|
194
198
|
* @example
|
|
195
199
|
*
|