@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,150 @@
|
|
|
1
|
+
import { Acl, BaseApiObject, CreateAclRequest, ListAclsRequest, ListAclsResponse, UpdateAclRequest } from "@fonoster/types";
|
|
2
|
+
import { FonosterClient } from "./client/types";
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Fonoster Acls, part of the Fonoster SIP Proxy subsystem,
|
|
5
|
+
* allows you to create, update, retrieve, and delete Access Control Lists (ACLs) rules 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 acls = new SDK.Acls(client);
|
|
21
|
+
* const response = await acls.createAcl(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 ACL",
|
|
31
|
+
* allow: ["47.132.130.31"], // Allow only this IP
|
|
32
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* main(request).catch(console.error);
|
|
36
|
+
*/
|
|
37
|
+
declare class Acls {
|
|
38
|
+
private client;
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a new Acls 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 Acl in the Workspace.
|
|
49
|
+
*
|
|
50
|
+
* @param {CreateAclRequest} request - The request object that contains the necessary information to create a new Acl
|
|
51
|
+
* @param {string} request.name - The name of the Acl
|
|
52
|
+
* @param {string[]} request.allow - The list of IPs to allow
|
|
53
|
+
* @param {string[]} request.deny - The list of IPs to deny
|
|
54
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Acl
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* const request = {
|
|
58
|
+
* name: "My ACL",
|
|
59
|
+
* allow: ["47.132.130.31"], // Allow only this IP
|
|
60
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
64
|
+
*
|
|
65
|
+
* acls.createAcl(request)
|
|
66
|
+
* .then(console.log) // successful response
|
|
67
|
+
* .catch(console.error); // an error occurred
|
|
68
|
+
*/
|
|
69
|
+
createAcl(request: CreateAclRequest): Promise<BaseApiObject>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves an existing Acl in the Workspace.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} ref - The reference of the Acl to retrieve
|
|
74
|
+
* @return {Promise<Acl>} - The response object that contains the Acl information
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
78
|
+
*
|
|
79
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
80
|
+
*
|
|
81
|
+
* acls.getAcl(ref)
|
|
82
|
+
* .then(console.log) // successful response
|
|
83
|
+
* .catch(console.error); // an error occurred
|
|
84
|
+
*/
|
|
85
|
+
getAcl(ref: string): Promise<Acl>;
|
|
86
|
+
/**
|
|
87
|
+
* Updates an existing Acl in the Workspace.
|
|
88
|
+
*
|
|
89
|
+
* @param {UpdateAclRequest} request - The request object that contains the necessary information to update an existing Acl
|
|
90
|
+
* @param {string} request.ref - The reference of the Acl to update
|
|
91
|
+
* @param {string} request.name - The name of the Acl
|
|
92
|
+
* @param {string[]} request.allow - The list of IPs to allow
|
|
93
|
+
* @param {string[]} request.deny - The list of IPs to deny
|
|
94
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Acl
|
|
95
|
+
* @example
|
|
96
|
+
*
|
|
97
|
+
* const request = {
|
|
98
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
99
|
+
* name: "My ACL",
|
|
100
|
+
* allow: ["47.132.130.31"] // Allow only this IP
|
|
101
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
102
|
+
* };
|
|
103
|
+
*
|
|
104
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
105
|
+
*
|
|
106
|
+
* acl.updateAcl(request)
|
|
107
|
+
* .then(console.log) // successful response
|
|
108
|
+
* .catch(console.error); // an error occurred
|
|
109
|
+
*/
|
|
110
|
+
updateAcl(request: UpdateAclRequest): Promise<BaseApiObject>;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves a list of Acls from a Workspace.
|
|
113
|
+
*
|
|
114
|
+
* @param {ListAclsRequest} request - The request object that contains the necessary information to retrieve a list of Acls
|
|
115
|
+
* @param {number} request.pageSize - The number of Acls to retrieve
|
|
116
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Acls
|
|
117
|
+
* @return {Promise<ListAclsResponse>} - The response object that contains the list of Acls
|
|
118
|
+
* @example
|
|
119
|
+
*
|
|
120
|
+
* const request = {
|
|
121
|
+
* pageSize: 10,
|
|
122
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
123
|
+
* };
|
|
124
|
+
*
|
|
125
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
126
|
+
*
|
|
127
|
+
* acls.listAcls(request)
|
|
128
|
+
* .then(console.log) // successful response
|
|
129
|
+
* .catch(console.error); // an error occurred
|
|
130
|
+
*/
|
|
131
|
+
listAcls(request: ListAclsRequest): Promise<ListAclsResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* Deletes an existing Acl from Fonoster.
|
|
134
|
+
* Note that this operation is irreversible.
|
|
135
|
+
*
|
|
136
|
+
* @param {string} ref - The reference of the Acl to delete
|
|
137
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Acl
|
|
138
|
+
* @example
|
|
139
|
+
*
|
|
140
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
141
|
+
*
|
|
142
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
143
|
+
*
|
|
144
|
+
* acls.deleteAcl(ref)
|
|
145
|
+
* .then(console.log) // successful response
|
|
146
|
+
* .catch(console.error); // an error occurred
|
|
147
|
+
*/
|
|
148
|
+
deleteAcl(ref: string): Promise<BaseApiObject>;
|
|
149
|
+
}
|
|
150
|
+
export { Acls };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Acls = void 0;
|
|
4
|
+
const makeRpcRequest_1 = require("./client/makeRpcRequest");
|
|
5
|
+
const acls_pb_1 = require("./generated/node/acls_pb");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Fonoster Acls, part of the Fonoster SIP Proxy subsystem,
|
|
8
|
+
* allows you to create, update, retrieve, and delete Access Control Lists (ACLs) rules 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 acls = new SDK.Acls(client);
|
|
24
|
+
* const response = await acls.createAcl(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 ACL",
|
|
34
|
+
* allow: ["47.132.130.31"], // Allow only this IP
|
|
35
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* main(request).catch(console.error);
|
|
39
|
+
*/
|
|
40
|
+
class Acls {
|
|
41
|
+
client;
|
|
42
|
+
/**
|
|
43
|
+
* Constructs a new Acls 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 Acl in the Workspace.
|
|
54
|
+
*
|
|
55
|
+
* @param {CreateAclRequest} request - The request object that contains the necessary information to create a new Acl
|
|
56
|
+
* @param {string} request.name - The name of the Acl
|
|
57
|
+
* @param {string[]} request.allow - The list of IPs to allow
|
|
58
|
+
* @param {string[]} request.deny - The list of IPs to deny
|
|
59
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Acl
|
|
60
|
+
* @example
|
|
61
|
+
*
|
|
62
|
+
* const request = {
|
|
63
|
+
* name: "My ACL",
|
|
64
|
+
* allow: ["47.132.130.31"], // Allow only this IP
|
|
65
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
66
|
+
* };
|
|
67
|
+
*
|
|
68
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
69
|
+
*
|
|
70
|
+
* acls.createAcl(request)
|
|
71
|
+
* .then(console.log) // successful response
|
|
72
|
+
* .catch(console.error); // an error occurred
|
|
73
|
+
*/
|
|
74
|
+
async createAcl(request) {
|
|
75
|
+
const client = this.client.getAclsClient();
|
|
76
|
+
const createAclRequest = new acls_pb_1.CreateAclRequest();
|
|
77
|
+
createAclRequest.setName(request.name);
|
|
78
|
+
createAclRequest.setAllowList(request.allow);
|
|
79
|
+
createAclRequest.setDenyList(request.deny);
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
client.createAcl(createAclRequest, this.client.getMetadata(), (err, response) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
reject(err);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
resolve(response.toObject());
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves an existing Acl in the Workspace.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} ref - The reference of the Acl to retrieve
|
|
94
|
+
* @return {Promise<Acl>} - The response object that contains the Acl information
|
|
95
|
+
* @example
|
|
96
|
+
*
|
|
97
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
98
|
+
*
|
|
99
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
100
|
+
*
|
|
101
|
+
* acls.getAcl(ref)
|
|
102
|
+
* .then(console.log) // successful response
|
|
103
|
+
* .catch(console.error); // an error occurred
|
|
104
|
+
*/
|
|
105
|
+
async getAcl(ref) {
|
|
106
|
+
const client = this.client.getAclsClient();
|
|
107
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
108
|
+
method: client.getAcl.bind(client),
|
|
109
|
+
requestPBObjectConstructor: acls_pb_1.GetAclRequest,
|
|
110
|
+
metadata: this.client.getMetadata(),
|
|
111
|
+
request: { ref }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Updates an existing Acl in the Workspace.
|
|
116
|
+
*
|
|
117
|
+
* @param {UpdateAclRequest} request - The request object that contains the necessary information to update an existing Acl
|
|
118
|
+
* @param {string} request.ref - The reference of the Acl to update
|
|
119
|
+
* @param {string} request.name - The name of the Acl
|
|
120
|
+
* @param {string[]} request.allow - The list of IPs to allow
|
|
121
|
+
* @param {string[]} request.deny - The list of IPs to deny
|
|
122
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Acl
|
|
123
|
+
* @example
|
|
124
|
+
*
|
|
125
|
+
* const request = {
|
|
126
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
127
|
+
* name: "My ACL",
|
|
128
|
+
* allow: ["47.132.130.31"] // Allow only this IP
|
|
129
|
+
* deny: ["0.0.0.0/0"] // Deny all other IPs
|
|
130
|
+
* };
|
|
131
|
+
*
|
|
132
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
133
|
+
*
|
|
134
|
+
* acl.updateAcl(request)
|
|
135
|
+
* .then(console.log) // successful response
|
|
136
|
+
* .catch(console.error); // an error occurred
|
|
137
|
+
*/
|
|
138
|
+
async updateAcl(request) {
|
|
139
|
+
const client = this.client.getAclsClient();
|
|
140
|
+
const updateAclRequest = new acls_pb_1.UpdateAclRequest();
|
|
141
|
+
updateAclRequest.setRef(request.ref);
|
|
142
|
+
updateAclRequest.setName(request.name);
|
|
143
|
+
updateAclRequest.setAllowList(request.allow);
|
|
144
|
+
updateAclRequest.setDenyList(request.deny);
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
client.updateAcl(updateAclRequest, this.client.getMetadata(), (err, response) => {
|
|
147
|
+
if (err) {
|
|
148
|
+
reject(err);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
resolve(response.toObject());
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves a list of Acls from a Workspace.
|
|
157
|
+
*
|
|
158
|
+
* @param {ListAclsRequest} request - The request object that contains the necessary information to retrieve a list of Acls
|
|
159
|
+
* @param {number} request.pageSize - The number of Acls to retrieve
|
|
160
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Acls
|
|
161
|
+
* @return {Promise<ListAclsResponse>} - The response object that contains the list of Acls
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* const request = {
|
|
165
|
+
* pageSize: 10,
|
|
166
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
167
|
+
* };
|
|
168
|
+
*
|
|
169
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
170
|
+
*
|
|
171
|
+
* acls.listAcls(request)
|
|
172
|
+
* .then(console.log) // successful response
|
|
173
|
+
* .catch(console.error); // an error occurred
|
|
174
|
+
*/
|
|
175
|
+
async listAcls(request) {
|
|
176
|
+
const client = this.client.getAclsClient();
|
|
177
|
+
const listAclsRequest = new acls_pb_1.ListAclsRequest();
|
|
178
|
+
listAclsRequest.setPageSize(request.pageSize);
|
|
179
|
+
listAclsRequest.setPageToken(request.pageToken);
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
client.listAcls(listAclsRequest, this.client.getMetadata(), (err, response) => {
|
|
182
|
+
if (err) {
|
|
183
|
+
reject(err);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const items = response.getItemsList().map((item) => {
|
|
187
|
+
const obj = item.toObject();
|
|
188
|
+
return {
|
|
189
|
+
...obj,
|
|
190
|
+
allow: obj.allowList,
|
|
191
|
+
deny: obj.denyList
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
resolve({
|
|
195
|
+
items,
|
|
196
|
+
nextPageToken: response.getNextPageToken()
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Deletes an existing Acl from Fonoster.
|
|
203
|
+
* Note that this operation is irreversible.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} ref - The reference of the Acl to delete
|
|
206
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Acl
|
|
207
|
+
* @example
|
|
208
|
+
*
|
|
209
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
210
|
+
*
|
|
211
|
+
* const acls = new SDK.Acls(client); // Existing client object
|
|
212
|
+
*
|
|
213
|
+
* acls.deleteAcl(ref)
|
|
214
|
+
* .then(console.log) // successful response
|
|
215
|
+
* .catch(console.error); // an error occurred
|
|
216
|
+
*/
|
|
217
|
+
async deleteAcl(ref) {
|
|
218
|
+
const client = this.client.getAclsClient();
|
|
219
|
+
return await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
220
|
+
method: client.deleteAcl.bind(client),
|
|
221
|
+
requestPBObjectConstructor: acls_pb_1.DeleteAclRequest,
|
|
222
|
+
metadata: this.client.getMetadata(),
|
|
223
|
+
request: { ref }
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
exports.Acls = Acls;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Agent, BaseApiObject, CreateAgentRequest, ListAgentsRequest, ListAgentsResponse, UpdateAgentRequest } from "@fonoster/types";
|
|
2
|
+
import { FonosterClient } from "./client/types";
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Fonoster Agents, part of the Fonoster SIP Proxy subsystem,
|
|
5
|
+
* allows you to create, update, retrieve, and delete SIP Agents 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 agents = new SDK.Agents(client);
|
|
21
|
+
* const response = await agents.createAgent(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: "John Doe",
|
|
31
|
+
* username: "1001",
|
|
32
|
+
* privacy: "PRIVATE",
|
|
33
|
+
* enabled: true,
|
|
34
|
+
* maxContacts: 3
|
|
35
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* main(request).catch(console.error);
|
|
39
|
+
*/
|
|
40
|
+
declare class Agents {
|
|
41
|
+
private client;
|
|
42
|
+
/**
|
|
43
|
+
* Constructs a new Agents 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: FonosterClient);
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new Agent in the Workspace.
|
|
52
|
+
*
|
|
53
|
+
* @param {CreateAgentRequest} request - The request object that contains the necessary information to create a new Agent
|
|
54
|
+
* @param {string} request.name - The name of the Agent
|
|
55
|
+
* @param {string} request.username - The username of the Agent
|
|
56
|
+
* @param {Privacy} request.privacy - The privacy of the Agent
|
|
57
|
+
* @param {boolean} request.enabled - The status of the Agent
|
|
58
|
+
* @param {number} request.maxContacts - The maximum number of contacts the Agent can have
|
|
59
|
+
* @param {string} request.domainRef - The reference of the Domain to associate the Agent
|
|
60
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Agent
|
|
61
|
+
* @example
|
|
62
|
+
*
|
|
63
|
+
* const request = {
|
|
64
|
+
* name: "John Doe",
|
|
65
|
+
* username: "1001",
|
|
66
|
+
* privacy: "PRIVATE",
|
|
67
|
+
* enabled: true,
|
|
68
|
+
* maxContacts: 3
|
|
69
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
70
|
+
* };
|
|
71
|
+
*
|
|
72
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
73
|
+
*
|
|
74
|
+
* agents.createAgent(request)
|
|
75
|
+
* .then(console.log) // successful response
|
|
76
|
+
* .catch(console.error); // an error occurred
|
|
77
|
+
*/
|
|
78
|
+
createAgent(request: CreateAgentRequest): Promise<BaseApiObject>;
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves an existing Agent in the Workspace.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} ref - The reference of the Agent to retrieve
|
|
83
|
+
* @return {Promise<Acl>} - The response object that contains the Agent information
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
87
|
+
*
|
|
88
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
89
|
+
*
|
|
90
|
+
* agents.getAgent(ref)
|
|
91
|
+
* .then(console.log) // successful response
|
|
92
|
+
* .catch(console.error); // an error occurred
|
|
93
|
+
*/
|
|
94
|
+
getAgent(ref: string): Promise<Agent>;
|
|
95
|
+
/**
|
|
96
|
+
* Updates an existing Agent in the Workspace.
|
|
97
|
+
*
|
|
98
|
+
* @param {UpdateAgentRequest} request - The request object that contains the necessary information to update an existing Agent
|
|
99
|
+
* @param {string} request.ref - The reference of the Agent to update
|
|
100
|
+
* @param {string} request.name - The name of the Agent
|
|
101
|
+
* @param {Privacy} request.privacy - The privacy of the Agent
|
|
102
|
+
* @param {boolean} request.enabled - The status of the Agent
|
|
103
|
+
* @param {number} request.maxContacts - The maximum number of contacts the Agent can have
|
|
104
|
+
* @param {string} request.domainRef - The reference of the Domain to associate the Agent
|
|
105
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Agent
|
|
106
|
+
* @example
|
|
107
|
+
*
|
|
108
|
+
* const request = {
|
|
109
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
110
|
+
* name: "John Doe",
|
|
111
|
+
* privacy: "PRIVATE",
|
|
112
|
+
* enabled: true,
|
|
113
|
+
* maxContacts: 3
|
|
114
|
+
* domainRef: "00000000-0000-0000-0000-000000000000"
|
|
115
|
+
* };
|
|
116
|
+
*
|
|
117
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
118
|
+
*
|
|
119
|
+
* agents.updateAgent(request)
|
|
120
|
+
* .then(console.log) // successful response
|
|
121
|
+
* .catch(console.error); // an error occurred
|
|
122
|
+
*/
|
|
123
|
+
updateAgent(request: UpdateAgentRequest): Promise<BaseApiObject>;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves a list of Agents from a Workspace.
|
|
126
|
+
*
|
|
127
|
+
* @param {ListAgentsRequest} request - The request object that contains the necessary information to retrieve a list of Agents
|
|
128
|
+
* @param {number} request.pageSize - The number of Agents to retrieve
|
|
129
|
+
* @param {string} request.pageToken - The token to retrieve the next page of Agents
|
|
130
|
+
* @return {Promise<ListAgentsResponse>} - The response object that contains the list of Agents
|
|
131
|
+
* @example
|
|
132
|
+
*
|
|
133
|
+
* const request = {
|
|
134
|
+
* pageSize: 10,
|
|
135
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
136
|
+
* };
|
|
137
|
+
*
|
|
138
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
139
|
+
*
|
|
140
|
+
* agents.listAgents(request)
|
|
141
|
+
* .then(console.log) // successful response
|
|
142
|
+
* .catch(console.error); // an error occurred
|
|
143
|
+
*/
|
|
144
|
+
listAgents(request: ListAgentsRequest): Promise<ListAgentsResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Deletes an existing Agent from Fonoster.
|
|
147
|
+
* Note that this operation is irreversible.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} ref - The reference of the Agent to delete
|
|
150
|
+
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Agent
|
|
151
|
+
* @example
|
|
152
|
+
*
|
|
153
|
+
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
154
|
+
*
|
|
155
|
+
* const agents = new SDK.Agents(client); // Existing client object
|
|
156
|
+
*
|
|
157
|
+
* agents.deleteAgent(ref)
|
|
158
|
+
* .then(console.log) // successful response
|
|
159
|
+
* .catch(console.error); // an error occurred
|
|
160
|
+
*/
|
|
161
|
+
deleteAgent(ref: string): Promise<BaseApiObject>;
|
|
162
|
+
}
|
|
163
|
+
export { Agents };
|