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 query_args argument to nitro_info #1178 #1194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions citrixadc/data_source_citrixadc_nitro_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func dataSourceCitrixAdcNitroInfo() *schema.Resource {
Optional: true,
Computed: true,
},
"query_args": {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
},
"primary_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -78,6 +83,11 @@ func dataSourceCitrixAdcNitroInfoBindingListRead(d *schema.ResourceData, meta in
client := meta.(*NetScalerNitroClient).client
workflowMap := d.Get("workflow").(map[string]interface{})
primaryId := d.Get("primary_id").(string)
argsMap := make(map[string]string)
queryArgs := d.Get("query_args").(map[string]interface{})
for k, v := range queryArgs {
argsMap[k] = v.(string)
}
missingErrorCode, err := strconv.Atoi(workflowMap["bound_resource_missing_errorcode"].(string))
if err != nil {
return err
Expand All @@ -86,6 +96,7 @@ func dataSourceCitrixAdcNitroInfoBindingListRead(d *schema.ResourceData, meta in
ResourceType: workflowMap["endpoint"].(string),
ResourceName: primaryId,
ResourceMissingErrorCode: missingErrorCode,
ArgsMap: argsMap,
}

dataArr, err := client.FindResourceArrayWithParams(findParams)
Expand Down Expand Up @@ -128,6 +139,11 @@ func dataSourceCitrixAdcNitroInfoObjectByNameRead(d *schema.ResourceData, meta i
client := meta.(*NetScalerNitroClient).client
workflowMap := d.Get("workflow").(map[string]interface{})
primaryId := d.Get("primary_id").(string)
argsMap := make(map[string]string)
queryArgs := d.Get("query_args").(map[string]interface{})
for k, v := range queryArgs {
argsMap[k] = v.(string)
}
missingErrorCode, err := strconv.Atoi(workflowMap["bound_resource_missing_errorcode"].(string))
if err != nil {
return err
Expand All @@ -136,6 +152,7 @@ func dataSourceCitrixAdcNitroInfoObjectByNameRead(d *schema.ResourceData, meta i
ResourceType: workflowMap["endpoint"].(string),
ResourceName: primaryId,
ResourceMissingErrorCode: missingErrorCode,
ArgsMap: argsMap,
}

dataArr, err := client.FindResourceArrayWithParams(findParams)
Expand Down
18 changes: 18 additions & 0 deletions docs/data-sources/nitro_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ output "list_output" {
output "object_output" {
value = [ for item in data.citrixadc_nitro_info.sample.nitro_list: item.object ]
}

# Fetch the content of a file using query_args:
data "citrixadc_nitro_info "my_file" {
workflow = {
lifecycle = "object_by_name"
endpoint = "systemfile"
bound_resource_missing_errorcode = "3441"
}
query_args = {
filename = "my_file_name"
filecondent = urlencode("/my/file/path")
}
}

output "my_file" {
value = data.citrixadc_nitro_info.my_file.nitro_object.filecontent
}
```

## Argument Reference
Expand All @@ -56,6 +73,7 @@ output "object_output" {

A list of such workflows can be found in the github repository example folder for the `nitro_info` data source.

* `query_args` - (Optional) A dictionary of query arguments that will be included when performing the request to the NITRO `endpoint` url.
* `primary_id` - (Optional) Value for the primary id of the nitro endpoint.
* `secondary_id` - (Optional) Value for the secondary id of the nitro endpoint.

Expand Down