Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change service_name to name #725

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apstra/analytics/telemetry_service_registry_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type TelemetryServiceRegistryEntry struct {
ServiceName types.String `tfsdk:"service_name"`
Name types.String `tfsdk:"name"`
ApplicationSchema jsontypes.Normalized `tfsdk:"application_schema"`
StorageSchemaPath types.String `tfsdk:"storage_schema_path"`
Builtin types.Bool `tfsdk:"built_in"`
Expand All @@ -28,7 +28,7 @@ type TelemetryServiceRegistryEntry struct {

func (o TelemetryServiceRegistryEntry) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
return map[string]dataSourceSchema.Attribute{
"service_name": dataSourceSchema.StringAttribute{
"name": dataSourceSchema.StringAttribute{
MarkdownDescription: "Service Name. Used to identify the Service.",
Required: true,
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
Expand Down Expand Up @@ -59,7 +59,7 @@ func (o TelemetryServiceRegistryEntry) DataSourceAttributes() map[string]dataSou

func (o TelemetryServiceRegistryEntry) ResourceAttributes() map[string]resourceSchema.Attribute {
return map[string]resourceSchema.Attribute{
"service_name": resourceSchema.StringAttribute{
"name": resourceSchema.StringAttribute{
MarkdownDescription: "Service Name. Used to identify the Service.",
Required: true,
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
Expand Down Expand Up @@ -95,7 +95,7 @@ func (o TelemetryServiceRegistryEntry) ResourceAttributes() map[string]resourceS
}

func (o *TelemetryServiceRegistryEntry) LoadApiData(ctx context.Context, in *apstra.TelemetryServiceRegistryEntry, diag *diag.Diagnostics) {
o.ServiceName = types.StringValue(in.ServiceName)
o.Name = types.StringValue(in.ServiceName)
o.Version = types.StringValue(in.Version)
o.Description = utils.StringValueOrNull(ctx, in.Description, diag)
o.Builtin = types.BoolValue(in.Builtin)
Expand All @@ -112,7 +112,7 @@ func (o *TelemetryServiceRegistryEntry) Request(_ context.Context, diags *diag.D
}

return &apstra.TelemetryServiceRegistryEntry{
ServiceName: o.ServiceName.ValueString(),
ServiceName: o.Name.ValueString(),
ApplicationSchema: []byte(o.ApplicationSchema.ValueString()),
StorageSchemaPath: storageSchemaPath,
Builtin: o.Builtin.ValueBool(),
Expand Down
12 changes: 6 additions & 6 deletions apstra/data_source_telemetry_service_registry_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (o *dataSourceTelemetryServiceRegistryEntries) Schema(_ context.Context, _
resp.Schema = schema.Schema{
MarkdownDescription: docCategoryDesign + "This data source returns the Service Names of Telemetry Service Registry Entries.",
Attributes: map[string]schema.Attribute{
"service_names": schema.SetAttribute{
"names": schema.SetAttribute{
MarkdownDescription: "A set of Service Names",
Computed: true,
ElementType: types.StringType,
Expand All @@ -45,8 +45,8 @@ func (o *dataSourceTelemetryServiceRegistryEntries) Schema(_ context.Context, _

func (o *dataSourceTelemetryServiceRegistryEntries) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config struct {
ServiceNames types.Set `tfsdk:"service_names"`
BuiltIn types.Bool `tfsdk:"built_in"`
Names types.Set `tfsdk:"names"`
BuiltIn types.Bool `tfsdk:"built_in"`
}

// get the configuration
Expand Down Expand Up @@ -75,10 +75,10 @@ func (o *dataSourceTelemetryServiceRegistryEntries) Read(ctx context.Context, re

// create new state object
var state struct {
ServiceNames types.Set `tfsdk:"service_names"`
BuiltIn types.Bool `tfsdk:"built_in"`
Names types.Set `tfsdk:"names"`
BuiltIn types.Bool `tfsdk:"built_in"`
}
state.ServiceNames = snameSet
state.Names = snameSet
state.BuiltIn = config.BuiltIn
// set state
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
Expand Down
4 changes: 2 additions & 2 deletions apstra/data_source_telemetry_service_registry_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func (o *dataSourceTelemetryServiceRegistryEntry) Read(ctx context.Context, req
return
}

api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, config.ServiceName.ValueString())
api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, config.Name.ValueString())
if utils.IsApstra404(err) {
resp.Diagnostics.AddAttributeError(
path.Root("name"),
"TelemetryServiceRegistryEntry not found",
fmt.Sprintf("TelemetryServiceRegistryEntry with Name %q not found", config.ServiceName.ValueString()))
fmt.Sprintf("TelemetryServiceRegistryEntry with Name %q not found", config.Name.ValueString()))
return
}
if err != nil { // catch errors other than 404 from above
Expand Down
4 changes: 2 additions & 2 deletions apstra/data_source_telemetry_service_registry_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
const (
dataSourceTelemetryServiceRegistryByServiceNameHCL = `
data "apstra_telemetry_service_registry_entry" "test" {
service_name = "%s"
name = "%s"
}
`
)
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestAccDataSourceTelemetryServiceRegistryEntry(t *testing.T) {
Config: insecureProviderConfigHCL + fmt.Sprintf(dataSourceTelemetryServiceRegistryByServiceNameHCL, ts.ServiceName),
Check: resource.ComposeAggregateTestCheckFunc(
// Verify data source/resource fields match
resource.TestCheckResourceAttr("data.apstra_telemetry_service_registry_entry.test", "service_name", ts.ServiceName),
resource.TestCheckResourceAttr("data.apstra_telemetry_service_registry_entry.test", "name", ts.ServiceName),
resource.TestCheckResourceAttr("data.apstra_telemetry_service_registry_entry.test", "storage_schema_path", utils.StringersToFriendlyString(ts.StorageSchemaPath)),
resource.TestCheckResourceAttrWith("data.apstra_telemetry_service_registry_entry.test", "application_schema", TestAppSchema),
),
Expand Down
10 changes: 5 additions & 5 deletions apstra/resource_telemetry_service_registry_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (o *resourceTelemetryServiceRegistryEntry) Create(ctx context.Context, req
return
}

api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, plan.ServiceName.ValueString())
api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, plan.Name.ValueString())
if err != nil {
resp.Diagnostics.AddError("Error retrieving TelemetryServiceRegistryEntry", err.Error())
return
Expand All @@ -85,7 +85,7 @@ func (o *resourceTelemetryServiceRegistryEntry) Read(ctx context.Context, req re
return
}

api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, state.ServiceName.ValueString())
api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, state.Name.ValueString())
if utils.IsApstra404(err) {
resp.State.RemoveResource(ctx)
return
Expand Down Expand Up @@ -117,13 +117,13 @@ func (o *resourceTelemetryServiceRegistryEntry) Update(ctx context.Context, req
return
}

err := o.client.UpdateTelemetryServiceRegistryEntry(ctx, plan.ServiceName.ValueString(), tsReq)
err := o.client.UpdateTelemetryServiceRegistryEntry(ctx, plan.Name.ValueString(), tsReq)
if err != nil {
resp.Diagnostics.AddError("error updating Telemetry Service Registry Entry", err.Error())
return
}

api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, plan.ServiceName.ValueString())
api, err := o.client.GetTelemetryServiceRegistryEntry(ctx, plan.Name.ValueString())
if err != nil {
resp.Diagnostics.AddError("Error retrieving TelemetryServiceRegistryEntry", err.Error())
return
Expand All @@ -145,7 +145,7 @@ func (o *resourceTelemetryServiceRegistryEntry) Delete(ctx context.Context, req
return
}

err := o.client.DeleteTelemetryServiceRegistryEntry(ctx, state.ServiceName.ValueString())
err := o.client.DeleteTelemetryServiceRegistryEntry(ctx, state.Name.ValueString())
if err != nil {
if utils.IsApstra404(err) {
return // 404 is okay
Expand Down
6 changes: 3 additions & 3 deletions apstra/resource_telemetry_service_registry_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// resource config
resource "apstra_telemetry_service_registry_entry" "test" {
description = "Test Registry Entry"
service_name = "%s"
name = "%s"
application_schema = jsonencode(%s)
storage_schema_path = "%s"

Expand Down Expand Up @@ -242,7 +242,7 @@ func TestAccResourceTelemetryServiceRegistryEntry(t *testing.T) {
Config: insecureProviderConfigHCL + testAccResourceServiceRegistryCfg1,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify name and data
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "service_name", testAccResourceServiceName),
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "name", testAccResourceServiceName),
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "storage_schema_path", ss1),
resource.TestCheckResourceAttrWith("apstra_telemetry_service_registry_entry.test", "application_schema", TestSR1),
),
Expand All @@ -252,7 +252,7 @@ func TestAccResourceTelemetryServiceRegistryEntry(t *testing.T) {
Config: insecureProviderConfigHCL + testAccResourceServiceRegistryCfg2,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify name and data
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "service_name", testAccResourceServiceName),
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "name", testAccResourceServiceName),
resource.TestCheckResourceAttr("apstra_telemetry_service_registry_entry.test", "storage_schema_path", ss2),
resource.TestCheckResourceAttrWith("apstra_telemetry_service_registry_entry.test", "application_schema", TestSR2),
),
Expand Down
8 changes: 4 additions & 4 deletions docs/data-sources/telemetry_service_registry_entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ output "not_builtin_entries" {

#all_entries = {
# "built_in" = tobool(null)
# "service_names" = toset([
# "names" = toset([
# "TestTelemetryServiceA",
# "TestTelemetryServiceC",
# "TestTelemetryServiceD",
Expand Down Expand Up @@ -85,7 +85,7 @@ output "not_builtin_entries" {
#}
#builtin_entries = {
# "built_in" = true
# "service_names" = toset([
# "names" = toset([
# "arp",
# "bgp",
# "bgp_communities",
Expand Down Expand Up @@ -125,7 +125,7 @@ output "not_builtin_entries" {
#}
#not_builtin_entries = {
# "built_in" = false
# "service_names" = toset([
# "names" = toset([
# "TestTelemetryServiceA",
# "TestTelemetryServiceC",
# "TestTelemetryServiceD",
Expand All @@ -142,4 +142,4 @@ output "not_builtin_entries" {

### Read-Only

- `service_names` (Set of String) A set of Service Names
- `names` (Set of String) A set of Service Names
10 changes: 5 additions & 5 deletions docs/data-sources/telemetry_service_registry_entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ data "apstra_telemetry_service_registry_entries" "not_builtin" {
}

data "apstra_telemetry_service_registry_entry" "all_not_built_in" {
for_each = data.apstra_telemetry_service_registry_entries.not_builtin.service_names
service_name = each.value
for_each = data.apstra_telemetry_service_registry_entries.not_builtin.names
name = each.value
}

output "not_built_in_entry" {
Expand All @@ -37,15 +37,15 @@ output "not_built_in_entry" {
# "application_schema" = "{\"properties\": {\"key\": {\"properties\": {\"authenticated_vlan\": {\"type\": \"string\"}, \"authorization_status\": {\"type\": \"string\"}, \"fallback_vlan_active\": {\"enum\": [\"True\", \"False\"], \"type\": \"string\"}, \"port_status\": {\"enum\": [\"authorized\", \"blocked\"], \"type\": \"string\"}, \"supplicant_mac\": {\"pattern\": \"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\", \"type\": \"string\"}}, \"required\": [\"supplicant_mac\", \"authenticated_vlan\", \"authorization_status\", \"port_status\", \"fallback_vlan_active\"], \"type\": \"object\"}, \"value\": {\"description\": \"0 in case of blocked, 1 in case of authorized\", \"type\": \"integer\"}}, \"required\": [\"key\", \"value\"], \"type\": \"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service A"
# "service_name" = "TestTelemetryServiceA"
# "name" = "TestTelemetryServiceA"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
# }
# "TestTelemetryServiceC" = {
# "application_schema" = "{\"properties\": {\"key\": {\"properties\": {\"authenticated_vlan\": {\"type\": \"string\"}, \"authorization_status\": {\"type\": \"string\"}, \"fallback_vlan_active\": {\"enum\": [\"True\", \"False\"], \"type\": \"string\"}, \"port_status\": {\"enum\": [\"authorized\", \"blocked\"], \"type\": \"string\"}, \"supplicant_mac\": {\"pattern\": \"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\", \"type\": \"string\"}}, \"required\": [\"supplicant_mac\", \"authenticated_vlan\", \"authorization_status\", \"port_status\", \"fallback_vlan_active\"], \"type\": \"object\"}, \"value\": {\"description\": \"0 in case of blocked, 1 in case of authorized\", \"type\": \"integer\"}}, \"required\": [\"key\", \"value\"], \"type\": \"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service B"
# "service_name" = "TestTelemetryServiceC"
# "name" = "TestTelemetryServiceC"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
# }
Expand All @@ -57,7 +57,7 @@ output "not_built_in_entry" {

### Required

- `service_name` (String) Service Name. Used to identify the Service.
- `name` (String) Service Name. Used to identify the Service.

### Read-Only

Expand Down
6 changes: 3 additions & 3 deletions docs/resources/telemetry_service_registry_entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "apstra_telemetry_service_registry_entry" "maketest" {
}
)
description = "Test Telemetry Service B"
service_name = "TestTelemetryServiceC"
name = "TestTelemetryServiceC"
storage_schema_path = "aos.sdk.telemetry.schemas.iba_integer_data"
}

Expand All @@ -80,7 +80,7 @@ output "r" {
# "application_schema" = "{\"properties\":{\"key\":{\"properties\":{\"authenticated_vlan\":{\"type\":\"string\"},\"authorization_status\":{\"type\":\"string\"},\"fallback_vlan_active\":{\"enum\":[\"True\",\"False\"],\"type\":\"string\"},\"port_status\":{\"enum\":[\"authorized\",\"blocked\"],\"type\":\"string\"},\"supplicant_mac\":{\"pattern\":\"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\",\"type\":\"string\"}},\"required\":[\"supplicant_mac\",\"authenticated_vlan\",\"authorization_status\",\"port_status\",\"fallback_vlan_active\"],\"type\":\"object\"},\"value\":{\"description\":\"0 in case of blocked, 1 in case of authorized\",\"type\":\"integer\"}},\"required\":[\"key\",\"value\"],\"type\":\"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service B"
# "service_name" = "TestTelemetryServiceC"
# "name" = "TestTelemetryServiceC"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
#}
Expand All @@ -92,7 +92,7 @@ output "r" {
### Required

- `application_schema` (String) Application Schema expressed in JSON
- `service_name` (String) Service Name. Used to identify the Service.
- `name` (String) Service Name. Used to identify the Service.
- `storage_schema_path` (String) Storage Schema Path. Must be one of:
- arp
- bgp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ output "not_builtin_entries" {

#all_entries = {
# "built_in" = tobool(null)
# "service_names" = toset([
# "names" = toset([
# "TestTelemetryServiceA",
# "TestTelemetryServiceC",
# "TestTelemetryServiceD",
Expand Down Expand Up @@ -70,7 +70,7 @@ output "not_builtin_entries" {
#}
#builtin_entries = {
# "built_in" = true
# "service_names" = toset([
# "names" = toset([
# "arp",
# "bgp",
# "bgp_communities",
Expand Down Expand Up @@ -110,7 +110,7 @@ output "not_builtin_entries" {
#}
#not_builtin_entries = {
# "built_in" = false
# "service_names" = toset([
# "names" = toset([
# "TestTelemetryServiceA",
# "TestTelemetryServiceC",
# "TestTelemetryServiceD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ data "apstra_telemetry_service_registry_entries" "not_builtin" {
}

data "apstra_telemetry_service_registry_entry" "all_not_built_in" {
for_each = data.apstra_telemetry_service_registry_entries.not_builtin.service_names
service_name = each.value
for_each = data.apstra_telemetry_service_registry_entries.not_builtin.names
name = each.value
}

output "not_built_in_entry" {
Expand All @@ -22,15 +22,15 @@ output "not_built_in_entry" {
# "application_schema" = "{\"properties\": {\"key\": {\"properties\": {\"authenticated_vlan\": {\"type\": \"string\"}, \"authorization_status\": {\"type\": \"string\"}, \"fallback_vlan_active\": {\"enum\": [\"True\", \"False\"], \"type\": \"string\"}, \"port_status\": {\"enum\": [\"authorized\", \"blocked\"], \"type\": \"string\"}, \"supplicant_mac\": {\"pattern\": \"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\", \"type\": \"string\"}}, \"required\": [\"supplicant_mac\", \"authenticated_vlan\", \"authorization_status\", \"port_status\", \"fallback_vlan_active\"], \"type\": \"object\"}, \"value\": {\"description\": \"0 in case of blocked, 1 in case of authorized\", \"type\": \"integer\"}}, \"required\": [\"key\", \"value\"], \"type\": \"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service A"
# "service_name" = "TestTelemetryServiceA"
# "name" = "TestTelemetryServiceA"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
# }
# "TestTelemetryServiceC" = {
# "application_schema" = "{\"properties\": {\"key\": {\"properties\": {\"authenticated_vlan\": {\"type\": \"string\"}, \"authorization_status\": {\"type\": \"string\"}, \"fallback_vlan_active\": {\"enum\": [\"True\", \"False\"], \"type\": \"string\"}, \"port_status\": {\"enum\": [\"authorized\", \"blocked\"], \"type\": \"string\"}, \"supplicant_mac\": {\"pattern\": \"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\", \"type\": \"string\"}}, \"required\": [\"supplicant_mac\", \"authenticated_vlan\", \"authorization_status\", \"port_status\", \"fallback_vlan_active\"], \"type\": \"object\"}, \"value\": {\"description\": \"0 in case of blocked, 1 in case of authorized\", \"type\": \"integer\"}}, \"required\": [\"key\", \"value\"], \"type\": \"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service B"
# "service_name" = "TestTelemetryServiceC"
# "name" = "TestTelemetryServiceC"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
# }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "apstra_telemetry_service_registry_entry" "maketest" {
}
)
description = "Test Telemetry Service B"
service_name = "TestTelemetryServiceC"
name = "TestTelemetryServiceC"
storage_schema_path = "aos.sdk.telemetry.schemas.iba_integer_data"
}

Expand All @@ -65,7 +65,7 @@ output "r" {
# "application_schema" = "{\"properties\":{\"key\":{\"properties\":{\"authenticated_vlan\":{\"type\":\"string\"},\"authorization_status\":{\"type\":\"string\"},\"fallback_vlan_active\":{\"enum\":[\"True\",\"False\"],\"type\":\"string\"},\"port_status\":{\"enum\":[\"authorized\",\"blocked\"],\"type\":\"string\"},\"supplicant_mac\":{\"pattern\":\"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$\",\"type\":\"string\"}},\"required\":[\"supplicant_mac\",\"authenticated_vlan\",\"authorization_status\",\"port_status\",\"fallback_vlan_active\"],\"type\":\"object\"},\"value\":{\"description\":\"0 in case of blocked, 1 in case of authorized\",\"type\":\"integer\"}},\"required\":[\"key\",\"value\"],\"type\":\"object\"}"
# "built_in" = false
# "description" = "Test Telemetry Service B"
# "service_name" = "TestTelemetryServiceC"
# "name" = "TestTelemetryServiceC"
# "storage_schema_path" = "aos.sdk.telemetry.schemas.iba_integer_data"
# "version" = ""
#}
Loading