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

Add APIVersion and APIVersionSetID to import #4993

Merged
merged 3 commits into from
Dec 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions azurerm/resource_arm_api_management_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ func resourceArmApiManagementApiCreateUpdate(d *schema.ResourceData, meta interf
revision := d.Get("revision").(string)
path := d.Get("path").(string)
apiId := fmt.Sprintf("%s;rev=%s", name, revision)
version := d.Get("version").(string)
versionSetId := d.Get("version_set_id").(string)

if features.ShouldResourcesBeImported() && d.IsNewResource() {
existing, err := client.Get(ctx, resourceGroup, serviceName, apiId)
Expand Down Expand Up @@ -230,6 +232,7 @@ func resourceArmApiManagementApiCreateUpdate(d *schema.ResourceData, meta interf
ContentFormat: apimanagement.ContentFormat(contentFormat),
ContentValue: utils.String(contentValue),
Path: utils.String(path),
APIVersion: utils.String(version),
},
}
wsdlSelectorVs := importV["wsdl_selector"].([]interface{})
Expand All @@ -244,6 +247,10 @@ func resourceArmApiManagementApiCreateUpdate(d *schema.ResourceData, meta interf
}
}

if versionSetId != "" {
apiParams.APICreateOrUpdateProperties.APIVersionSetID = utils.String(versionSetId)
}

if _, err := client.CreateOrUpdate(ctx, resourceGroup, serviceName, apiId, apiParams, ""); err != nil {
return fmt.Errorf("Error creating/updating API Management API %q (Resource Group %q): %+v", name, resourceGroup, err)
}
Expand All @@ -253,9 +260,6 @@ 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)

if version != "" && versionSetId == "" {
return fmt.Errorf("Error setting `version` without the required `version_set_id`")
sam-cogan marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down