From 1e91925492e508f8d6d66a019651e6ea84114790 Mon Sep 17 00:00:00 2001 From: Alistair Yan <52126234+1riatsila1@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:35:52 +0200 Subject: [PATCH] fix: groups docs and plan modification (#154) --- INSTALL.md | 2 +- docs/index.md | 3 +++ docs/resources/agent_group_assignment.md | 9 +++++--- docs/resources/group.md | 7 ++++-- docs/resources/network_group_assignment.md | 7 ++++-- docs/resources/sensor_group_assignment.md | 7 ++++-- .../service_test_group_assignment.md | 7 ++++-- internal/provider/provider.go | 4 +++- .../resource_agent_group_assignment.go | 17 ++++++++------ internal/provider/resources/resource_group.go | 12 ++++++---- .../resource_network_group_assignment.go | 23 +++++++++++-------- .../resource_sensor_group_assignment.go | 17 ++++++++------ .../resource_service_group_assignment.go | 17 ++++++++------ 13 files changed, 83 insertions(+), 49 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 2a95435a..24a302ce 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -72,7 +72,7 @@ The following example uses Zsh (default) on macOS (Apple Silicon). ```console RELEASE=x.y.z - wget -q https://github.com/aruba-uxi/terraform-provider-hpeuxi/releases/download/v${RELEASE}/terraform-provider-hpeuxi_${RELEASE}_darwin_arm64.zip + wget https://github.com/aruba-uxi/terraform-provider-hpeuxi/releases/download/v${RELEASE}/terraform-provider-hpeuxi_${RELEASE}_darwin_arm64.zip ``` 3. Extract the plugin. diff --git a/docs/index.md b/docs/index.md index 6da79f03..d2bf4639 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,12 +3,15 @@ page_title: "hpeuxi Provider" description: |- Interact with HPE Aruba Network UXI Configuration. + See https://developer.greenlake.hpe.com/docs/greenlake/guides/public/authentication/authentication/#configuring-api-client-credentials for more information on generating client credentials. --- # hpeuxi Provider Interact with HPE Aruba Network UXI Configuration. +See https://developer.greenlake.hpe.com/docs/greenlake/guides/public/authentication/authentication/#configuring-api-client-credentials for more information on generating client credentials. + ## Example Usage ```terraform diff --git a/docs/resources/agent_group_assignment.md b/docs/resources/agent_group_assignment.md index 66ee0439..6a3fb361 100644 --- a/docs/resources/agent_group_assignment.md +++ b/docs/resources/agent_group_assignment.md @@ -4,11 +4,14 @@ page_title: "hpeuxi_agent_group_assignment Resource - hpeuxi" subcategory: "" description: |- Manages an agent group assignment. + Note: it is recommended to use a hpeuxi_group resource id as the group_id. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. --- # hpeuxi_agent_group_assignment (Resource) -Manages an agent group assignment. +Manages an agent group assignment. + +Note: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. ## Example Usage @@ -24,8 +27,8 @@ resource "hpeuxi_agent_group_assignment" "my_agent_group_assignment" { ### Required -- `agent_id` (String) The identifier of the agent to be assigned. Use agent id; `uxi_agent` resource id field or `uxi_agent` datasource id field here. -- `group_id` (String) The identifier of the group to be assigned to. Use group id; `uxi_group` resource id field or `uxi_group` datasource id field here. +- `agent_id` (String) The identifier of the agent to be assigned. Use `hpeuxi_agent` resource id field; `data.hpeuxi_agent` id field or agent id here. +- `group_id` (String) The identifier of the group to be assigned to. Use `hpeuxi_group` resource id field (recommended); `data.hpeuxi_group` id field or group id here. ### Read-Only diff --git a/docs/resources/group.md b/docs/resources/group.md index efe69097..4572e104 100644 --- a/docs/resources/group.md +++ b/docs/resources/group.md @@ -4,11 +4,14 @@ page_title: "hpeuxi_group Resource - hpeuxi" subcategory: "" description: |- Manages a group. + Note: building a group hierarchy by using an hpeuxi_group resource id as a child group's parent_group_id is recommended to maintain dependencies between linked groups. This will help maintain accurate state if the user attempts to change the parent of a non leaf group. --- # hpeuxi_group (Resource) -Manages a group. +Manages a group. + +Note: building a group hierarchy by using an `hpeuxi_group` **resource** `id` as a child group's `parent_group_id` is recommended to maintain dependencies between linked groups. This will help maintain accurate state if the user attempts to change the parent of a non leaf group. ## Example Usage @@ -34,7 +37,7 @@ resource "hpeuxi_group" "level_2" { ### Optional -- `parent_group_id` (String) The identifier of the parent of this group. Use hpeuxi_group resource or datasource id for this attribute. Alternatively leave blank to set group to highest level configurable node. +- `parent_group_id` (String) The identifier of the parent of this group. Use `hpeuxi_group` resource (recommended) or `data.hpeuxi_group` id for this attribute. Alternatively leave blank to set group to highest level configurable node. ### Read-Only diff --git a/docs/resources/network_group_assignment.md b/docs/resources/network_group_assignment.md index d06eab03..2fbc3057 100644 --- a/docs/resources/network_group_assignment.md +++ b/docs/resources/network_group_assignment.md @@ -4,12 +4,15 @@ page_title: "hpeuxi_network_group_assignment Resource - hpeuxi" subcategory: "" description: |- Manages a network group assignment. + Note: it is recommended to use a hpeuxi_group resource id as the group_id. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. --- # hpeuxi_network_group_assignment (Resource) Manages a network group assignment. +Note: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. + ## Example Usage ```terraform @@ -24,8 +27,8 @@ resource "hpeuxi_network_group_assignment" "my_network_group_assignment" { ### Required -- `group_id` (String) The identifier of the group to be assigned to. Use group id; `uxi_group` resource id field or `uxi_group` datasource id field here. -- `network_id` (String) The identifier of the network to be assigned. Use wired network id; `uxi_wired_network` resource id field; `uxi_wired_network` datasource id field; wireless network id; `uxi_wireless_network` resource id field or `uxi_wireless_network` datasource id field here. +- `group_id` (String) The identifier of the group to be assigned to. Use `hpeuxi_group` resource id field (recommended); `data.hpeuxi_group` id field or group id here. +- `network_id` (String) The identifier of the network to be assigned. Use `hpeuxi_wired_network` resource id field; `data.hpeuxi_wired_network` id field; `hpeuxi_wireless_network` resource id field; `data.hpeuxi_wireless_network` id field wired network id; or wireless network id here. ### Read-Only diff --git a/docs/resources/sensor_group_assignment.md b/docs/resources/sensor_group_assignment.md index 1822a73e..4d5cd5f3 100644 --- a/docs/resources/sensor_group_assignment.md +++ b/docs/resources/sensor_group_assignment.md @@ -4,12 +4,15 @@ page_title: "hpeuxi_sensor_group_assignment Resource - hpeuxi" subcategory: "" description: |- Manages a sensor group assignment. + Note: it is recommended to use a hpeuxi_group resource id as the group_id. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. --- # hpeuxi_sensor_group_assignment (Resource) Manages a sensor group assignment. +Note: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. + ## Example Usage ```terraform @@ -24,8 +27,8 @@ resource "hpeuxi_sensor_group_assignment" "my_sensor_group_assignment" { ### Required -- `group_id` (String) The identifier of the group to be assigned to. Use group id; `uxi_group` resource id field or `uxi_group` datasource id field here. -- `sensor_id` (String) The identifier of the sensor to be assigned. Use sensor id; `uxi_sensor` resource id field or `uxi_sensor` datasource id field here. +- `group_id` (String) The identifier of the group to be assigned to. Use `hpeuxi_group` resource id field (recommended); `data.hpeuxi_group` id field or group id here. +- `sensor_id` (String) The identifier of the sensor to be assigned. Use `hpeuxi_sensor` resource id field; `data.hpeuxi_sensor` id field or sensor id here. ### Read-Only diff --git a/docs/resources/service_test_group_assignment.md b/docs/resources/service_test_group_assignment.md index de1e3680..c6bfc182 100644 --- a/docs/resources/service_test_group_assignment.md +++ b/docs/resources/service_test_group_assignment.md @@ -4,12 +4,15 @@ page_title: "hpeuxi_service_test_group_assignment Resource - hpeuxi" subcategory: "" description: |- Manages a service test group assignment. + Note: it is recommended to use a hpeuxi_group resource id as the group_id. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. --- # hpeuxi_service_test_group_assignment (Resource) Manages a service test group assignment. +Note: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. This will help maintain dependencies between resources. This is useful when a destructive action is performed on an ancestor of the assigned group. + ## Example Usage ```terraform @@ -24,8 +27,8 @@ resource "hpeuxi_service_test_group_assignment" "my_service_test_group_assignmen ### Required -- `group_id` (String) The identifier of the group to be assigned to. Use group id; `uxi_group` resource id field or `uxi_group` datasource id field here. -- `service_test_id` (String) The identifier of the service test to be assigned. Use service test id; `uxi_service_test` resource id field or `uxi_service_test` datasource id field here. +- `group_id` (String) The identifier of the group to be assigned to. Use `hpeuxi_group` resource id field (recommended); `data.hpeuxi_group` id field or group id here. +- `service_test_id` (String) The identifier of the service test to be assigned. Use `hpeuxi_service_test` resource id field; `data.hpeuxi_service_test` id field or service test id here. ### Read-Only diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 913722cf..de1096ee 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -60,7 +60,9 @@ func (p *hpeuxiConfigurationProvider) Schema( resp *provider.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Interact with HPE Aruba Network UXI Configuration.", + Description: "Interact with HPE Aruba Network UXI Configuration." + + "\n\nSee https://developer.greenlake.hpe.com/docs/greenlake/guides/public/authentication/authentication/#configuring-api-client-credentials " + + "for more information on generating client credentials.", Attributes: map[string]schema.Attribute{ "client_id": schema.StringAttribute{ Description: "The Client ID as obtained from HPE GreenLake API client credentials. " + diff --git a/internal/provider/resources/resource_agent_group_assignment.go b/internal/provider/resources/resource_agent_group_assignment.go index 55b25160..0bb2f006 100644 --- a/internal/provider/resources/resource_agent_group_assignment.go +++ b/internal/provider/resources/resource_agent_group_assignment.go @@ -52,7 +52,10 @@ func (r *agentGroupAssignmentResource) Schema( resp *resource.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Manages an agent group assignment.", + Description: "Manages an agent group assignment. " + + "\n\nNote: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. " + + "This will help maintain dependencies between resources. This is useful when a " + + "destructive action is performed on an ancestor of the assigned group.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The identifier of the agent group assignment.", @@ -63,9 +66,9 @@ func (r *agentGroupAssignmentResource) Schema( }, "agent_id": schema.StringAttribute{ Description: "The identifier of the agent to be assigned. " + - "Use agent id; " + - "`uxi_agent` resource id field or " + - "`uxi_agent` datasource id field here.", + "Use `hpeuxi_agent` resource id field; " + + "`data.hpeuxi_agent` id field " + + "or agent id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), @@ -73,9 +76,9 @@ func (r *agentGroupAssignmentResource) Schema( }, "group_id": schema.StringAttribute{ Description: "The identifier of the group to be assigned to. " + - "Use group id; " + - "`uxi_group` resource id field or " + - "`uxi_group` datasource id field here.", + "Use `hpeuxi_group` resource id field (recommended); " + + "`data.hpeuxi_group` id field or " + + "group id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/provider/resources/resource_group.go b/internal/provider/resources/resource_group.go index 7cd25520..9c57e560 100644 --- a/internal/provider/resources/resource_group.go +++ b/internal/provider/resources/resource_group.go @@ -55,7 +55,11 @@ func (r *groupResource) Schema( resp *resource.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Manages a group.", + Description: "Manages a group. " + + "\n\nNote: building a group hierarchy by using an `hpeuxi_group` **resource** `id` as " + + "a child group's `parent_group_id` is recommended to maintain dependencies between " + + "linked groups. This will help maintain accurate state if the user attempts to " + + "change the parent of a non leaf group.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The identifier of the group.", @@ -70,7 +74,7 @@ func (r *groupResource) Schema( }, "parent_group_id": schema.StringAttribute{ Description: "The identifier of the parent of this group. " + - "Use hpeuxi_group resource or datasource id for this attribute. " + + "Use `hpeuxi_group` resource (recommended) or `data.hpeuxi_group` id for this attribute. " + "Alternatively leave blank to set group to highest level configurable node.", Optional: true, PlanModifiers: []planmodifier.String{ @@ -230,7 +234,7 @@ func (r *groupResource) Update( // only update parent if not attached to root node (else leave it as null) parentGroup, _ := r.getGroup(ctx, group.Parent.Id) if parentGroup != nil && !util.IsRoot(*parentGroup) { - state.ParentGroupID = types.StringValue(group.Parent.Id) + plan.ParentGroupID = types.StringValue(group.Parent.Id) } diags = resp.State.Set(ctx, plan) @@ -285,8 +289,6 @@ func (r *groupResource) getGroup( request := r.client.ConfigurationAPI.GroupsGet(ctx).Id(id) groupResponse, response, err := util.RetryForTooManyRequests(request.Execute) - // groupResponse, response, err := request.Execute() - // this causes a segfault errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { return nil, errors.New(errorDetail) diff --git a/internal/provider/resources/resource_network_group_assignment.go b/internal/provider/resources/resource_network_group_assignment.go index 3b637c64..2502f506 100644 --- a/internal/provider/resources/resource_network_group_assignment.go +++ b/internal/provider/resources/resource_network_group_assignment.go @@ -52,7 +52,10 @@ func (r *networkGroupAssignmentResource) Schema( resp *resource.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Manages a network group assignment.", + Description: "Manages a network group assignment." + + "\n\nNote: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. " + + "This will help maintain dependencies between resources. This is useful when a " + + "destructive action is performed on an ancestor of the assigned group.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The identifier of the network group assignment", @@ -63,12 +66,12 @@ func (r *networkGroupAssignmentResource) Schema( }, "network_id": schema.StringAttribute{ Description: "The identifier of the network to be assigned. " + - "Use wired network id; " + - "`uxi_wired_network` resource id field; " + - "`uxi_wired_network` datasource id field; " + - "wireless network id; " + - "`uxi_wireless_network` resource id field or " + - "`uxi_wireless_network` datasource id field here.", + "Use `hpeuxi_wired_network` resource id field; " + + "`data.hpeuxi_wired_network` id field; " + + "`hpeuxi_wireless_network` resource id field; " + + "`data.hpeuxi_wireless_network` id field " + + "wired network id; " + + "or wireless network id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), @@ -76,9 +79,9 @@ func (r *networkGroupAssignmentResource) Schema( }, "group_id": schema.StringAttribute{ Description: "The identifier of the group to be assigned to. " + - "Use group id; " + - "`uxi_group` resource id field or " + - "`uxi_group` datasource id field here.", + "Use `hpeuxi_group` resource id field (recommended); " + + "`data.hpeuxi_group` id field or " + + "group id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/provider/resources/resource_sensor_group_assignment.go b/internal/provider/resources/resource_sensor_group_assignment.go index 20663000..cf30c838 100644 --- a/internal/provider/resources/resource_sensor_group_assignment.go +++ b/internal/provider/resources/resource_sensor_group_assignment.go @@ -52,7 +52,10 @@ func (r *sensorGroupAssignmentResource) Schema( resp *resource.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Manages a sensor group assignment.", + Description: "Manages a sensor group assignment." + + "\n\nNote: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. " + + "This will help maintain dependencies between resources. This is useful when a " + + "destructive action is performed on an ancestor of the assigned group.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The identifier of the sensor group assignment", @@ -63,9 +66,9 @@ func (r *sensorGroupAssignmentResource) Schema( }, "sensor_id": schema.StringAttribute{ Description: "The identifier of the sensor to be assigned. " + - "Use sensor id; " + - "`uxi_sensor` resource id field or " + - "`uxi_sensor` datasource id field here.", + "Use `hpeuxi_sensor` resource id field; " + + "`data.hpeuxi_sensor` id field or " + + "sensor id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), @@ -73,9 +76,9 @@ func (r *sensorGroupAssignmentResource) Schema( }, "group_id": schema.StringAttribute{ Description: "The identifier of the group to be assigned to. " + - "Use group id; " + - "`uxi_group` resource id field or " + - "`uxi_group` datasource id field here.", + "Use `hpeuxi_group` resource id field (recommended); " + + "`data.hpeuxi_group` id field or " + + "group id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/provider/resources/resource_service_group_assignment.go b/internal/provider/resources/resource_service_group_assignment.go index b4c8d84c..ddb16b9c 100644 --- a/internal/provider/resources/resource_service_group_assignment.go +++ b/internal/provider/resources/resource_service_group_assignment.go @@ -52,7 +52,10 @@ func (r *serviceTestGroupAssignmentResource) Schema( resp *resource.SchemaResponse, ) { resp.Schema = schema.Schema{ - Description: "Manages a service test group assignment.", + Description: "Manages a service test group assignment." + + "\n\nNote: it is recommended to use a `hpeuxi_group` **resource** `id` as the `group_id`. " + + "This will help maintain dependencies between resources. This is useful when a " + + "destructive action is performed on an ancestor of the assigned group.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The identifier of the service test group assignment", @@ -63,9 +66,9 @@ func (r *serviceTestGroupAssignmentResource) Schema( }, "service_test_id": schema.StringAttribute{ Description: "The identifier of the service test to be assigned. " + - "Use service test id; " + - "`uxi_service_test` resource id field or " + - "`uxi_service_test` datasource id field here.", + "Use `hpeuxi_service_test` resource id field; " + + "`data.hpeuxi_service_test` id field or " + + "service test id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), @@ -73,9 +76,9 @@ func (r *serviceTestGroupAssignmentResource) Schema( }, "group_id": schema.StringAttribute{ Description: "The identifier of the group to be assigned to. " + - "Use group id; " + - "`uxi_group` resource id field or " + - "`uxi_group` datasource id field here.", + "Use `hpeuxi_group` resource id field (recommended); " + + "`data.hpeuxi_group` id field or " + + "group id here.", Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(),