From c5f12fd2e683b9b6c0fc694458c151107bb82684 Mon Sep 17 00:00:00 2001 From: danischm Date: Tue, 25 Jul 2023 13:30:57 +0200 Subject: [PATCH] Set type for hardcoded values --- gen/definitions/generic/acl_policy_definition.yaml | 2 ++ .../generic/app_probe_class_policy_object.yaml | 1 + .../application_aware_routing_policy_definition.yaml | 2 ++ .../generic/application_list_policy_object.yaml | 1 + gen/definitions/generic/as_path_list_policy_object.yaml | 1 + gen/definitions/generic/cflowd_policy_definition.yaml | 1 + gen/definitions/generic/class_map_policy_object.yaml | 1 + gen/definitions/generic/color_list_policy_object.yaml | 1 + .../custom_control_topology_policy_definition.yaml | 1 + .../generic/data_ipv4_prefix_list_policy_object.yaml | 1 + .../generic/data_ipv6_prefix_list_policy_object.yaml | 1 + gen/definitions/generic/device_acl_policy_definition.yaml | 2 ++ .../generic/expanded_community_list_policy_object.yaml | 1 + .../generic/extended_community_list_policy_object.yaml | 1 + .../generic/hub_and_spoke_topology_policy_definition.yaml | 1 + .../generic/ipv4_prefix_list_policy_object.yaml | 1 + .../generic/ipv6_prefix_list_policy_object.yaml | 1 + gen/definitions/generic/localized_policy.yaml | 1 + .../generic/mesh_topology_policy_definition.yaml | 1 + gen/definitions/generic/mirror_policy_object.yaml | 1 + gen/definitions/generic/policer_policy_object.yaml | 1 + .../generic/preferred_color_group_policy_object.yaml | 1 + gen/definitions/generic/qos_map_policy_definition.yaml | 1 + gen/definitions/generic/region_list.yaml | 1 + .../generic/rewrite_rule_policy_definition.yaml | 1 + gen/definitions/generic/route_policy_definition.yaml | 3 +++ gen/definitions/generic/site_list_policy_object.yaml | 1 + gen/definitions/generic/sla_class_policy_object.yaml | 1 + .../generic/standard_community_list_policy_object.yaml | 1 + gen/definitions/generic/tloc_list_policy_object.yaml | 1 + .../generic/traffic_data_policy_definition.yaml | 1 + gen/definitions/generic/vpn_list_policy_object.yaml | 1 + .../generic/vpn_membership_policy_definition.yaml | 1 + gen/templates/generic/model.go | 8 ++++---- 34 files changed, 42 insertions(+), 4 deletions(-) diff --git a/gen/definitions/generic/acl_policy_definition.yaml b/gen/definitions/generic/acl_policy_definition.yaml index ed7b34fd..5ca06b8a 100644 --- a/gen/definitions/generic/acl_policy_definition.yaml +++ b/gen/definitions/generic/acl_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Localized Policies attributes: - model_name: type + type: String value: acl - model_name: name tf_name: name @@ -54,6 +55,7 @@ attributes: description: Sequence name example: Sequence 10 - model_name: sequenceType + type: String value: acl - model_name: baseAction tf_name: base_action diff --git a/gen/definitions/generic/app_probe_class_policy_object.yaml b/gen/definitions/generic/app_probe_class_policy_object.yaml index 594f56cf..708aee8c 100644 --- a/gen/definitions/generic/app_probe_class_policy_object.yaml +++ b/gen/definitions/generic/app_probe_class_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: appProbe - model_name: name tf_name: name diff --git a/gen/definitions/generic/application_aware_routing_policy_definition.yaml b/gen/definitions/generic/application_aware_routing_policy_definition.yaml index 06cc07bd..9e11a668 100644 --- a/gen/definitions/generic/application_aware_routing_policy_definition.yaml +++ b/gen/definitions/generic/application_aware_routing_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: appRoute - model_name: name tf_name: name @@ -40,6 +41,7 @@ attributes: description: Sequence name example: Region1 - model_name: sequenceType + type: String value: appRoute - model_name: sequenceIpType tf_name: ip_type diff --git a/gen/definitions/generic/application_list_policy_object.yaml b/gen/definitions/generic/application_list_policy_object.yaml index ff6134c3..796e5922 100644 --- a/gen/definitions/generic/application_list_policy_object.yaml +++ b/gen/definitions/generic/application_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: app - model_name: name tf_name: name diff --git a/gen/definitions/generic/as_path_list_policy_object.yaml b/gen/definitions/generic/as_path_list_policy_object.yaml index d18591ad..8251d8d1 100644 --- a/gen/definitions/generic/as_path_list_policy_object.yaml +++ b/gen/definitions/generic/as_path_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: asPath - model_name: name tf_name: name diff --git a/gen/definitions/generic/cflowd_policy_definition.yaml b/gen/definitions/generic/cflowd_policy_definition.yaml index dad7d93a..230a292d 100644 --- a/gen/definitions/generic/cflowd_policy_definition.yaml +++ b/gen/definitions/generic/cflowd_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: cflowd - model_name: name tf_name: name diff --git a/gen/definitions/generic/class_map_policy_object.yaml b/gen/definitions/generic/class_map_policy_object.yaml index 0a06d6bc..af7d3394 100644 --- a/gen/definitions/generic/class_map_policy_object.yaml +++ b/gen/definitions/generic/class_map_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: class - model_name: name tf_name: name diff --git a/gen/definitions/generic/color_list_policy_object.yaml b/gen/definitions/generic/color_list_policy_object.yaml index b97b0862..a21dbe39 100644 --- a/gen/definitions/generic/color_list_policy_object.yaml +++ b/gen/definitions/generic/color_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: color - model_name: name tf_name: name diff --git a/gen/definitions/generic/custom_control_topology_policy_definition.yaml b/gen/definitions/generic/custom_control_topology_policy_definition.yaml index a4f92c15..f556604b 100644 --- a/gen/definitions/generic/custom_control_topology_policy_definition.yaml +++ b/gen/definitions/generic/custom_control_topology_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: control - model_name: name tf_name: name diff --git a/gen/definitions/generic/data_ipv4_prefix_list_policy_object.yaml b/gen/definitions/generic/data_ipv4_prefix_list_policy_object.yaml index 73b7b46a..9c167a65 100644 --- a/gen/definitions/generic/data_ipv4_prefix_list_policy_object.yaml +++ b/gen/definitions/generic/data_ipv4_prefix_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: dataPrefix - model_name: name tf_name: name diff --git a/gen/definitions/generic/data_ipv6_prefix_list_policy_object.yaml b/gen/definitions/generic/data_ipv6_prefix_list_policy_object.yaml index 8f2ddfcd..15d6f8c9 100644 --- a/gen/definitions/generic/data_ipv6_prefix_list_policy_object.yaml +++ b/gen/definitions/generic/data_ipv6_prefix_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: dataipv6prefix - model_name: name tf_name: name diff --git a/gen/definitions/generic/device_acl_policy_definition.yaml b/gen/definitions/generic/device_acl_policy_definition.yaml index 3820710f..a6af5824 100644 --- a/gen/definitions/generic/device_acl_policy_definition.yaml +++ b/gen/definitions/generic/device_acl_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Localized Policies attributes: - model_name: type + type: String value: deviceAccessPolicy - model_name: name tf_name: name @@ -54,6 +55,7 @@ attributes: description: Sequence name example: Sequence 10 - model_name: sequenceType + type: String value: deviceaccesspolicy - model_name: baseAction tf_name: base_action diff --git a/gen/definitions/generic/expanded_community_list_policy_object.yaml b/gen/definitions/generic/expanded_community_list_policy_object.yaml index 47fa939a..4b355756 100644 --- a/gen/definitions/generic/expanded_community_list_policy_object.yaml +++ b/gen/definitions/generic/expanded_community_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: expandedCommunity - model_name: name tf_name: name diff --git a/gen/definitions/generic/extended_community_list_policy_object.yaml b/gen/definitions/generic/extended_community_list_policy_object.yaml index 9f0a998f..f09e3756 100644 --- a/gen/definitions/generic/extended_community_list_policy_object.yaml +++ b/gen/definitions/generic/extended_community_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: extCommunity - model_name: name tf_name: name diff --git a/gen/definitions/generic/hub_and_spoke_topology_policy_definition.yaml b/gen/definitions/generic/hub_and_spoke_topology_policy_definition.yaml index 62200911..02673e94 100644 --- a/gen/definitions/generic/hub_and_spoke_topology_policy_definition.yaml +++ b/gen/definitions/generic/hub_and_spoke_topology_policy_definition.yaml @@ -7,6 +7,7 @@ root_element: definition doc_category: Centralized Policies attributes: - model_name: type + type: String value: hubAndSpoke - model_name: name tf_name: name diff --git a/gen/definitions/generic/ipv4_prefix_list_policy_object.yaml b/gen/definitions/generic/ipv4_prefix_list_policy_object.yaml index 90504c67..bab0d231 100644 --- a/gen/definitions/generic/ipv4_prefix_list_policy_object.yaml +++ b/gen/definitions/generic/ipv4_prefix_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: prefix - model_name: name tf_name: name diff --git a/gen/definitions/generic/ipv6_prefix_list_policy_object.yaml b/gen/definitions/generic/ipv6_prefix_list_policy_object.yaml index f5de46af..76acfe27 100644 --- a/gen/definitions/generic/ipv6_prefix_list_policy_object.yaml +++ b/gen/definitions/generic/ipv6_prefix_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: ipv6prefix - model_name: name tf_name: name diff --git a/gen/definitions/generic/localized_policy.yaml b/gen/definitions/generic/localized_policy.yaml index 8b2d28eb..61a49f4a 100644 --- a/gen/definitions/generic/localized_policy.yaml +++ b/gen/definitions/generic/localized_policy.yaml @@ -7,6 +7,7 @@ id_attribute: policyId doc_category: Localized Policies attributes: - model_name: policyType + type: String value: feature - model_name: policyName tf_name: name diff --git a/gen/definitions/generic/mesh_topology_policy_definition.yaml b/gen/definitions/generic/mesh_topology_policy_definition.yaml index 0cb26d27..1f99300c 100644 --- a/gen/definitions/generic/mesh_topology_policy_definition.yaml +++ b/gen/definitions/generic/mesh_topology_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: mesh - model_name: name tf_name: name diff --git a/gen/definitions/generic/mirror_policy_object.yaml b/gen/definitions/generic/mirror_policy_object.yaml index 8f094dda..171ef94a 100644 --- a/gen/definitions/generic/mirror_policy_object.yaml +++ b/gen/definitions/generic/mirror_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: mirror - model_name: name tf_name: name diff --git a/gen/definitions/generic/policer_policy_object.yaml b/gen/definitions/generic/policer_policy_object.yaml index 8305c2d2..01671e5b 100644 --- a/gen/definitions/generic/policer_policy_object.yaml +++ b/gen/definitions/generic/policer_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: policer - model_name: name tf_name: name diff --git a/gen/definitions/generic/preferred_color_group_policy_object.yaml b/gen/definitions/generic/preferred_color_group_policy_object.yaml index 7ffe636b..89990efc 100644 --- a/gen/definitions/generic/preferred_color_group_policy_object.yaml +++ b/gen/definitions/generic/preferred_color_group_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: preferredColorGroup - model_name: name tf_name: name diff --git a/gen/definitions/generic/qos_map_policy_definition.yaml b/gen/definitions/generic/qos_map_policy_definition.yaml index 1f6e5b84..90b985af 100644 --- a/gen/definitions/generic/qos_map_policy_definition.yaml +++ b/gen/definitions/generic/qos_map_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Localized Policies attributes: - model_name: type + type: String value: qosMap - model_name: name tf_name: name diff --git a/gen/definitions/generic/region_list.yaml b/gen/definitions/generic/region_list.yaml index 3c33ee99..e437d675 100644 --- a/gen/definitions/generic/region_list.yaml +++ b/gen/definitions/generic/region_list.yaml @@ -7,6 +7,7 @@ doc_category: Policy Objects exclude_test: true attributes: - model_name: type + type: String value: region - model_name: name tf_name: name diff --git a/gen/definitions/generic/rewrite_rule_policy_definition.yaml b/gen/definitions/generic/rewrite_rule_policy_definition.yaml index c67c6214..0754069f 100644 --- a/gen/definitions/generic/rewrite_rule_policy_definition.yaml +++ b/gen/definitions/generic/rewrite_rule_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Localized Policies attributes: - model_name: type + type: String value: rewriteRule - model_name: name tf_name: name diff --git a/gen/definitions/generic/route_policy_definition.yaml b/gen/definitions/generic/route_policy_definition.yaml index c2736c4c..327c4d0a 100644 --- a/gen/definitions/generic/route_policy_definition.yaml +++ b/gen/definitions/generic/route_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Localized Policies attributes: - model_name: type + type: String value: vedgeRoute - model_name: name tf_name: name @@ -53,6 +54,7 @@ attributes: description: Sequence name example: Sequence 10 - model_name: sequenceType + type: String value: vedgeRoute - model_name: baseAction tf_name: base_action @@ -245,6 +247,7 @@ attributes: exclude_test: true - model_name: type data_path: [actions.0] + type: String value: set - model_name: parameter data_path: [actions.0] diff --git a/gen/definitions/generic/site_list_policy_object.yaml b/gen/definitions/generic/site_list_policy_object.yaml index 37a63be4..d3ee8dbd 100644 --- a/gen/definitions/generic/site_list_policy_object.yaml +++ b/gen/definitions/generic/site_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: site - model_name: name tf_name: name diff --git a/gen/definitions/generic/sla_class_policy_object.yaml b/gen/definitions/generic/sla_class_policy_object.yaml index 6492d2b1..20c08b24 100644 --- a/gen/definitions/generic/sla_class_policy_object.yaml +++ b/gen/definitions/generic/sla_class_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: sla - model_name: name tf_name: name diff --git a/gen/definitions/generic/standard_community_list_policy_object.yaml b/gen/definitions/generic/standard_community_list_policy_object.yaml index dfeeac24..36f0e73d 100644 --- a/gen/definitions/generic/standard_community_list_policy_object.yaml +++ b/gen/definitions/generic/standard_community_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: community - model_name: name tf_name: name diff --git a/gen/definitions/generic/tloc_list_policy_object.yaml b/gen/definitions/generic/tloc_list_policy_object.yaml index 808a7dc6..3e574af7 100644 --- a/gen/definitions/generic/tloc_list_policy_object.yaml +++ b/gen/definitions/generic/tloc_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: tloc - model_name: name tf_name: name diff --git a/gen/definitions/generic/traffic_data_policy_definition.yaml b/gen/definitions/generic/traffic_data_policy_definition.yaml index 2be9a928..6a22ff11 100644 --- a/gen/definitions/generic/traffic_data_policy_definition.yaml +++ b/gen/definitions/generic/traffic_data_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: data - model_name: name tf_name: name diff --git a/gen/definitions/generic/vpn_list_policy_object.yaml b/gen/definitions/generic/vpn_list_policy_object.yaml index 55645ff6..8c7190b9 100644 --- a/gen/definitions/generic/vpn_list_policy_object.yaml +++ b/gen/definitions/generic/vpn_list_policy_object.yaml @@ -6,6 +6,7 @@ id_attribute: listId doc_category: Policy Objects attributes: - model_name: type + type: String value: vpn - model_name: name tf_name: name diff --git a/gen/definitions/generic/vpn_membership_policy_definition.yaml b/gen/definitions/generic/vpn_membership_policy_definition.yaml index 0fdfa33a..1ffe5751 100644 --- a/gen/definitions/generic/vpn_membership_policy_definition.yaml +++ b/gen/definitions/generic/vpn_membership_policy_definition.yaml @@ -6,6 +6,7 @@ id_attribute: definitionId doc_category: Centralized Policies attributes: - model_name: type + type: String value: vpnMembershipGroup - model_name: name tf_name: name diff --git a/gen/templates/generic/model.go b/gen/templates/generic/model.go index 9d08e65e..af0d0926 100644 --- a/gen/templates/generic/model.go +++ b/gen/templates/generic/model.go @@ -144,7 +144,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { body := "" {{- range .Attributes}} {{- if .Value}} - body, _ = sjson.Set(body, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", "{{.Value}}") + body, _ = sjson.Set(body, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) {{- else if not .TfOnly}} {{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}} if !data.{{toGoName .TfName}}.IsNull(){{if ne .ConditionalAttribute.Name ""}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}"{{end}} { @@ -171,7 +171,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemBody := "" {{- range .Attributes}} {{- if .Value}} - itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", "{{.Value}}") + itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) {{- else if not .TfOnly}} {{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}} if !item.{{toGoName .TfName}}.IsNull(){{if ne .ConditionalAttribute.Name ""}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}"{{end}} { @@ -198,7 +198,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemChildBody := "" {{- range .Attributes}} {{- if .Value}} - itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", "{{.Value}}") + itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) {{- else if not .TfOnly}} {{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}} if !childItem.{{toGoName .TfName}}.IsNull(){{if ne .ConditionalAttribute.Name ""}} && childItem.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}"{{end}} { @@ -225,7 +225,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemChildChildBody := "" {{- range .Attributes}} {{- if .Value}} - itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", "{{.Value}}") + itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) {{- else if not .TfOnly}} {{- if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64")}} if !childChildItem.{{toGoName .TfName}}.IsNull(){{if ne .ConditionalAttribute.Name ""}} && childChildItem.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}"{{end}} {