Skip to content

Commit

Permalink
Docs: Fix 'azurerm_api_management_api_operation' example (#23741)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhcp committed Nov 1, 2023
1 parent 391cd4b commit 183cd43
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ func TestAccApiManagementApiOperation_representations(t *testing.T) {
})
}

func TestAccApiManagementApiOperation_templateParameter(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_api_management_api_operation", "test")
r := ApiManagementApiOperationResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.templateParameter(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccApiManagementApiOperation_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_api_management_api_operation", "test")
r := ApiManagementApiOperationResource{}
Expand Down Expand Up @@ -551,6 +566,33 @@ SAMPLE
`, r.template(data))
}

func (r ApiManagementApiOperationResource) templateParameter(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_api_management_api_operation" "test" {
operation_id = "acctest-operation"
api_name = azurerm_api_management_api.test.name
api_management_name = azurerm_api_management.test.name
resource_group_name = azurerm_resource_group.test.name
display_name = "Acceptance Test Operation"
method = "DELETE"
url_template = "/users/{id}/delete"
description = "This can only be done by the logged in user."
template_parameter {
name = "id"
type = "number"
required = true
}
response {
status_code = 200
}
}
`, r.template(data))
}

func (ApiManagementApiOperationResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
8 changes: 7 additions & 1 deletion website/docs/r/api_management_api_operation.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ resource "azurerm_api_management_api_operation" "example" {
url_template = "/users/{id}/delete"
description = "This can only be done by the logged in user."
template_parameter {
name = "id"
type = "number"
required = true
}
response {
status_code = 200
}
Expand Down Expand Up @@ -62,7 +68,7 @@ The following arguments are supported:

* `response` - (Optional) One or more `response` blocks as defined below.

* `template_parameter` - (Optional) One or more `template_parameter` blocks as defined below.
* `template_parameter` - (Optional) One or more `template_parameter` blocks as defined below. Required if `url_template` contains one or more parameters.

---

Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/api_management_api_operation_tag.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ resource "azurerm_api_management_api_operation" "example" {
url_template = "/users/{id}/delete"
description = "This can only be done by the logged in user."
template_parameter {
name = "id"
type = "number"
required = true
}
response {
status_code = 200
}
Expand Down

0 comments on commit 183cd43

Please sign in to comment.