Skip to content

Commit

Permalink
fix: groups docs and plan modification (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 authored Dec 5, 2024
1 parent fd4714b commit 1e91925
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 49 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions docs/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions docs/resources/agent_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/resources/group.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/resources/network_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/resources/sensor_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/resources/service_test_group_assignment.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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. " +
Expand Down
17 changes: 10 additions & 7 deletions internal/provider/resources/resource_agent_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -63,19 +66,19 @@ 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(),
},
},
"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(),
Expand Down
12 changes: 7 additions & 5 deletions internal/provider/resources/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions internal/provider/resources/resource_network_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -63,22 +66,22 @@ 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(),
},
},
"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(),
Expand Down
17 changes: 10 additions & 7 deletions internal/provider/resources/resource_sensor_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -63,19 +66,19 @@ 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(),
},
},
"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(),
Expand Down
17 changes: 10 additions & 7 deletions internal/provider/resources/resource_service_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -63,19 +66,19 @@ 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(),
},
},
"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(),
Expand Down

0 comments on commit 1e91925

Please sign in to comment.