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_logic_app_action_http - support for the queries property #18934

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 38 additions & 0 deletions internal/services/logic/logic_app_action_http_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ func resourceLogicAppActionHTTP() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
},
},

"queries": {
Type: pluginsdk.TypeMap,
Optional: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"run_after": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -121,10 +130,17 @@ func resourceLogicAppActionHTTPCreateUpdate(d *pluginsdk.ResourceData, meta inte
return err
}

queriesRaw := d.Get("queries").(map[string]interface{})
queries, err := expandLogicAppActionHttpQueries(queriesRaw)
if err != nil {
return err
}

inputs := map[string]interface{}{
"method": d.Get("method").(string),
"uri": d.Get("uri").(string),
"headers": headers,
"queries": queries,
}

// storing action's body in json object to keep consistent with azure portal
Expand Down Expand Up @@ -214,6 +230,13 @@ func resourceLogicAppActionHTTPRead(d *pluginsdk.ResourceData, meta interface{})
}
}

if queries := inputs["queries"]; queries != nil {
qv := queries.(map[string]interface{})
if err := d.Set("queries", qv); err != nil {
return fmt.Errorf("setting `queries` for HTTP Action %q: %+v", id.Name, err)
}
}

v = action["runAfter"]
if v != nil {
runAfter, ok := v.(map[string]interface{})
Expand Down Expand Up @@ -256,3 +279,18 @@ func expandLogicAppActionHttpHeaders(headersRaw map[string]interface{}) (*map[st

return &headers, nil
}

func expandLogicAppActionHttpQueries(queriesRaw map[string]interface{}) (*map[string]string, error) {
queries := make(map[string]string)

for i, v := range queriesRaw {
value, err := tags.TagValueToString(v)
if err != nil {
return nil, err
}

queries[i] = value
}

return &queries, nil
}
33 changes: 33 additions & 0 deletions internal/services/logic/logic_app_action_http_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ func TestAccLogicAppActionHttp_headers(t *testing.T) {
})
}

func TestAccLogicAppActionHttp_queries(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_action_http", "test")
r := LogicAppActionHttpResource{}

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

func TestAccLogicAppActionHttp_disappears(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_action_http", "test")
r := LogicAppActionHttpResource{}
Expand Down Expand Up @@ -196,6 +211,24 @@ resource "azurerm_logic_app_action_http" "test" {
`, r.template(data), data.RandomInteger)
}

func (r LogicAppActionHttpResource) queries(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_logic_app_action_http" "test" {
name = "action%d"
logic_app_id = azurerm_logic_app_workflow.test.id
method = "GET"
uri = "http://example.com/hello"

queries = {
"Hello" = "World"
"Something" = "New"
}
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppActionHttpResource) runAfterCondition(data acceptance.TestData, condition string) string {
return fmt.Sprintf(`
%s
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/logic_app_action_http.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The following arguments are supported:

* `headers` - (Optional) Specifies a Map of Key-Value Pairs that should be sent to the `uri` when this HTTP Action is triggered.

* `queries` - (Optional) Specifies a Map of Key-Value Pairs that should be sent to the `uri` when this HTTP Action is triggered.

* `run_after` - (Optional) Specifies the place of the HTTP Action in the Logic App Workflow. If not specified, the HTTP Action is right after the Trigger. A `run_after` block is as defined below.

---
Expand Down