@gradientedge/cdk-utils 9.34.0 → 9.35.0
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/dist/src/lib/azure/services/api-management/main.d.ts +30 -2
- package/dist/src/lib/azure/services/api-management/main.js +114 -1
- package/dist/src/lib/azure/services/api-management/types.d.ts +14 -0
- package/package.json +1 -1
- package/src/lib/azure/services/api-management/main.ts +161 -2
- package/src/lib/azure/services/api-management/types.ts +16 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { DataAzurermApiManagement, DataAzurermApiManagementConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management';
|
|
2
|
+
import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend';
|
|
1
3
|
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management';
|
|
4
|
+
import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api';
|
|
5
|
+
import { ApiManagementLoggerApplicationInsights } from '@cdktf/provider-azurerm/lib/api-management-logger';
|
|
2
6
|
import { CommonAzureConstruct } from '../../common';
|
|
3
|
-
import { ApiManagementProps } from './types';
|
|
7
|
+
import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps } from './types';
|
|
4
8
|
/**
|
|
5
9
|
* @classdesc Provides operations on Azure Api Management
|
|
6
10
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -26,5 +30,29 @@ export declare class AzureApiManagementManager {
|
|
|
26
30
|
* @param props api management properties
|
|
27
31
|
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
28
32
|
*/
|
|
29
|
-
createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps): ApiManagement;
|
|
33
|
+
createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey']): ApiManagement;
|
|
34
|
+
/**
|
|
35
|
+
* @summary Method to resolve an api management
|
|
36
|
+
* @param id scoped id of the resource
|
|
37
|
+
* @param scope scope in which this resource is defined
|
|
38
|
+
* @param props api management properties
|
|
39
|
+
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
40
|
+
*/
|
|
41
|
+
resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig): DataAzurermApiManagement;
|
|
42
|
+
/**
|
|
43
|
+
* @summary Method to create a new api management backend
|
|
44
|
+
* @param id scoped id of the resource
|
|
45
|
+
* @param scope scope in which this resource is defined
|
|
46
|
+
* @param props api management backend properties
|
|
47
|
+
* @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
|
|
48
|
+
*/
|
|
49
|
+
createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps): ApiManagementBackend;
|
|
50
|
+
/**
|
|
51
|
+
* @summary Method to create a new api management api
|
|
52
|
+
* @param id scoped id of the resource
|
|
53
|
+
* @param scope scope in which this resource is defined
|
|
54
|
+
* @param props api management api properties
|
|
55
|
+
* @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
|
|
56
|
+
*/
|
|
57
|
+
createApiManagementApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps): ApiManagementApi;
|
|
30
58
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AzureApiManagementManager = void 0;
|
|
4
7
|
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
8
|
+
const data_azurerm_api_management_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-api-management");
|
|
9
|
+
const api_management_backend_1 = require("@cdktf/provider-azurerm/lib/api-management-backend");
|
|
5
10
|
const api_management_1 = require("@cdktf/provider-azurerm/lib/api-management");
|
|
11
|
+
const api_management_api_1 = require("@cdktf/provider-azurerm/lib/api-management-api");
|
|
12
|
+
const api_management_api_operation_1 = require("@cdktf/provider-azurerm/lib/api-management-api-operation");
|
|
13
|
+
const api_management_api_operation_policy_1 = require("@cdktf/provider-azurerm/lib/api-management-api-operation-policy");
|
|
14
|
+
const api_management_logger_1 = require("@cdktf/provider-azurerm/lib/api-management-logger");
|
|
6
15
|
const utils_1 = require("../../utils");
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
17
|
/**
|
|
8
18
|
* @classdesc Provides operations on Azure Api Management
|
|
9
19
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -29,7 +39,7 @@ class AzureApiManagementManager {
|
|
|
29
39
|
* @param props api management properties
|
|
30
40
|
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
31
41
|
*/
|
|
32
|
-
createApiManagement(id, scope, props) {
|
|
42
|
+
createApiManagement(id, scope, props, applicationInsightsKey) {
|
|
33
43
|
if (!props)
|
|
34
44
|
throw `Props undefined for ${id}`;
|
|
35
45
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
@@ -47,10 +57,113 @@ class AzureApiManagementManager {
|
|
|
47
57
|
environment: scope.props.stage,
|
|
48
58
|
},
|
|
49
59
|
});
|
|
60
|
+
if (applicationInsightsKey) {
|
|
61
|
+
new api_management_logger_1.ApiManagementLogger(scope, `${id}-am-logger`, {
|
|
62
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
63
|
+
resourceGroupName: resourceGroup.name,
|
|
64
|
+
apiManagementName: apiManagement.name,
|
|
65
|
+
applicationInsights: {
|
|
66
|
+
instrumentationKey: applicationInsightsKey,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
50
70
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementName`, scope, apiManagement.name);
|
|
51
71
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId);
|
|
52
72
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementId`, scope, apiManagement.id);
|
|
53
73
|
return apiManagement;
|
|
54
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @summary Method to resolve an api management
|
|
77
|
+
* @param id scoped id of the resource
|
|
78
|
+
* @param scope scope in which this resource is defined
|
|
79
|
+
* @param props api management properties
|
|
80
|
+
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
81
|
+
*/
|
|
82
|
+
resolveApiManagement(id, scope, props) {
|
|
83
|
+
if (!props)
|
|
84
|
+
throw `Props undefined for ${id}`;
|
|
85
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
86
|
+
name: scope.props.resourceGroupName
|
|
87
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
88
|
+
: `${props.resourceGroupName}`,
|
|
89
|
+
});
|
|
90
|
+
if (!resourceGroup)
|
|
91
|
+
throw `Resource group undefined for ${id}`;
|
|
92
|
+
const apiManagement = new data_azurerm_api_management_1.DataAzurermApiManagement(scope, `${id}-am`, {
|
|
93
|
+
...props,
|
|
94
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
95
|
+
resourceGroupName: scope.props.resourceGroupName
|
|
96
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
97
|
+
: `${props.resourceGroupName}`,
|
|
98
|
+
});
|
|
99
|
+
return apiManagement;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @summary Method to create a new api management backend
|
|
103
|
+
* @param id scoped id of the resource
|
|
104
|
+
* @param scope scope in which this resource is defined
|
|
105
|
+
* @param props api management backend properties
|
|
106
|
+
* @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
|
|
107
|
+
*/
|
|
108
|
+
createApiManagementBackend(id, scope, props) {
|
|
109
|
+
if (!props)
|
|
110
|
+
throw `Props undefined for ${id}`;
|
|
111
|
+
const apiManagementBackend = new api_management_backend_1.ApiManagementBackend(scope, `${id}-am-be`, {
|
|
112
|
+
...props,
|
|
113
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
114
|
+
description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
|
|
115
|
+
protocol: props.protocol || 'http',
|
|
116
|
+
});
|
|
117
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name);
|
|
118
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId);
|
|
119
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendId`, scope, apiManagementBackend.id);
|
|
120
|
+
return apiManagementBackend;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @summary Method to create a new api management api
|
|
124
|
+
* @param id scoped id of the resource
|
|
125
|
+
* @param scope scope in which this resource is defined
|
|
126
|
+
* @param props api management api properties
|
|
127
|
+
* @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
|
|
128
|
+
*/
|
|
129
|
+
createApiManagementApi(id, scope, props) {
|
|
130
|
+
if (!props)
|
|
131
|
+
throw `Props undefined for ${id}`;
|
|
132
|
+
const apiManagementApi = new api_management_api_1.ApiManagementApi(scope, `${id}-am-api`, {
|
|
133
|
+
...props,
|
|
134
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
135
|
+
displayName: props.displayName || props.name,
|
|
136
|
+
revision: props.revision || '1',
|
|
137
|
+
protocols: props.protocols || ['https'],
|
|
138
|
+
subscriptionRequired: props.subscriptionRequired || true,
|
|
139
|
+
});
|
|
140
|
+
lodash_1.default.forEach(props.operations, operation => {
|
|
141
|
+
const apimOperation = new api_management_api_operation_1.ApiManagementApiOperation(scope, `${id}-apim-api-operation-${operation.path}-${operation.method}`, {
|
|
142
|
+
operationId: `${operation.path}-${operation.method}`,
|
|
143
|
+
method: operation.method.toUpperCase(),
|
|
144
|
+
apiManagementName: apiManagementApi.apiManagementName,
|
|
145
|
+
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
146
|
+
apiName: apiManagementApi.name,
|
|
147
|
+
displayName: `/${operation.path}`,
|
|
148
|
+
urlTemplate: `/${operation.path}`,
|
|
149
|
+
});
|
|
150
|
+
const apimOperationPolicy = new api_management_api_operation_policy_1.ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.path}-${operation.method}`, {
|
|
151
|
+
apiManagementName: apiManagementApi.apiManagementName,
|
|
152
|
+
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
153
|
+
apiName: apiManagementApi.name,
|
|
154
|
+
operationId: apimOperation.operationId,
|
|
155
|
+
xmlContent: operation.xmlContent,
|
|
156
|
+
});
|
|
157
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationOperationId`, scope, apimOperation.operationId);
|
|
158
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationFriendlyUniqueId`, scope, apimOperation.friendlyUniqueId);
|
|
159
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationId`, scope, apimOperation.id);
|
|
160
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`, scope, apimOperationPolicy.friendlyUniqueId);
|
|
161
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.path}-${operation.method}-apimOperationPolicyId`, scope, apimOperationPolicy.id);
|
|
162
|
+
});
|
|
163
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiName`, scope, apiManagementApi.name);
|
|
164
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
|
|
165
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiId`, scope, apiManagementApi.id);
|
|
166
|
+
return apiManagementApi;
|
|
167
|
+
}
|
|
55
168
|
}
|
|
56
169
|
exports.AzureApiManagementManager = AzureApiManagementManager;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { ApiManagementConfig } from '@cdktf/provider-azurerm/lib/api-management';
|
|
2
|
+
import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-management-backend';
|
|
3
|
+
import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api';
|
|
4
|
+
import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation';
|
|
5
|
+
import { ApiManagementApiOperationPolicyConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy';
|
|
2
6
|
export interface ApiManagementProps extends ApiManagementConfig {
|
|
3
7
|
}
|
|
8
|
+
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
9
|
+
}
|
|
10
|
+
export interface ApiManagementApiProps extends ApiManagementApiConfig {
|
|
11
|
+
operations: OperationsProps[];
|
|
12
|
+
}
|
|
13
|
+
export interface OperationsProps {
|
|
14
|
+
path: ApiManagementApiOperationConfig['urlTemplate'];
|
|
15
|
+
method: ApiManagementApiOperationConfig['method'];
|
|
16
|
+
xmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent'];
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
+
import {
|
|
3
|
+
DataAzurermApiManagement,
|
|
4
|
+
DataAzurermApiManagementConfig,
|
|
5
|
+
} from '@cdktf/provider-azurerm/lib/data-azurerm-api-management'
|
|
6
|
+
import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend'
|
|
2
7
|
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management'
|
|
8
|
+
import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api'
|
|
9
|
+
import { ApiManagementApiOperation } from '@cdktf/provider-azurerm/lib/api-management-api-operation'
|
|
10
|
+
import { ApiManagementApiOperationPolicy } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy'
|
|
11
|
+
import {
|
|
12
|
+
ApiManagementLogger,
|
|
13
|
+
ApiManagementLoggerApplicationInsights,
|
|
14
|
+
} from '@cdktf/provider-azurerm/lib/api-management-logger'
|
|
3
15
|
import { CommonAzureConstruct } from '../../common'
|
|
4
16
|
import { createAzureTfOutput } from '../../utils'
|
|
5
|
-
import { ApiManagementProps } from './types'
|
|
17
|
+
import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps } from './types'
|
|
18
|
+
import _ from 'lodash'
|
|
6
19
|
|
|
7
20
|
/**
|
|
8
21
|
* @classdesc Provides operations on Azure Api Management
|
|
@@ -29,7 +42,12 @@ export class AzureApiManagementManager {
|
|
|
29
42
|
* @param props api management properties
|
|
30
43
|
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
31
44
|
*/
|
|
32
|
-
public createApiManagement(
|
|
45
|
+
public createApiManagement(
|
|
46
|
+
id: string,
|
|
47
|
+
scope: CommonAzureConstruct,
|
|
48
|
+
props: ApiManagementProps,
|
|
49
|
+
applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey']
|
|
50
|
+
) {
|
|
33
51
|
if (!props) throw `Props undefined for ${id}`
|
|
34
52
|
|
|
35
53
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
@@ -49,10 +67,151 @@ export class AzureApiManagementManager {
|
|
|
49
67
|
},
|
|
50
68
|
})
|
|
51
69
|
|
|
70
|
+
if (applicationInsightsKey) {
|
|
71
|
+
new ApiManagementLogger(scope, `${id}-am-logger`, {
|
|
72
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
73
|
+
resourceGroupName: resourceGroup.name,
|
|
74
|
+
apiManagementName: apiManagement.name,
|
|
75
|
+
applicationInsights: {
|
|
76
|
+
instrumentationKey: applicationInsightsKey,
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
52
81
|
createAzureTfOutput(`${id}-apiManagementName`, scope, apiManagement.name)
|
|
53
82
|
createAzureTfOutput(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId)
|
|
54
83
|
createAzureTfOutput(`${id}-apiManagementId`, scope, apiManagement.id)
|
|
55
84
|
|
|
56
85
|
return apiManagement
|
|
57
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @summary Method to resolve an api management
|
|
90
|
+
* @param id scoped id of the resource
|
|
91
|
+
* @param scope scope in which this resource is defined
|
|
92
|
+
* @param props api management properties
|
|
93
|
+
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
94
|
+
*/
|
|
95
|
+
public resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig) {
|
|
96
|
+
if (!props) throw `Props undefined for ${id}`
|
|
97
|
+
|
|
98
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
99
|
+
name: scope.props.resourceGroupName
|
|
100
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
101
|
+
: `${props.resourceGroupName}`,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
105
|
+
|
|
106
|
+
const apiManagement = new DataAzurermApiManagement(scope, `${id}-am`, {
|
|
107
|
+
...props,
|
|
108
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
109
|
+
resourceGroupName: scope.props.resourceGroupName
|
|
110
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
111
|
+
: `${props.resourceGroupName}`,
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
return apiManagement
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @summary Method to create a new api management backend
|
|
119
|
+
* @param id scoped id of the resource
|
|
120
|
+
* @param scope scope in which this resource is defined
|
|
121
|
+
* @param props api management backend properties
|
|
122
|
+
* @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
|
|
123
|
+
*/
|
|
124
|
+
public createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
|
|
125
|
+
if (!props) throw `Props undefined for ${id}`
|
|
126
|
+
|
|
127
|
+
const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
|
|
128
|
+
...props,
|
|
129
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
130
|
+
description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
|
|
131
|
+
protocol: props.protocol || 'http',
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name)
|
|
135
|
+
createAzureTfOutput(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId)
|
|
136
|
+
createAzureTfOutput(`${id}-apiManagementBackendId`, scope, apiManagementBackend.id)
|
|
137
|
+
|
|
138
|
+
return apiManagementBackend
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @summary Method to create a new api management api
|
|
143
|
+
* @param id scoped id of the resource
|
|
144
|
+
* @param scope scope in which this resource is defined
|
|
145
|
+
* @param props api management api properties
|
|
146
|
+
* @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
|
|
147
|
+
*/
|
|
148
|
+
public createApiManagementApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
|
|
149
|
+
if (!props) throw `Props undefined for ${id}`
|
|
150
|
+
|
|
151
|
+
const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
|
|
152
|
+
...props,
|
|
153
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
154
|
+
displayName: props.displayName || props.name,
|
|
155
|
+
revision: props.revision || '1',
|
|
156
|
+
protocols: props.protocols || ['https'],
|
|
157
|
+
subscriptionRequired: props.subscriptionRequired || true,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
_.forEach(props.operations, operation => {
|
|
161
|
+
const apimOperation = new ApiManagementApiOperation(
|
|
162
|
+
scope,
|
|
163
|
+
`${id}-apim-api-operation-${operation.path}-${operation.method}`,
|
|
164
|
+
{
|
|
165
|
+
operationId: `${operation.path}-${operation.method}`,
|
|
166
|
+
method: operation.method.toUpperCase(),
|
|
167
|
+
apiManagementName: apiManagementApi.apiManagementName,
|
|
168
|
+
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
169
|
+
apiName: apiManagementApi.name,
|
|
170
|
+
displayName: `/${operation.path}`,
|
|
171
|
+
urlTemplate: `/${operation.path}`,
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const apimOperationPolicy = new ApiManagementApiOperationPolicy(
|
|
176
|
+
scope,
|
|
177
|
+
`${id}-apim-api-operation-policy-${operation.path}-${operation.method}`,
|
|
178
|
+
{
|
|
179
|
+
apiManagementName: apiManagementApi.apiManagementName,
|
|
180
|
+
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
181
|
+
apiName: apiManagementApi.name,
|
|
182
|
+
operationId: apimOperation.operationId,
|
|
183
|
+
xmlContent: operation.xmlContent,
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
createAzureTfOutput(
|
|
188
|
+
`${id}-${operation.path}-${operation.method}-apimOperationOperationId`,
|
|
189
|
+
scope,
|
|
190
|
+
apimOperation.operationId
|
|
191
|
+
)
|
|
192
|
+
createAzureTfOutput(
|
|
193
|
+
`${id}-${operation.path}-${operation.method}-apimOperationFriendlyUniqueId`,
|
|
194
|
+
scope,
|
|
195
|
+
apimOperation.friendlyUniqueId
|
|
196
|
+
)
|
|
197
|
+
createAzureTfOutput(`${id}-${operation.path}-${operation.method}-apimOperationId`, scope, apimOperation.id)
|
|
198
|
+
|
|
199
|
+
createAzureTfOutput(
|
|
200
|
+
`${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`,
|
|
201
|
+
scope,
|
|
202
|
+
apimOperationPolicy.friendlyUniqueId
|
|
203
|
+
)
|
|
204
|
+
createAzureTfOutput(
|
|
205
|
+
`${id}-${operation.path}-${operation.method}-apimOperationPolicyId`,
|
|
206
|
+
scope,
|
|
207
|
+
apimOperationPolicy.id
|
|
208
|
+
)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
|
|
212
|
+
createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId)
|
|
213
|
+
createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id)
|
|
214
|
+
|
|
215
|
+
return apiManagementApi
|
|
216
|
+
}
|
|
58
217
|
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
import { ApiManagementConfig } from '@cdktf/provider-azurerm/lib/api-management'
|
|
2
|
+
import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-management-backend'
|
|
3
|
+
import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api'
|
|
4
|
+
import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation'
|
|
5
|
+
import { ApiManagementApiOperationPolicyConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy'
|
|
2
6
|
|
|
3
7
|
export interface ApiManagementProps extends ApiManagementConfig {}
|
|
8
|
+
|
|
9
|
+
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {}
|
|
10
|
+
|
|
11
|
+
export interface ApiManagementApiProps extends ApiManagementApiConfig {
|
|
12
|
+
operations: OperationsProps[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OperationsProps {
|
|
16
|
+
path: ApiManagementApiOperationConfig['urlTemplate']
|
|
17
|
+
method: ApiManagementApiOperationConfig['method']
|
|
18
|
+
xmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
|
|
19
|
+
}
|