-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Helper functions for Service Bus namespace ingredient (#64)
- Loading branch information
1 parent
f954ebb
commit fc68cf8
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 63 additions & 1 deletion
64
ingredient/ingredient-service-bus-namespace/src/functions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,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) | ||
let util = IngredientManager.getIngredientFunction("coreutils", this.context); | ||
const name = util.create_resource_name("sbn", null, false); | ||
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 || ""; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.