-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from NetApp/54-new-data-source-protocolscifsl…
…ocal-groups 54 new data source protocolscifslocal groups
- Loading branch information
Showing
16 changed files
with
581 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
docs/data-sources/netapp-ontap_protocols_cifs_local_group_data_source.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "netapp-ontap_protocols_cifs_local_group_data_source Data Source - terraform-provider-netapp-ontap" | ||
subcategory: "nas" | ||
description: |- | ||
Retrieve CifsLocalGroup data source | ||
--- | ||
|
||
# Data Source ontap_protocols_cifs_local_group | ||
|
||
Retrieves protocols cifs local group configuration | ||
|
||
## Example Usage | ||
```terraform | ||
data "netapp-ontap_protocols_cifs_local_group_data_source" "local_group" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster4" | ||
svm_name = "svm3" | ||
name = "Administrators" | ||
} | ||
``` | ||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `cx_profile_name` (String) Connection profile name | ||
- `name` (String) Cifs Local Group name | ||
- `svm_name` (String) Svm name | ||
|
||
### Read-Only | ||
|
||
- `description` (String) Cifs Local Group description | ||
- `id` (String) Cifs Local Group id | ||
- `members` (Attributes List) Cifs Local Group members (see [below for nested schema](#nestedatt--members)) | ||
|
||
<a id="nestedatt--members"></a> | ||
### Nested Schema for `members` | ||
|
||
Read-Only: | ||
|
||
- `name` (String) Cifs Local Group member | ||
|
||
|
72 changes: 72 additions & 0 deletions
72
docs/data-sources/netapp-ontap_protocols_cifs_local_groups_data_source.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "netapp-ontap_protocols_cifs_local_groups_data_source Data Source - terraform-provider-netapp-ontap" | ||
subcategory: "nas" | ||
description: |- | ||
Retrieves list of Cifs Local Groups. | ||
--- | ||
|
||
# Data Source protocols_cifs_local_groups | ||
|
||
Retrieves list of Cifs Local Groups. | ||
|
||
## Example Usage | ||
```terraform | ||
data "netapp-ontap_protocols_cifs_local_groups_data_source" "local_groups" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster1" | ||
filter = { | ||
svm_name = "svm*" | ||
name = "Administrators" | ||
} | ||
} | ||
``` | ||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `cx_profile_name` (String) Connection profile name | ||
|
||
### Optional | ||
|
||
- `filter` (Attributes) (see [below for nested schema](#nestedatt--filter)) | ||
|
||
### Read-Only | ||
|
||
- `protocols_cifs_local_groups` (Attributes List) Protocols Cifs Local Groups (see [below for nested schema](#nestedatt--protocols_cifs_local_groups)) | ||
|
||
<a id="nestedatt--filter"></a> | ||
### Nested Schema for `filter` | ||
|
||
Optional: | ||
|
||
- `name` (String) Cifs Local Group name | ||
- `svm_name` (String) Cifs Local Group svm name | ||
|
||
|
||
<a id="nestedatt--protocols_cifs_local_groups"></a> | ||
### Nested Schema for `protocols_cifs_local_groups` | ||
|
||
Required: | ||
|
||
- `cx_profile_name` (String) Connection profile name | ||
- `name` (String) Cifs Local Group name | ||
- `svm_name` (String) Cifs Local Group svm name | ||
|
||
Read-Only: | ||
|
||
- `description` (String) Cifs Local Group description | ||
- `id` (String) Cifs Local Group identifier | ||
- `members` (Attributes List) Cifs Local Group members (see [below for nested schema](#nestedatt--protocols_cifs_local_groups--members)) | ||
|
||
<a id="nestedatt--protocols_cifs_local_groups--members"></a> | ||
### Nested Schema for `protocols_cifs_local_groups.members` | ||
|
||
Read-Only: | ||
|
||
- `name` (String) Cifs Local Group member names | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
examples/data-sources/netapp-ontap_protocols_cifs_local_group/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
data "netapp-ontap_protocols_cifs_local_group_data_source" "protocols_cifs_local_group" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster4" | ||
svm_name = "svm3" | ||
name = "Administrators" | ||
} |
1 change: 1 addition & 0 deletions
1
examples/data-sources/netapp-ontap_protocols_cifs_local_group/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../provider/provider.tf |
1 change: 1 addition & 0 deletions
1
examples/data-sources/netapp-ontap_protocols_cifs_local_group/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../provider/terraform.tfvars |
1 change: 1 addition & 0 deletions
1
examples/data-sources/netapp-ontap_protocols_cifs_local_group/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../provider/variables.tf |
8 changes: 8 additions & 0 deletions
8
examples/data-sources/netapp-ontap_protocols_cifs_local_groups/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data "netapp-ontap_protocols_cifs_local_groups_data_source" "protocols_cifs_local_groups" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster4" | ||
filter = { | ||
svm_name = "svm*" | ||
name = "Administrators" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
examples/data-sources/netapp-ontap_protocols_cifs_local_groups/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../provider/provider.tf |
3 changes: 3 additions & 0 deletions
3
examples/data-sources/netapp-ontap_protocols_cifs_local_groups/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
username = "admin" | ||
password = "xxxxxxxxx" | ||
validate_certs = true |
1 change: 1 addition & 0 deletions
1
examples/data-sources/netapp-ontap_protocols_cifs_local_groups/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../provider/variables.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package interfaces | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
"github.com/mitchellh/mapstructure" | ||
"github.com/netapp/terraform-provider-netapp-ontap/internal/restclient" | ||
"github.com/netapp/terraform-provider-netapp-ontap/internal/utils" | ||
) | ||
|
||
// CifsLocalGroupGetDataModelONTAP describes the GET record data model using go types for mapping. | ||
type CifsLocalGroupGetDataModelONTAP struct { | ||
Name string `mapstructure:"name"` | ||
SID string `mapstructure:"sid"` | ||
SVM svm `mapstructure:"svm"` | ||
Description string `mapstructure:"description"` | ||
Members []member `mapstructure:"members"` | ||
} | ||
|
||
// member | ||
type member struct { | ||
Name string `mapstructure:"name"` | ||
} | ||
|
||
// CifsLocalGroupResourceBodyDataModelONTAP describes the body data model using go types for mapping. | ||
type CifsLocalGroupResourceBodyDataModelONTAP struct { | ||
Name string `mapstructure:"name"` | ||
SVM svm `mapstructure:"svm"` | ||
} | ||
|
||
// CifsLocalGroupDataSourceFilterModel describes the data source data model for queries. | ||
type CifsLocalGroupDataSourceFilterModel struct { | ||
Name string `mapstructure:"name"` | ||
SVMName string `mapstructure:"svm.name"` | ||
} | ||
|
||
// GetCifsLocalGroupByName to get protocols_cifs_local_group info | ||
func GetCifsLocalGroupByName(errorHandler *utils.ErrorHandler, r restclient.RestClient, name string, svmName string) (*CifsLocalGroupGetDataModelONTAP, error) { | ||
api := "protocols/cifs/local-groups" | ||
query := r.NewQuery() | ||
query.Set("name", name) | ||
query.Set("svm.name", svmName) | ||
|
||
query.Fields([]string{"name", "svm.name", "description", "members"}) | ||
statusCode, response, err := r.GetNilOrOneRecord(api, query, nil) | ||
if err == nil && response == nil { | ||
err = fmt.Errorf("no response for GET %s", api) | ||
} | ||
if err != nil { | ||
return nil, errorHandler.MakeAndReportError("error reading protocols_cifs_local_group info", fmt.Sprintf("error on GET %s: %s, statusCode %d", api, err, statusCode)) | ||
} | ||
|
||
var dataONTAP CifsLocalGroupGetDataModelONTAP | ||
if err := mapstructure.Decode(response, &dataONTAP); err != nil { | ||
return nil, errorHandler.MakeAndReportError(fmt.Sprintf("failed to decode response from GET %s", api), | ||
fmt.Sprintf("error: %s, statusCode %d, response %#v", err, statusCode, response)) | ||
} | ||
tflog.Debug(errorHandler.Ctx, fmt.Sprintf("Read protocols_cifs_local_group data source: %#v", dataONTAP)) | ||
return &dataONTAP, nil | ||
} | ||
|
||
// GetCifsLocalGroups to get protocols_cifs_local_group info for all resources matching a filter | ||
func GetCifsLocalGroups(errorHandler *utils.ErrorHandler, r restclient.RestClient, filter *CifsLocalGroupDataSourceFilterModel) ([]CifsLocalGroupGetDataModelONTAP, error) { | ||
api := "protocols/cifs/local-groups" | ||
query := r.NewQuery() | ||
query.Fields([]string{"name", "svm.name", "description", "members"}) | ||
if filter != nil { | ||
var filterMap map[string]interface{} | ||
if err := mapstructure.Decode(filter, &filterMap); err != nil { | ||
return nil, errorHandler.MakeAndReportError("error encoding protocols_cifs_local_groups filter info", fmt.Sprintf("error on filter %#v: %s", filter, err)) | ||
} | ||
query.SetValues(filterMap) | ||
} | ||
statusCode, response, err := r.GetZeroOrMoreRecords(api, query, nil) | ||
if err == nil && response == nil { | ||
err = fmt.Errorf("no response for GET %s", api) | ||
} | ||
if err != nil { | ||
return nil, errorHandler.MakeAndReportError("error reading protocols_cifs_local_groups info", fmt.Sprintf("error on GET %s: %s, statusCode %d", api, err, statusCode)) | ||
} | ||
|
||
var dataONTAP []CifsLocalGroupGetDataModelONTAP | ||
for _, info := range response { | ||
var record CifsLocalGroupGetDataModelONTAP | ||
if err := mapstructure.Decode(info, &record); err != nil { | ||
return nil, errorHandler.MakeAndReportError(fmt.Sprintf("failed to decode response from GET %s", api), | ||
fmt.Sprintf("error: %s, statusCode %d, info %#v", err, statusCode, info)) | ||
} | ||
dataONTAP = append(dataONTAP, record) | ||
} | ||
tflog.Debug(errorHandler.Ctx, fmt.Sprintf("Read protocols_cifs_local_groups data source: %#v", dataONTAP)) | ||
return dataONTAP, nil | ||
} |
Oops, something went wrong.