-
Notifications
You must be signed in to change notification settings - Fork 14
/
functions.ts
72 lines (45 loc) · 3.17 KB
/
functions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {BaseUtility, IngredientManager} from '@azbake/core'
import { ServiceBusManagementClient } from "@azure/arm-servicebus";
export class ServiceBusNamespaceUtils extends BaseUtility {
public create_resource_name(): string {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
const name = util.create_resource_name("sbn", null, true);
return name;
}
public async get_endpoint(nsName: string, rg: string | null = null): Promise<string> {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new ServiceBusManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.namespaces.get(resource_group, nsName);
// client.namespaces.listKeys(resource_group,)
return response.serviceBusEndpoint || "";
}
public async get_primary_key(nsName: string, authRuleName: string, rg: string | null = null) : Promise<string> {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new ServiceBusManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.namespaces.listKeys(resource_group, nsName, authRuleName);
return response.primaryKey || "";
}
public async get_secondary_key(nsName: string, authRuleName: string, rg: string | null = null) : Promise<string> {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new ServiceBusManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.namespaces.listKeys(resource_group, nsName, authRuleName);
return response.secondaryKey || "";
}
public async get_primary_connection_string(nsName: string, authRuleName: string, rg: string | null = null) : Promise<string> {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new ServiceBusManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.namespaces.listKeys(resource_group, nsName, authRuleName);
return response.primaryConnectionString || "";
}
public async get_secondary_connection_string(nsName: string, authRuleName: string, rg: string | null = null) : Promise<string> {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new ServiceBusManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.namespaces.listKeys(resource_group, nsName, authRuleName);
return response.secondaryConnectionString || "";
}
}