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

azure_cognitive_deployment - Changes model.version property from Required to Optional. #24264

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Next Next commit
add source property and update doc
liuwuliuyun committed Dec 15, 2023
commit 7121ef55cec3e41583f9b4f5a9f72e2521934209
20 changes: 19 additions & 1 deletion internal/services/cognitive/cognitive_deployment_resource.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/deployments"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
@@ -32,6 +33,7 @@ type cognitiveDeploymentModel struct {
type DeploymentModelModel struct {
Format string `tfschema:"format"`
Name string `tfschema:"name"`
Source string `tfschema:"source"`
Version string `tfschema:"version"`
}

@@ -98,9 +100,15 @@ func (r CognitiveDeploymentResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: validation.StringIsNotEmpty,
},

"source": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this is a resource id wouldn't it make more sense to have it be

Suggested change
"source": {
"source_resource_id": {

Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: azure.ValidateResourceID,
},

"version": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
},
},
},
@@ -411,6 +419,10 @@ func expandDeploymentModelModel(inputList []DeploymentModelModel) *deployments.D
output.Name = &input.Name
}

if input.Source != "" {
output.Source = &input.Source
}

if input.Version != "" {
output.Version = &input.Version
}
@@ -461,6 +473,12 @@ func flattenDeploymentModelModel(input *deployments.DeploymentModel) []Deploymen
}
output.Name = name

source := ""
if input.Source != nil {
source = *input.Source
}
output.Source = source

version := ""
if input.Version != nil {
version = *input.Version
4 changes: 3 additions & 1 deletion website/docs/r/cognitive_deployment.html.markdown
Original file line number Diff line number Diff line change
@@ -66,7 +66,9 @@ A `model` block supports the following:

* `name` - (Required) The name of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created.

* `version` - (Required) The version of Cognitive Services Account Deployment model.
* `source` - (Optional) Deployment model source ARM resource ID.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a valid resource here? could we expand on the docs a bit more


* `version` - (Optional) The version of Cognitive Services Account Deployment model. If `version` is not specified, a default version will be assigned. The default version is different for different models and might change when there is new version available for a model.
liuwuliuyun marked this conversation as resolved.
Show resolved Hide resolved

---