Skip to content

Commit

Permalink
Merge branch 'main' into hpesign
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon committed Nov 14, 2024
2 parents 87d7b58 + f30c5a1 commit 747f628
Show file tree
Hide file tree
Showing 150 changed files with 6,082 additions and 1,735 deletions.
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ generate-config-api-client: retrieve-config-api-openapi-spec
--output /local/{{ CONFIG_API_CLIENT_DIR }} \
--package-name config_api_client \
--git-user-id aruba-uxi \
--git-repo-id terraform-provider-configuration-api/{{ CONFIG_API_CLIENT_DIR }} \
--git-repo-id terraform-provider-hpeuxi/{{ CONFIG_API_CLIENT_DIR }} \
--openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=configuration
just tidy-client
just fmt-client
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ go_path = $(go env GOPATH)/bin

```
dev_overrides {
"registry.terraform.io/arubauxi/configuration" = "<go_path>"
"registry.terraform.io/arubauxi/hpeuxi" = "<go_path>"
}
```

Example `~/.terraformrc` file
```
provider_installation {
dev_overrides {
"registry.terraform.io/arubauxi/configuration" = "/Users/<user>/go/bin"
"registry.terraform.io/arubauxi/hpeuxi" = "/Users/<user>/go/bin"
}
direct {}
}
Expand Down
3 changes: 0 additions & 3 deletions docs/data-sources/agent.md

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

2 changes: 1 addition & 1 deletion docs/data-sources/service_test.md

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

2 changes: 1 addition & 1 deletion examples/full-demo/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
uxi = {
source = "registry.terraform.io/arubauxi/configuration"
source = "registry.terraform.io/arubauxi/hpeuxi"
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/aruba-uxi/terraform-provider-configuration
module github.com/aruba-uxi/terraform-provider-hpeuxi

go 1.21

toolchain go1.22.5

require (
github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client v0.0.0-00010101000000-000000000000
github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client v0.0.0-00010101000000-000000000000
github.com/h2non/gock v1.2.0
github.com/hashicorp/terraform-plugin-framework v1.10.0
github.com/hashicorp/terraform-plugin-go v0.23.0
Expand All @@ -22,6 +22,7 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
Expand Down Expand Up @@ -68,4 +69,4 @@ require (
google.golang.org/protobuf v1.34.0 // indirect
)

replace github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client => ./pkg/config-api-client
replace github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client => ./pkg/config-api-client
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE=
github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package config

const (
MaxRetriesFor429 = 10
MaxRetriesForTooManyRequests = 10
)
35 changes: 12 additions & 23 deletions internal/provider/datasources/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand All @@ -24,17 +24,14 @@ type agentDataSource struct {
}

type agentDataSourceModel struct {
Id types.String `tfsdk:"id"`
Serial types.String `tfsdk:"serial"`
Name types.String `tfsdk:"name"`
ModelNumber types.String `tfsdk:"model_number"`
WifiMacAddress types.String `tfsdk:"wifi_mac_address"`
EthernetMacAddress types.String `tfsdk:"ethernet_mac_address"`
AddressNote types.String `tfsdk:"address_note"`
Longitude types.Float32 `tfsdk:"longitude"`
Latitude types.Float32 `tfsdk:"latitude"`
Notes types.String `tfsdk:"notes"`
PcapMode types.String `tfsdk:"pcap_mode"`
Id types.String `tfsdk:"id"`
Serial types.String `tfsdk:"serial"`
Name types.String `tfsdk:"name"`
ModelNumber types.String `tfsdk:"model_number"`
WifiMacAddress types.String `tfsdk:"wifi_mac_address"`
EthernetMacAddress types.String `tfsdk:"ethernet_mac_address"`
Notes types.String `tfsdk:"notes"`
PcapMode types.String `tfsdk:"pcap_mode"`
Filter struct {
AgentID types.String `tfsdk:"agent_id"`
} `tfsdk:"filter"`
Expand Down Expand Up @@ -73,15 +70,6 @@ func (d *agentDataSource) Schema(
"ethernet_mac_address": schema.StringAttribute{
Computed: true,
},
"address_note": schema.StringAttribute{
Computed: true,
},
"longitude": schema.Float32Attribute{
Computed: true,
},
"latitude": schema.Float32Attribute{
Computed: true,
},
"notes": schema.StringAttribute{
Computed: true,
},
Expand Down Expand Up @@ -118,7 +106,7 @@ func (d *agentDataSource) Read(
AgentsGet(ctx).
Id(state.Filter.AgentID.ValueString())

agentResponse, response, err := util.RetryFor429(request.Execute)
agentResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_agent")
Expand All @@ -137,6 +125,7 @@ func (d *agentDataSource) Read(

state.Id = types.StringValue(agent.Id)
state.Name = types.StringValue(agent.Name)
state.Serial = types.StringValue(agent.Serial)
state.ModelNumber = types.StringPointerValue(agent.ModelNumber.Get())
state.WifiMacAddress = types.StringPointerValue(agent.WifiMacAddress.Get())
state.EthernetMacAddress = types.StringPointerValue(agent.EthernetMacAddress.Get())
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/datasources/agent_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (d *agentGroupAssignmentDataSource) Read(
request := d.client.ConfigurationAPI.
AgentGroupAssignmentsGet(ctx).
Id(state.Filter.AgentGroupAssignmentID)
agentGroupAssignmentResponse, response, err := util.RetryFor429(request.Execute)
agentGroupAssignmentResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_agent_group_assignment")
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/datasources/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -90,7 +90,7 @@ func (d *groupDataSource) Read(
GroupsGet(ctx).
Id(*state.Filter.GroupID)

groupResponse, response, err := util.RetryFor429(request.Execute)
groupResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_group")
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/datasources/network_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (d *networkGroupAssignmentDataSource) Read(
request := d.client.ConfigurationAPI.
NetworkGroupAssignmentsGet(ctx).
Id(state.Filter.NetworkGroupAssignmentID)
networkGroupAssignmentResponse, response, err := util.RetryFor429(request.Execute)
networkGroupAssignmentResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_network_group_assignment")
Expand Down
9 changes: 5 additions & 4 deletions internal/provider/datasources/sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -118,7 +118,7 @@ func (d *sensorDataSource) Read(
SensorsGet(ctx).
Id(state.Filter.SensorID.ValueString())

sensorResponse, response, err := util.RetryFor429(request.Execute)
sensorResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_sensor")
Expand All @@ -137,12 +137,13 @@ func (d *sensorDataSource) Read(

state.Id = types.StringValue(sensor.Id)
state.Name = types.StringValue(sensor.Name)
state.Serial = types.StringValue(sensor.Serial)
state.ModelNumber = types.StringValue(sensor.ModelNumber)
state.WifiMacAddress = types.StringPointerValue(sensor.WifiMacAddress.Get())
state.EthernetMacAddress = types.StringPointerValue(sensor.EthernetMacAddress.Get())
state.AddressNote = types.StringPointerValue(sensor.AddressNote.Get())
state.Longitude = types.Float32PointerValue(sensor.Longitude.Get())
state.Latitude = types.Float32PointerValue(sensor.Latitude.Get())
state.Longitude = types.Float32PointerValue(sensor.Longitude.Get())
state.Notes = types.StringPointerValue(sensor.Notes.Get())
state.PcapMode = types.StringPointerValue(sensor.PcapMode.Get())

Expand Down
6 changes: 3 additions & 3 deletions internal/provider/datasources/sensor_group_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -86,7 +86,7 @@ func (d *sensorGroupAssignmentDataSource) Read(
request := d.client.ConfigurationAPI.
SensorGroupAssignmentsGet(ctx).
Id(state.Filter.SensorGroupAssignmentID)
sensorGroupAssignmentResponse, response, err := util.RetryFor429(request.Execute)
sensorGroupAssignmentResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("create", "uxi_sensor_group_assignment")
Expand Down
14 changes: 9 additions & 5 deletions internal/provider/datasources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand All @@ -29,7 +29,7 @@ type serviceTestDataSourceModel struct {
Name types.String `tfsdk:"name"`
Target types.String `tfsdk:"target"`
Template types.String `tfsdk:"template"`
IsEnabled types.String `tfsdk:"is_enabled"`
IsEnabled types.Bool `tfsdk:"is_enabled"`
Filter struct {
ServiceTestID types.String `tfsdk:"service_test_id"`
} `tfsdk:"filter"`
Expand Down Expand Up @@ -65,7 +65,7 @@ func (d *serviceTestDataSource) Schema(
"template": schema.StringAttribute{
Computed: true,
},
"is_enabled": schema.StringAttribute{
"is_enabled": schema.BoolAttribute{
Computed: true,
},
"filter": schema.SingleNestedAttribute{
Expand Down Expand Up @@ -98,7 +98,7 @@ func (d *serviceTestDataSource) Read(
ServiceTestsGet(ctx).
Id(state.Filter.ServiceTestID.ValueString())

serviceTestResponse, response, err := util.RetryFor429(request.Execute)
serviceTestResponse, response, err := util.RetryForTooManyRequests(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_service_test")
Expand All @@ -116,7 +116,11 @@ func (d *serviceTestDataSource) Read(
serviceTest := serviceTestResponse.Items[0]

state.Id = types.StringValue(serviceTest.Id)
state.Category = types.StringValue(serviceTest.Category)
state.Name = types.StringValue(serviceTest.Name)
state.Target = types.StringPointerValue(serviceTest.Target.Get())
state.Template = types.StringValue(serviceTest.Template)
state.IsEnabled = types.BoolValue(serviceTest.IsEnabled)

// Set state
diags = resp.State.Set(ctx, &state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

config_api_client "github.com/aruba-uxi/terraform-provider-configuration-api/pkg/config-api-client"
"github.com/aruba-uxi/terraform-provider-configuration/internal/provider/util"
"github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util"
config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -84,7 +84,9 @@ func (d *serviceTestGroupAssignmentDataSource) Read(
request := d.client.ConfigurationAPI.
ServiceTestGroupAssignmentsGet(ctx).
Id(state.Filter.ServiceTestGroupAssignmentID)
serviceTestGroupAssignmentResponse, response, err := util.RetryFor429(request.Execute)
serviceTestGroupAssignmentResponse, response, err := util.RetryForTooManyRequests(
request.Execute,
)
errorPresent, errorDetail := util.RaiseForStatus(response, err)

errorSummary := util.GenerateErrorSummary("read", "uxi_service_test_group_assignment")
Expand Down
Loading

0 comments on commit 747f628

Please sign in to comment.