/
policyRestrictions.ts
154 lines (147 loc) · 5.37 KB
/
policyRestrictions.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { PolicyRestrictions } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { PolicyInsightsClient } from "../policyInsightsClient";
import {
CheckRestrictionsRequest,
PolicyRestrictionsCheckAtSubscriptionScopeOptionalParams,
PolicyRestrictionsCheckAtSubscriptionScopeResponse,
PolicyRestrictionsCheckAtResourceGroupScopeOptionalParams,
PolicyRestrictionsCheckAtResourceGroupScopeResponse,
CheckManagementGroupRestrictionsRequest,
PolicyRestrictionsCheckAtManagementGroupScopeOptionalParams,
PolicyRestrictionsCheckAtManagementGroupScopeResponse
} from "../models";
/** Class containing PolicyRestrictions operations. */
export class PolicyRestrictionsImpl implements PolicyRestrictions {
private readonly client: PolicyInsightsClient;
/**
* Initialize a new instance of the class PolicyRestrictions class.
* @param client Reference to the service client
*/
constructor(client: PolicyInsightsClient) {
this.client = client;
}
/**
* Checks what restrictions Azure Policy will place on a resource within a subscription.
* @param parameters The check policy restrictions parameters.
* @param options The options parameters.
*/
checkAtSubscriptionScope(
parameters: CheckRestrictionsRequest,
options?: PolicyRestrictionsCheckAtSubscriptionScopeOptionalParams
): Promise<PolicyRestrictionsCheckAtSubscriptionScopeResponse> {
return this.client.sendOperationRequest(
{ parameters, options },
checkAtSubscriptionScopeOperationSpec
);
}
/**
* Checks what restrictions Azure Policy will place on a resource within a resource group. Use this
* when the resource group the resource will be created in is already known.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param parameters The check policy restrictions parameters.
* @param options The options parameters.
*/
checkAtResourceGroupScope(
resourceGroupName: string,
parameters: CheckRestrictionsRequest,
options?: PolicyRestrictionsCheckAtResourceGroupScopeOptionalParams
): Promise<PolicyRestrictionsCheckAtResourceGroupScopeResponse> {
return this.client.sendOperationRequest(
{ resourceGroupName, parameters, options },
checkAtResourceGroupScopeOperationSpec
);
}
/**
* Checks what restrictions Azure Policy will place on resources within a management group.
* @param managementGroupId Management group ID.
* @param parameters The check policy restrictions parameters.
* @param options The options parameters.
*/
checkAtManagementGroupScope(
managementGroupId: string,
parameters: CheckManagementGroupRestrictionsRequest,
options?: PolicyRestrictionsCheckAtManagementGroupScopeOptionalParams
): Promise<PolicyRestrictionsCheckAtManagementGroupScopeResponse> {
return this.client.sendOperationRequest(
{ managementGroupId, parameters, options },
checkAtManagementGroupScopeOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const checkAtSubscriptionScopeOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.CheckRestrictionsResult
},
default: {
bodyMapper: Mappers.ErrorResponseAutoGenerated
}
},
requestBody: Parameters.parameters1,
queryParameters: [Parameters.apiVersion3],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const checkAtResourceGroupScopeOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.CheckRestrictionsResult
},
default: {
bodyMapper: Mappers.ErrorResponseAutoGenerated
}
},
requestBody: Parameters.parameters1,
queryParameters: [Parameters.apiVersion3],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName1
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const checkAtManagementGroupScopeOperationSpec: coreClient.OperationSpec = {
path:
"/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.CheckRestrictionsResult
},
default: {
bodyMapper: Mappers.ErrorResponseAutoGenerated
}
},
requestBody: Parameters.parameters2,
queryParameters: [Parameters.apiVersion3],
urlParameters: [
Parameters.$host,
Parameters.managementGroupsNamespace,
Parameters.managementGroupId
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};