-
Notifications
You must be signed in to change notification settings - Fork 14
/
functions.ts
80 lines (58 loc) · 4.11 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
73
74
75
76
77
78
79
import {BaseUtility, IngredientManager} from '@azbake/core'
import { NetworkManagementClient } from "@azure/arm-network";
export class NetworkInterfaceUtils extends BaseUtility {
public create_resource_name() {
let util = IngredientManager.getIngredientFunction("coreutils", this.context)
const name = util.create_resource_name("ni", null, false);
return name;
}
public async get(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response;
}
public async get_mac_address(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.macAddress;
}
public async get_ip_configurations(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.ipConfigurations;
}
public async get_virtual_machine(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.virtualMachine;
}
public async get_dns_settings(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.dnsSettings;
}
public async get_primary(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.primary;
}
public async get_enable_ip_forwarding(nicName: string, rg: string | null = null) {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let resource_group = rg || await util.resource_group();
const client = new NetworkManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.networkInterfaces.get( resource_group, nicName)
return response.enableIPForwarding;
}
}