Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hqhqhqhqhqhqhqhqhqhqhq committed Aug 26, 2024
1 parent 856bbb7 commit bd951c3
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 24 deletions.
15 changes: 14 additions & 1 deletion docs/data-sources/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ output "quarantine_policy" {
For type `Microsoft.Resources/resourceGroups`, the `parent_id` could be omitted, it defaults to subscription ID specified in provider or the default subscription (You could check the default subscription by azure cli command: `az account show`).
- `query_parameters` (Map of List of String) A map of query parameters to include in the request
- `resource_id` (String) The ID of the Azure resource to retrieve.
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -96,6 +98,17 @@ output "quarantine_policy" {
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
15 changes: 14 additions & 1 deletion docs/data-sources/resource_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ data "azapi_resource_action" "example" {
- `method` (String) The HTTP method to use when performing the action. Must be one of `POST`, `GET`. Defaults to `POST`.
- `query_parameters` (Map of List of String) A map of query parameters to include in the request
- `resource_id` (String) The ID of the Azure resource to perform the action on.
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -75,6 +77,17 @@ data "azapi_resource_action" "example" {
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
15 changes: 14 additions & 1 deletion docs/data-sources/resource_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ data "azapi_resource_list" "listSubnetsByVnet" {

- `headers` (Map of String) A map of headers to include in the request
- `query_parameters` (Map of List of String) A map of query parameters to include in the request
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -77,6 +79,17 @@ data "azapi_resource_list" "listSubnetsByVnet" {
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

Expand Down
15 changes: 14 additions & 1 deletion docs/resources/data_plane_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ resource "azapi_data_plane_resource" "dataset" {
- `locks` (List of String) A list of ARM resource IDs which are used to avoid create/modify/delete azapi resources at the same time.
- `read_headers` (Map of String) A mapping of headers to be sent with the read request.
- `read_query_parameters` (Map of List of String) A mapping of query parameters to be sent with the read request.
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -100,6 +102,17 @@ resource "azapi_data_plane_resource" "dataset" {
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `update_headers` (Map of String) A mapping of headers to be sent with the update request.
Expand Down
23 changes: 19 additions & 4 deletions docs/resources/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ resource "azapi_resource" "example" {
name = var.name
type = "Microsoft.Network/publicIPAddresses@2023-11-01"
parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example"
body = properties = {
sku = var.sku
zones = var.zones
body = {
properties = {
sku = var.sku
zones = var.zones
}
}
replace_triggers_external_values = [
Expand All @@ -132,7 +134,9 @@ resource "azapi_resource" "example" {
]
}
```
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -146,6 +150,17 @@ resource "azapi_resource" "example" {
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `schema_validation_enabled` (Boolean) Whether enabled the validation on `type` and `body` with embedded schema. Defaults to `true`.
- `tags` (Map of String) A mapping of tags which should be assigned to the Azure resource.
Expand Down
36 changes: 24 additions & 12 deletions docs/resources/resource_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ description: |-
- `locks` (List of String) A list of ARM resource IDs which are used to avoid create/modify/delete azapi resources at the same time.
- `method` (String) Specifies the HTTP method of the azure resource action. Allowed values are `POST`, `PATCH`, `PUT` and `DELETE`. Defaults to `POST`.
- `query_parameters` (Map of List of String) A map of query parameters to include in the request
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -94,25 +96,35 @@ description: |-
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `when` (String) When to perform the action, value must be one of: `apply`, `destroy`. Default is `apply`.

### Read-Only

- `id` (String) The ID of the Azure resource.
- `output` (Dynamic) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `output` (Dynamic) The output HCL object containing the properties specified in `response_export_values`. Here are some examples to use the values.

```text
{
properties = {
loginServer = "registry1.azurecr.io"
policies = {
quarantinePolicy = {
status = "disabled"
}
}
}
```terraform
// it will output "registry1.azurecr.io"
output "login_server" {
value = azapi_resource_action.example.output.properties.loginServer
}

// it will output "disabled"
output "quarantine_policy" {
value = azapi_resource_action.example.output.properties.policies.quarantinePolicy.status
}
```

Expand Down
15 changes: 14 additions & 1 deletion docs/resources/update_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ This resource can manage a subset of any existing Azure resource manager resourc
- `read_headers` (Map of String) A mapping of headers to be sent with the read request.
- `read_query_parameters` (Map of List of String) A mapping of query parameters to be sent with the read request.
- `resource_id` (String) The ID of an existing Azure source.
- `response_export_values` (List of String) A list of path that needs to be exported from response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to computed property output.
- `response_export_values` (Dynamic) The attribute can accept either a list or a map.

- **List**: A list of paths that need to be exported from the response body. Setting it to `["*"]` will export the full response body. Here's an example. If it sets to `["properties.loginServer", "properties.policies.quarantinePolicy.status"]`, it will set the following HCL object to the computed property output.

```text
{
Expand All @@ -127,6 +129,17 @@ This resource can manage a subset of any existing Azure resource manager resourc
}
}
```

- **Map**: A map where the key is the name for the result and the value is a JMESPath query string to filter the response. Here's an example. If it sets to `{"login_server": "properties.loginServer", "quarantine_status": "properties.policies.quarantinePolicy.status"}`, it will set the following HCL object to the computed property output.

```text
{
login_server = "registry1.azurecr.io"
quarantine_status = "disabled"
}
```

To learn more about JMESPath, visit [JMESPath](https://jmespath.org/).
- `retry` (Attributes) The retry block supports the following arguments: (see [below for nested schema](#nestedatt--retry))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `update_headers` (Map of String) A mapping of headers to be sent with the update request.
Expand Down
8 changes: 5 additions & 3 deletions internal/services/azapi_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ func (r *AzapiResource) Schema(ctx context.Context, _ resource.SchemaRequest, re
" name = var.name\n" +
" type = \"Microsoft.Network/publicIPAddresses@2023-11-01\"\n" +
" parent_id = \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example\"\n" +
" body = properties = {\n" +
" sku = var.sku\n" +
" zones = var.zones\n" +
" body = {\n" +
" properties = {\n" +
" sku = var.sku\n" +
" zones = var.zones\n" +
" }\n" +
" }\n" +
"\n" +
" replace_triggers_external_values = [\n" +
Expand Down

0 comments on commit bd951c3

Please sign in to comment.