Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_api_management_api - the version and version_set_id properties can now be set #4592

Merged
merged 12 commits into from
Nov 8, 2019
45 changes: 33 additions & 12 deletions azurerm/resource_arm_api_management_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ func resourceArmApiManagementApi() *schema.Resource {

"version": {
Type: schema.TypeString,
Computed: true,
Optional: true,
kraihn marked this conversation as resolved.
Show resolved Hide resolved
},

"version_set_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
},
}
Expand Down Expand Up @@ -243,6 +243,9 @@ func resourceArmApiManagementApiCreateUpdate(d *schema.ResourceData, meta interf
displayName := d.Get("display_name").(string)
serviceUrl := d.Get("service_url").(string)

version := d.Get("version").(string)
versionSetId := d.Get("version_set_id").(string)
kraihn marked this conversation as resolved.
Show resolved Hide resolved

protocolsRaw := d.Get("protocols").(*schema.Set).List()
protocols := expandApiManagementApiProtocols(protocolsRaw)

Expand All @@ -257,16 +260,34 @@ func resourceArmApiManagementApiCreateUpdate(d *schema.ResourceData, meta interf
apiType = apimanagement.APIType(apimanagement.SoapToRest)
}

params := apimanagement.APICreateOrUpdateParameter{
APICreateOrUpdateProperties: &apimanagement.APICreateOrUpdateProperties{
APIType: apiType,
Description: utils.String(description),
DisplayName: utils.String(displayName),
Path: utils.String(path),
Protocols: protocols,
ServiceURL: utils.String(serviceUrl),
SubscriptionKeyParameterNames: subscriptionKeyParameterNames,
},
var params apimanagement.APICreateOrUpdateParameter
if versionSetId != "" {
kraihn marked this conversation as resolved.
Show resolved Hide resolved
params = apimanagement.APICreateOrUpdateParameter{
APICreateOrUpdateProperties: &apimanagement.APICreateOrUpdateProperties{
APIType: apiType,
Description: utils.String(description),
DisplayName: utils.String(displayName),
Path: utils.String(path),
Protocols: protocols,
ServiceURL: utils.String(serviceUrl),
SubscriptionKeyParameterNames: subscriptionKeyParameterNames,
APIVersion: utils.String(version),
APIVersionSetID: utils.String(versionSetId),
},
}
} else {
params = apimanagement.APICreateOrUpdateParameter{
APICreateOrUpdateProperties: &apimanagement.APICreateOrUpdateProperties{
APIType: apiType,
Description: utils.String(description),
DisplayName: utils.String(displayName),
Path: utils.String(path),
Protocols: protocols,
ServiceURL: utils.String(serviceUrl),
SubscriptionKeyParameterNames: subscriptionKeyParameterNames,
APIVersion: utils.String(version),
},
}
}

if _, err := client.CreateOrUpdate(ctx, resourceGroup, serviceName, apiId, params, ""); err != nil {
Expand Down