Skip to content

Commit

Permalink
Nullable parameters, part 1 (api, api/policies)
Browse files Browse the repository at this point in the history
  • Loading branch information
krbar committed Dec 9, 2023
1 parent bd6b1b5 commit 1c7d815
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 142 deletions.
12 changes: 0 additions & 12 deletions avm/res/api-management/service/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,20 @@ Description of the API. May include HTML formatting tags.

- Required: No
- Type: string
- Default: `''`

### Parameter: `apiRevision`

Describes the Revision of the API. If no value is provided, default revision 1 is created.

- Required: No
- Type: string
- Default: `''`

### Parameter: `apiRevisionDescription`

Description of the API Revision.

- Required: No
- Type: string
- Default: `''`

### Parameter: `apiType`

Expand All @@ -131,31 +128,27 @@ Indicates the Version identifier of the API if the API is versioned.

- Required: No
- Type: string
- Default: `''`

### Parameter: `apiVersionDescription`

Description of the API Version.

- Required: No
- Type: string
- Default: `''`

### Parameter: `apiVersionSetId`

Indicates the Version identifier of the API version set.

- Required: No
- Type: string
- Default: `''`

### Parameter: `authenticationSettings`

Collection of authentication settings included into this API.

- Required: No
- Type: object
- Default: `{}`

### Parameter: `format`

Expand Down Expand Up @@ -215,23 +208,20 @@ Absolute URL of the backend service implementing this API. Cannot be more than 2

- Required: No
- Type: string
- Default: `''`

### Parameter: `sourceApiId`

API identifier of the source API.

- Required: No
- Type: string
- Default: `''`

### Parameter: `subscriptionKeyParameterNames`

Protocols over which API is made available.

- Required: No
- Type: object
- Default: `{}`

### Parameter: `subscriptionRequired`

Expand Down Expand Up @@ -264,15 +254,13 @@ Content value when Importing an API.

- Required: No
- Type: string
- Default: `''`

### Parameter: `wsdlSelector`

Criteria to limit import of WSDL to a subset of the document.

- Required: No
- Type: object
- Default: `{}`


## Outputs
Expand Down
50 changes: 25 additions & 25 deletions avm/res/api-management/service/api/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ param policies array = []
param apiManagementServiceName string

@description('Optional. Describes the Revision of the API. If no value is provided, default revision 1 is created.')
param apiRevision string = ''
param apiRevision string?

@description('Optional. Description of the API Revision.')
param apiRevisionDescription string = ''
param apiRevisionDescription string?

@description('Optional. Type of API to create. * http creates a REST API * soap creates a SOAP pass-through API * websocket creates websocket API * graphql creates GraphQL API.')
@allowed([
Expand All @@ -27,19 +27,19 @@ param apiRevisionDescription string = ''
param apiType string = 'http'

@description('Optional. Indicates the Version identifier of the API if the API is versioned.')
param apiVersion string = ''
param apiVersion string?

@description('Optional. Indicates the Version identifier of the API version set.')
param apiVersionSetId string = ''
param apiVersionSetId string?

@description('Optional. Description of the API Version.')
param apiVersionDescription string = ''
param apiVersionDescription string?

@description('Optional. Collection of authentication settings included into this API.')
param authenticationSettings object = {}
param authenticationSettings object?

@description('Optional. Description of the API. May include HTML formatting tags.')
param apiDescription string = ''
param apiDescription string?

@description('Required. API name. Must be 1 to 300 characters long.')
@maxLength(300)
Expand Down Expand Up @@ -73,13 +73,13 @@ param protocols array = [

@description('Optional. Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.')
@maxLength(2000)
param serviceUrl string = ''
param serviceUrl string?

@description('Optional. API identifier of the source API.')
param sourceApiId string = ''
param sourceApiId string?

@description('Optional. Protocols over which API is made available.')
param subscriptionKeyParameterNames object = {}
param subscriptionKeyParameterNames object?

@description('Optional. Specifies whether an API or Product subscription is required for accessing the API.')
param subscriptionRequired bool = false
Expand All @@ -94,10 +94,10 @@ param subscriptionRequired bool = false
param type string = 'http'

@description('Optional. Content value when Importing an API.')
param value string = ''
param value string?

@description('Optional. Criteria to limit import of WSDL to a subset of the document.')
param wsdlSelector object = {}
param wsdlSelector object?

resource service 'Microsoft.ApiManagement/service@2021-08-01' existing = {
name: apiManagementServiceName
Expand All @@ -107,26 +107,26 @@ resource api 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
name: name
parent: service
properties: {
apiRevision: !empty(apiRevision) ? apiRevision : null
apiRevisionDescription: !empty(apiRevisionDescription) ? apiRevisionDescription : null
apiType: !empty(apiType) ? apiType : null
apiVersion: !empty(apiVersion) ? apiVersion : null
apiVersionDescription: !empty(apiVersionDescription) ? apiVersionDescription : null
apiVersionSetId: !empty(apiVersionSetId) ? apiVersionSetId : null
authenticationSettings: authenticationSettings
description: apiDescription
apiRevision: apiRevision
apiRevisionDescription: apiRevisionDescription
apiType: apiType
apiVersion: apiVersion
apiVersionDescription: apiVersionDescription
apiVersionSetId: apiVersionSetId
authenticationSettings: authenticationSettings ?? {}
description: apiDescription ?? ''
displayName: displayName
format: !empty(value) ? format : null
isCurrent: isCurrent
path: path
protocols: protocols
serviceUrl: !empty(serviceUrl) ? serviceUrl : null
sourceApiId: !empty(sourceApiId) ? sourceApiId : null
subscriptionKeyParameterNames: !empty(subscriptionKeyParameterNames) ? subscriptionKeyParameterNames : null
serviceUrl: serviceUrl
sourceApiId: sourceApiId
subscriptionKeyParameterNames: subscriptionKeyParameterNames
subscriptionRequired: subscriptionRequired
type: type
value: !empty(value) ? value : null
wsdlSelector: wsdlSelector
value: value
wsdlSelector: wsdlSelector ?? {}
}
}

Expand Down
74 changes: 42 additions & 32 deletions avm/res/api-management/service/api/main.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.23.1.45101",
"templateHash": "3782651839276159285"
"templateHash": "6833640993258659219"
},
"name": "API Management Service APIs",
"description": "This module deploys an API Management Service API.",
Expand Down Expand Up @@ -33,14 +34,14 @@
},
"apiRevision": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Describes the Revision of the API. If no value is provided, default revision 1 is created."
}
},
"apiRevisionDescription": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Description of the API Revision."
}
Expand All @@ -60,35 +61,35 @@
},
"apiVersion": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Indicates the Version identifier of the API if the API is versioned."
}
},
"apiVersionSetId": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Indicates the Version identifier of the API version set."
}
},
"apiVersionDescription": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Description of the API Version."
}
},
"authenticationSettings": {
"type": "object",
"defaultValue": {},
"nullable": true,
"metadata": {
"description": "Optional. Collection of authentication settings included into this API."
}
},
"apiDescription": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Description of the API. May include HTML formatting tags."
}
Expand Down Expand Up @@ -143,22 +144,22 @@
},
"serviceUrl": {
"type": "string",
"defaultValue": "",
"nullable": true,
"maxLength": 2000,
"metadata": {
"description": "Optional. Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long."
}
},
"sourceApiId": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. API identifier of the source API."
}
},
"subscriptionKeyParameterNames": {
"type": "object",
"defaultValue": {},
"nullable": true,
"metadata": {
"description": "Optional. Protocols over which API is made available."
}
Expand All @@ -185,48 +186,57 @@
},
"value": {
"type": "string",
"defaultValue": "",
"nullable": true,
"metadata": {
"description": "Optional. Content value when Importing an API."
}
},
"wsdlSelector": {
"type": "object",
"defaultValue": {},
"nullable": true,
"metadata": {
"description": "Optional. Criteria to limit import of WSDL to a subset of the document."
}
}
},
"resources": [
{
"resources": {
"service": {
"existing": true,
"type": "Microsoft.ApiManagement/service",
"apiVersion": "2021-08-01",
"name": "[parameters('apiManagementServiceName')]"
},
"api": {
"type": "Microsoft.ApiManagement/service/apis",
"apiVersion": "2021-08-01",
"name": "[format('{0}/{1}', parameters('apiManagementServiceName'), parameters('name'))]",
"properties": {
"apiRevision": "[if(not(empty(parameters('apiRevision'))), parameters('apiRevision'), null())]",
"apiRevisionDescription": "[if(not(empty(parameters('apiRevisionDescription'))), parameters('apiRevisionDescription'), null())]",
"apiType": "[if(not(empty(parameters('apiType'))), parameters('apiType'), null())]",
"apiVersion": "[if(not(empty(parameters('apiVersion'))), parameters('apiVersion'), null())]",
"apiVersionDescription": "[if(not(empty(parameters('apiVersionDescription'))), parameters('apiVersionDescription'), null())]",
"apiVersionSetId": "[if(not(empty(parameters('apiVersionSetId'))), parameters('apiVersionSetId'), null())]",
"authenticationSettings": "[parameters('authenticationSettings')]",
"description": "[parameters('apiDescription')]",
"apiRevision": "[parameters('apiRevision')]",
"apiRevisionDescription": "[parameters('apiRevisionDescription')]",
"apiType": "[parameters('apiType')]",
"apiVersion": "[parameters('apiVersion')]",
"apiVersionDescription": "[parameters('apiVersionDescription')]",
"apiVersionSetId": "[parameters('apiVersionSetId')]",
"authenticationSettings": "[coalesce(parameters('authenticationSettings'), createObject())]",
"description": "[coalesce(parameters('apiDescription'), '')]",
"displayName": "[parameters('displayName')]",
"format": "[if(not(empty(parameters('value'))), parameters('format'), null())]",
"isCurrent": "[parameters('isCurrent')]",
"path": "[parameters('path')]",
"protocols": "[parameters('protocols')]",
"serviceUrl": "[if(not(empty(parameters('serviceUrl'))), parameters('serviceUrl'), null())]",
"sourceApiId": "[if(not(empty(parameters('sourceApiId'))), parameters('sourceApiId'), null())]",
"subscriptionKeyParameterNames": "[if(not(empty(parameters('subscriptionKeyParameterNames'))), parameters('subscriptionKeyParameterNames'), null())]",
"serviceUrl": "[parameters('serviceUrl')]",
"sourceApiId": "[parameters('sourceApiId')]",
"subscriptionKeyParameterNames": "[parameters('subscriptionKeyParameterNames')]",
"subscriptionRequired": "[parameters('subscriptionRequired')]",
"type": "[parameters('type')]",
"value": "[if(not(empty(parameters('value'))), parameters('value'), null())]",
"wsdlSelector": "[parameters('wsdlSelector')]"
}
"value": "[parameters('value')]",
"wsdlSelector": "[coalesce(parameters('wsdlSelector'), createObject())]"
},
"dependsOn": [
"service"
]
},
{
"policy": {
"copy": {
"name": "policy",
"count": "[length(parameters('policies'))]"
Expand Down Expand Up @@ -341,10 +351,10 @@
}
},
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apiManagementServiceName'), parameters('name'))]"
"api"
]
}
],
},
"outputs": {
"name": {
"type": "string",
Expand Down
Loading

0 comments on commit 1c7d815

Please sign in to comment.