Skip to content

Commit

Permalink
HCL syntax cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpitman committed Sep 10, 2024
1 parent cbad3f6 commit b10a6a6
Show file tree
Hide file tree
Showing 15 changed files with 1,321 additions and 1,816 deletions.
1,668 changes: 840 additions & 828 deletions dynatrace/api/openpipeline/jsonmodel/openapi.yaml

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions dynatrace/api/openpipeline/settings/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func (ep *Endpoints) Schema() map[string]*schema.Schema {
}

func (ep *Endpoints) MarshalHCL(properties hcl.Properties) error {
return properties.Encode("endpoints", ep.Endpoints)
return properties.Encode("endpoint", ep.Endpoints)
}

func (ep *Endpoints) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.Decode("endpoints", &ep.Endpoints)
return decoder.Decode("endpoint", &ep.Endpoints)
}

func (d Endpoints) MarshalJSON() ([]byte, error) {
Expand All @@ -51,11 +51,11 @@ type EndpointDefinition struct {

func (d *EndpointDefinition) Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"base_path": {
Type: schema.TypeString,
Description: "The base path of the ingest source.",
Required: true,
},
// "base_path": {
// Type: schema.TypeString,
// Description: "The base path of the ingest source.",
// Required: true,
// },
// "builtin": {
// Type: schema.TypeString,
// Description: "Indicates if the object is provided by Dynatrace or customer defined.",
Expand All @@ -69,7 +69,7 @@ func (d *EndpointDefinition) Schema() map[string]*schema.Schema {
"display_name": {
Type: schema.TypeString,
Description: "Display name of the ingest source.",
Optional: true,
Required: true,
},
// "editable": {
// Type: schema.TypeBool,
Expand All @@ -92,7 +92,7 @@ func (d *EndpointDefinition) Schema() map[string]*schema.Schema {
MinItems: 1,
MaxItems: 1,
Elem: &schema.Resource{Schema: new(Routing).Schema()},
Optional: true,
Required: true,
},
"processors": {
Type: schema.TypeList,
Expand All @@ -107,7 +107,7 @@ func (d *EndpointDefinition) Schema() map[string]*schema.Schema {

func (d *EndpointDefinition) MarshalHCL(properties hcl.Properties) error {
return properties.EncodeAll(map[string]any{
"base_path": d.BasePath,
//"base_path": d.BasePath,
// "builtin": d.Builtin,
"default_bucket": d.DefaultBucket,
"display_name": d.DisplayName,
Expand All @@ -122,14 +122,14 @@ func (d *EndpointDefinition) MarshalHCL(properties hcl.Properties) error {
func (d *EndpointDefinition) UnmarshalHCL(decoder hcl.Decoder) error {

return decoder.DecodeAll(map[string]any{
"base_path": &d.BasePath,
//"base_path": &d.BasePath,
// "builtin": &d.Builtin,
"default_bucket": &d.DefaultBucket,
"display_name": &d.DisplayName,
// "editable": &d.Editable,
"enabled": d.Enabled,
"segment": d.Segment,
"routing": d.Routing,
"enabled": &d.Enabled,
"segment": &d.Segment,
"routing": &d.Routing,
"endpoint_processor": &d.Processors,
})
}
Expand Down
41 changes: 25 additions & 16 deletions dynatrace/api/openpipeline/settings/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ func (ep *BasePipeline) Schema() map[string]*schema.Schema {
MinItems: 1,
MaxItems: 1,
Elem: &schema.Resource{Schema: new(StorageStage).Schema()},
Optional: true,
Required: true,
},
"display_name": {
Type: schema.TypeString,
Description: "Display name of the pipeline.",
Optional: true,
Required: true,
},
// "editable": {
// Type: schema.TypeBool,
Expand All @@ -189,21 +189,24 @@ func (ep *BasePipeline) Schema() map[string]*schema.Schema {
"enabled": {
Type: schema.TypeBool,
Description: "Indicates if the object is active.",
Optional: true,
Required: true,
},
"id": {
Type: schema.TypeString,
Description: "Identifier of the pipeline.",
Optional: true,
Required: true,
},
}
}

func (ep *BasePipeline) MarshalHCL(properties hcl.Properties) error {
return properties.EncodeAll(map[string]any{
// "builtin": ep.Builtin,
"data_extraction": ep.DataExtraction,
"display_name": ep.DisplayName,
"data_extraction": ep.DataExtraction,
"metric_extraction": ep.MetricExtraction,
"security_context": ep.SecurityContext,
"storage": ep.Storage,
"display_name": ep.DisplayName,
// "editable": ep.Editable,
"enabled": ep.Enabled,
"id": ep.Id,
Expand All @@ -212,12 +215,15 @@ func (ep *BasePipeline) MarshalHCL(properties hcl.Properties) error {

func (ep *BasePipeline) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.DecodeAll(map[string]any{
// "builtin": ep.Builtin,
"data_extraction": ep.DataExtraction,
"display_name": ep.DisplayName,
// "editable": ep.Editable,
"enabled": ep.Enabled,
"id": ep.Id,
// "builtin": &ep.Builtin,
"data_extraction": &ep.DataExtraction,
"metric_extraction": &ep.MetricExtraction,
"security_context": &ep.SecurityContext,
"storage": &ep.Storage,
"display_name": &ep.DisplayName,
// "editable": &ep.Editable,
"enabled": &ep.Enabled,
"id": &ep.Id,
})
}

Expand All @@ -243,14 +249,16 @@ func (p *DefaultPipeline) MarshalHCL(properties hcl.Properties) error {
if err := p.BasePipeline.MarshalHCL(properties); err != nil {
return err
}
return nil

return properties.Encode("processing", &p.Processing)
}

func (p *DefaultPipeline) UnmarshalHCL(decoder hcl.Decoder) error {
if err := p.BasePipeline.UnmarshalHCL(decoder); err != nil {
return err
}
return nil

return decoder.Decode("processing", &p.Processing)
}

func (p DefaultPipeline) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -287,14 +295,15 @@ func (p *ClassicPipeline) MarshalHCL(properties hcl.Properties) error {
if err := p.BasePipeline.MarshalHCL(properties); err != nil {
return err
}
return properties.Encode("settings_schema", p.SettingsSchema)
return properties.EncodeAll(map[string]any{"settings_schema": p.SettingsSchema, "processing": p.Processing})
}

func (p *ClassicPipeline) UnmarshalHCL(decoder hcl.Decoder) error {
if err := p.BasePipeline.UnmarshalHCL(decoder); err != nil {
return err
}
return decoder.Decode("settings_schema", &p.SettingsSchema)
return decoder.DecodeAll(map[string]any{"settings_schema": &p.SettingsSchema, "processing": &p.Processing})

}

func (p ClassicPipeline) MarshalJSON() ([]byte, error) {
Expand Down
46 changes: 30 additions & 16 deletions dynatrace/api/openpipeline/settings/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ const (
FieldsAddProcessorType = "fieldsAdd"
FieldsRemoveProcessorType = "fieldsRemove"
FieldsRenameProcessorType = "fieldsRename"

CounterMetricProcessorType = "counterMetric"
ValueMetricProcessorType = "valueMetric"

DavisEventExtractionProcessorType = "davis"
BizEventExtractionProcessorType = "bizevent"

SecurityContextProcessorType = "securityContext"

NoStorageStageProcessorType = "noStorage"
BucketAssignmentStageProcessorType = "bucketAssignment"

TechnologyProcessorType = "technology"
SqlxProcessorType = "sqlx"
)

type Processor struct {
Expand Down Expand Up @@ -321,8 +335,8 @@ func (ep *FieldExtraction) MarshalHCL(properties hcl.Properties) error {
func (ep *FieldExtraction) UnmarshalHCL(decoder hcl.Decoder) error {

return decoder.DecodeAll(map[string]any{
"fields": ep.Fields,
"semantic": ep.Semantic,
"fields": &ep.Fields,
"semantic": &ep.Semantic,
})
}

Expand Down Expand Up @@ -383,8 +397,8 @@ func (ep *BizEventExtractionProcessor) UnmarshalHCL(decoder hcl.Decoder) error {
}

return decoder.DecodeAll(map[string]any{
"event_provider": ep.EventProvider,
"event_type": ep.EventType,
"event_provider": &ep.EventProvider,
"event_type": &ep.EventType,
})
}

Expand Down Expand Up @@ -503,9 +517,9 @@ func (ep *ValueAssignment) MarshalHCL(properties hcl.Properties) error {
func (ep *ValueAssignment) UnmarshalHCL(decoder hcl.Decoder) error {

return decoder.DecodeAll(map[string]any{
"type": ep.Type,
"field": ep.Field,
"constant": ep.Constant,
"type": &ep.Type,
"field": &ep.Field,
"constant": &ep.Constant,
})
}

Expand Down Expand Up @@ -612,14 +626,14 @@ func (p *CounterMetricExtractionProcessor) UnmarshalHCL(decoder hcl.Decoder) err
return err
}
return decoder.DecodeAll(map[string]any{
"dimensions": p.Dimensions,
"metric_key": p.MetricKey,
"dimensions": &p.Dimensions,
"metric_key": &p.MetricKey,
})
}

func (ep CounterMetricExtractionProcessor) MarshalJSON() ([]byte, error) {
type counterMetricExtractionProcessor CounterMetricExtractionProcessor
return MarshalAsJSONWithType((counterMetricExtractionProcessor)(ep), CounterMetricExtractionProcessorType)
return MarshalAsJSONWithType((counterMetricExtractionProcessor)(ep), CounterMetricProcessorType)
}

type ValueMetricExtractionProcessor struct {
Expand Down Expand Up @@ -667,15 +681,15 @@ func (p *ValueMetricExtractionProcessor) UnmarshalHCL(decoder hcl.Decoder) error
return err
}
return decoder.DecodeAll(map[string]any{
"dimensions": p.Dimensions,
"field": p.Field,
"metric_key": p.MetricKey,
"dimensions": &p.Dimensions,
"field": &p.Field,
"metric_key": &p.MetricKey,
})
}

func (ep ValueMetricExtractionProcessor) MarshalJSON() ([]byte, error) {
type valueMetricExtractionProcessor ValueMetricExtractionProcessor
return MarshalAsJSONWithType((valueMetricExtractionProcessor)(ep), ValueMetricExtracionProcessorType)
return MarshalAsJSONWithType((valueMetricExtractionProcessor)(ep), ValueMetricProcessorType)
}

type BucketAssignmentProcessor struct {
Expand Down Expand Up @@ -708,7 +722,7 @@ func (p *BucketAssignmentProcessor) UnmarshalHCL(decoder hcl.Decoder) error {
return err
}
return decoder.DecodeAll(map[string]any{
"bucket_name": p.BucketName,
"bucket_name": &p.BucketName,
})
}

Expand Down Expand Up @@ -772,7 +786,7 @@ func (p *SecurityContextProcessor) UnmarshalHCL(decoder hcl.Decoder) error {
return err
}
return decoder.DecodeAll(map[string]any{
"value": p.Value,
"value": &p.Value,
})
}

Expand Down
6 changes: 3 additions & 3 deletions dynatrace/api/openpipeline/settings/processor_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type EndpointProcessors struct {
func (ep *EndpointProcessors) Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"processor": {
Type: schema.TypeSet,
Type: schema.TypeList,
Description: "todo",
Elem: &schema.Resource{Schema: new(EndpointProcessor).Schema()},
Optional: true,
Expand All @@ -25,11 +25,11 @@ func (ep *EndpointProcessors) Schema() map[string]*schema.Schema {
}

func (ep *EndpointProcessors) MarshalHCL(properties hcl.Properties) error {
return properties.Encode("processors", ep.Processors)
return properties.Encode("processor", ep.Processors)
}

func (ep *EndpointProcessors) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.Decode("processors", &ep.Processors)
return decoder.Decode("processor", &ep.Processors)
}

func (ep EndpointProcessors) MarshalJSON() ([]byte, error) {
Expand Down
Loading

0 comments on commit b10a6a6

Please sign in to comment.