Skip to content

Commit

Permalink
Merge pull request #162 from NetApp/14-new-data-source-protocols_san_…
Browse files Browse the repository at this point in the history
…lun-maps

new data sources protocols_san_lun-map_data_source
  • Loading branch information
carchi8py authored Apr 4, 2024
2 parents d9d69a5 + 94ebe70 commit a9e6d09
Show file tree
Hide file tree
Showing 19 changed files with 632 additions and 15 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ FEATURES:
* **New Data Source:** `netapp_ontap_protocols_cifs_servers_data_source` ([#24](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/24))
* **New Data Source:** `netapp-ontap_name_services_ldap_data_source` ([#26](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/26))
* **New Data Source:** `netapp-ontap_name_services_ldaps_data_source` ([#26](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/26))
* **New Data Source:** `netapp-ontap_protocols_san_lun-map_data_source` ([#14](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/14))
* **New Data Source:** `netapp-ontap_protocols_san_lun-maps_data_source` ([#14](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/14))
* **New Resource:** `netapp-ontap_protocols_cifs_local_group_resource` ([#53](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/53))
* **New Resource:** `netapp-ontap_protocols_cifs_local_user_resource` ([#56](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/56))
* **New Resource:** `netapp-ontap_protocols_cifs_user_group_privilege_resource` ([#58](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/58))
* **New Resource:** `netapp-ontap_svm_peers_resource` ([#51](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/51))
* **New Resource:** `netapp-ontap_protocols_cifs_user_group_member_resource` ([#123](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/123))
* **New Resource:** `netapp-protocols_san_lun-maps_resource` ([#13](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/13))
* **New Resource:** `netapp-ontap_protocols_san_lun-maps_resource` ([#13](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/13))
* **New Resource:** `netapp-ontap_name_services_ldap_resource` ([#25](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/25))
* **New Resource:** `netapp-ontap_protocols_cifs_service_resource` ([#23](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/23))

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/protocols_san_igroup_data_source.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netapp-ontap_protocols_san_igroup_data_source Data Source - terraform-provider-netapp-ontap"
subcategory: "San"
subcategory: "san"
description: |-
ProtocolsSanIgroup data source
---
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/protocols_san_igroups_data_source.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netapp-ontap_protocols_san_igroups_data_source Data Source - terraform-provider-netapp-ontap"
subcategory: "San"
subcategory: "san"
description: |-
ProtocolsSanIgroups data source
---
Expand Down
69 changes: 69 additions & 0 deletions docs/data-sources/protocols_san_lun-map_data_source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netapp-ontap_protocols_san_lun-map_data_source Data Source - terraform-provider-netapp-ontap"
subcategory: "san"
description: |-
ProtocolsSanLunMap data source
---

# netapp-ontap_protocols_san_lun-map_data_source (Data Source)

ProtocolsSanLunMap data source

## Example Usage
```terraform
data "netapp-ontap_protocols_san_lun-map_data_source" "example" {
cx_profile_name = "example_profile"
igroup {
name = "example_igroup"
}
lun {
name = "example_lun"
}
svm {
name = "example_svm"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cx_profile_name` (String) Connection profile name
- `igroup` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--igroup))
- `lun` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--lun))
- `svm` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--svm))

### Read-Only

- `logical_unit_number` (Number) If no value is provided, ONTAP assigns the lowest available value

<a id="nestedatt--igroup"></a>
### Nested Schema for `igroup`

Required:

- `name` (String) name of the igroup


<a id="nestedatt--lun"></a>
### Nested Schema for `lun`

Required:

- `name` (String) name of the lun


<a id="nestedatt--svm"></a>
### Nested Schema for `svm`

Required:

- `name` (String) name of the SVM


118 changes: 118 additions & 0 deletions docs/data-sources/protocols_san_lun-maps_data_source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netapp-ontap_protocols_san_lun-maps_data_source Data Source - terraform-provider-netapp-ontap"
subcategory: "san"
description: |-
ProtocolsSanLunMaps data source
---

# netapp-ontap_protocols_san_lun-maps_data_source (Data Source)

ProtocolsSanLunMaps data source

## Example Usage
```terraform
data "netapp-ontap_protocols_san_lun-maps_data_source" "example" {
cx_profile_name = "example_profile"
filter {
igroup {
name = "example_igroup"
}
lun {
name = "example_lun"
}
svm {
name = "example_svm"
}
}
}
```

<!-- 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_san_lun_maps` (Attributes List) (see [below for nested schema](#nestedatt--protocols_san_lun_maps))

<a id="nestedatt--filter"></a>
### Nested Schema for `filter`

Optional:

- `igroup` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--filter--igroup))
- `lun` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--filter--lun))
- `svm` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--filter--svm))

<a id="nestedatt--filter--igroup"></a>
### Nested Schema for `filter.igroup`

Optional:

- `name` (String) name of the igroup


<a id="nestedatt--filter--lun"></a>
### Nested Schema for `filter.lun`

Optional:

- `name` (String) name of the lun


<a id="nestedatt--filter--svm"></a>
### Nested Schema for `filter.svm`

Optional:

- `name` (String) name of the SVM



<a id="nestedatt--protocols_san_lun_maps"></a>
### Nested Schema for `protocols_san_lun_maps`

Required:

- `cx_profile_name` (String) Connection profile name
- `igroup` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--protocols_san_lun_maps--igroup))
- `lun` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--protocols_san_lun_maps--lun))
- `svm` (Attributes) SVM details for ProtocolsSanLunMaps (see [below for nested schema](#nestedatt--protocols_san_lun_maps--svm))

Read-Only:

- `logical_unit_number` (Number) If no value is provided, ONTAP assigns the lowest available value

<a id="nestedatt--protocols_san_lun_maps--igroup"></a>
### Nested Schema for `protocols_san_lun_maps.igroup`

Required:

- `name` (String) name of the igroup


<a id="nestedatt--protocols_san_lun_maps--lun"></a>
### Nested Schema for `protocols_san_lun_maps.lun`

Required:

- `name` (String) name of the lun


<a id="nestedatt--protocols_san_lun_maps--svm"></a>
### Nested Schema for `protocols_san_lun_maps.svm`

Required:

- `name` (String) name of the SVM


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data "netapp-ontap_protocols_san_lun-map_data_source" "protocols_san_lun-maps" {
# required to know which system to interface with
cx_profile_name = "cluster2"
svm = {
name = "carchi-test"
}
lun = {
name = "/vol/lunTest/ACC-import-lun"
}
igroup = {
name = "acc_test"
}
# logical_unit_number = 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "netapp-ontap_protocols_san_lun-maps_data_source" "protocols_san_lun-mapss" {
# required to know which system to interface with
cx_profile_name = "cluster2"
# filter = {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ data "netapp-ontap_storage_lun_data_source" "storage_lun" {
cx_profile_name = "cluster4"
name = "/vol/ansibleVolume18/lun1"
svm_name = "svm0"
privileges = "test"
location = {
volume = {
name = "ansibleVolume18"
Expand Down
55 changes: 45 additions & 10 deletions internal/interfaces/protocols_san_lun-maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,69 @@ import (
type ProtocolsSanLunMapsGetDataModelONTAP struct {
SVM svm `mapstructure:"svm"`
LogicalUnitNumber int `mapstructure:"logical_unit_number"`
IGroup igroup `mapstructure:"igroup"`
Lun lun `mapstructure:"lun"`
IGroup IGroup `mapstructure:"igroup"`
Lun Lun `mapstructure:"lun"`
}

// igroup describes the resource data model.
type igroup struct {
// IGroup describes the resource data model.
type IGroup struct {
Name string `mapstructure:"name,omitempty"`
UUID string `mapstructure:"uuid,omitempty"`
}

// lun describes the resource data model.
type lun struct {
// Lun describes the resource data model.
type Lun struct {
Name string `mapstructure:"name,omitempty"`
UUID string `mapstructure:"uuid,omitempty"`
}

// ProtocolsSanLunMapsResourceBodyDataModelONTAP describes the body data model using go types for mapping.
type ProtocolsSanLunMapsResourceBodyDataModelONTAP struct {
SVM svm `mapstructure:"svm"`
IGroup igroup `mapstructure:"igroup"`
Lun lun `mapstructure:"lun"`
IGroup IGroup `mapstructure:"igroup"`
Lun Lun `mapstructure:"lun"`
LogicalUnitNumber int `mapstructure:"logical_unit_number,omitempty"`
}

// ProtocolsSanLunMapsDataSourceFilterModel describes the data source data model for queries.
type ProtocolsSanLunMapsDataSourceFilterModel struct {
Name string `mapstructure:"name"`
SVMName string `mapstructure:"svm.name"`
Lun Lun `mapstructure:"lun"`
SVM SVM `mapstructure:"svm"`
IGroup IGroup `mapstructure:"igroup"`
}

// GetProtocolsSanLunMaps to get protocols_san_lun-maps info
func GetProtocolsSanLunMaps(errorHandler *utils.ErrorHandler, r restclient.RestClient, filter *ProtocolsSanLunMapsDataSourceFilterModel) ([]ProtocolsSanLunMapsGetDataModelONTAP, error) {
api := "/protocols/san/lun-maps"
query := r.NewQuery()
query.Fields([]string{"svm.name", "igroup.name", "igroup.uuid", "lun.name", "lun.uuid", "logical_unit_number"})
if filter != nil {
var filterMap map[string]interface{}
if err := mapstructure.Decode(filter, &filterMap); err != nil {
return nil, errorHandler.MakeAndReportError("error encoding /protocols/san/lun-maps 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_san_lun-maps info", fmt.Sprintf("error on GET %s: %s, statusCode %d", api, err, statusCode))
}

var dataONTAP []ProtocolsSanLunMapsGetDataModelONTAP
for _, info := range response {
var record ProtocolsSanLunMapsGetDataModelONTAP
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_san_lun-maps data source: %#v", dataONTAP))
return dataONTAP, nil
}

// GetProtocolsSanLunMapsByName to get protocols_san_lun-maps info
Expand Down
Loading

0 comments on commit a9e6d09

Please sign in to comment.