Skip to content

Commit 5fcf078

Browse files
feat: Add functional_type, registration_type and extended_metadata to the apphub service and workload (#15692) (hashicorp#11062)
[upstream:e0e861e3e04ee006cec761377fa04336380da28d] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent f7222c5 commit 5fcf078

File tree

7 files changed

+362
-0
lines changed

7 files changed

+362
-0
lines changed

.changelog/15692.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
apphub: added `functional_type`, `registration_type`, and `extended_metadata` fields to `google_apphub_service` and `google_apphub_workload` resources
3+
```

google-beta/services/apphub/resource_apphub_service.go

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,53 @@ func ResourceApphubService() *schema.Resource {
259259
Description: `Properties of an underlying cloud resource that can comprise a Service.`,
260260
Elem: &schema.Resource{
261261
Schema: map[string]*schema.Schema{
262+
"extended_metadata": {
263+
Type: schema.TypeList,
264+
Computed: true,
265+
Description: `Output only. Additional metadata specific to the resource type.`,
266+
Elem: &schema.Resource{
267+
Schema: map[string]*schema.Schema{
268+
"key": {
269+
Type: schema.TypeString,
270+
Computed: true,
271+
Description: `The key of the extended metadata.`,
272+
},
273+
"value": {
274+
Type: schema.TypeList,
275+
Computed: true,
276+
Description: `The value of the extended metadata.`,
277+
Elem: &schema.Resource{
278+
Schema: map[string]*schema.Schema{
279+
"extended_metadata_schema": {
280+
Type: schema.TypeString,
281+
Computed: true,
282+
Description: `The resource name for the Extended Metadata Schema.`,
283+
},
284+
"metadata_struct": {
285+
Type: schema.TypeString,
286+
Computed: true,
287+
Description: `The metadata contents as a JSON string.`,
288+
},
289+
},
290+
},
291+
},
292+
},
293+
},
294+
},
295+
"functional_type": {
296+
Type: schema.TypeList,
297+
Computed: true,
298+
Description: `Output only. The type of the service.`,
299+
Elem: &schema.Resource{
300+
Schema: map[string]*schema.Schema{
301+
"type": {
302+
Type: schema.TypeString,
303+
Computed: true,
304+
Description: `Output only. The functional type of a service or workload.`,
305+
},
306+
},
307+
},
308+
},
262309
"gcp_project": {
263310
Type: schema.TypeString,
264311
Computed: true,
@@ -269,6 +316,20 @@ func ResourceApphubService() *schema.Resource {
269316
Computed: true,
270317
Description: `Output only. The location that the underlying resource resides in, for example, us-west1.`,
271318
},
319+
"registration_type": {
320+
Type: schema.TypeList,
321+
Computed: true,
322+
Description: `Output only. The registration type of the service.`,
323+
Elem: &schema.Resource{
324+
Schema: map[string]*schema.Schema{
325+
"type": {
326+
Type: schema.TypeString,
327+
Computed: true,
328+
Description: `Output only. The registration type of a service.`,
329+
},
330+
},
331+
},
332+
},
272333
"zone": {
273334
Type: schema.TypeString,
274335
Computed: true,
@@ -705,6 +766,12 @@ func flattenApphubServiceServiceProperties(v interface{}, d *schema.ResourceData
705766
flattenApphubServiceServicePropertiesLocation(original["location"], d, config)
706767
transformed["zone"] =
707768
flattenApphubServiceServicePropertiesZone(original["zone"], d, config)
769+
transformed["functional_type"] =
770+
flattenApphubServiceServicePropertiesFunctionalType(original["functionalType"], d, config)
771+
transformed["registration_type"] =
772+
flattenApphubServiceServicePropertiesRegistrationType(original["registrationType"], d, config)
773+
transformed["extended_metadata"] =
774+
flattenApphubServiceServicePropertiesExtendedMetadata(original["extendedMetadata"], d, config)
708775
return []interface{}{transformed}
709776
}
710777
func flattenApphubServiceServicePropertiesGcpProject(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -719,6 +786,86 @@ func flattenApphubServiceServicePropertiesZone(v interface{}, d *schema.Resource
719786
return v
720787
}
721788

789+
func flattenApphubServiceServicePropertiesFunctionalType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
790+
if v == nil {
791+
return nil
792+
}
793+
original := v.(map[string]interface{})
794+
if len(original) == 0 {
795+
return nil
796+
}
797+
transformed := make(map[string]interface{})
798+
transformed["type"] =
799+
flattenApphubServiceServicePropertiesFunctionalTypeType(original["type"], d, config)
800+
return []interface{}{transformed}
801+
}
802+
func flattenApphubServiceServicePropertiesFunctionalTypeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
803+
return v
804+
}
805+
806+
func flattenApphubServiceServicePropertiesRegistrationType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
807+
if v == nil {
808+
return nil
809+
}
810+
original := v.(map[string]interface{})
811+
if len(original) == 0 {
812+
return nil
813+
}
814+
transformed := make(map[string]interface{})
815+
transformed["type"] =
816+
flattenApphubServiceServicePropertiesRegistrationTypeType(original["type"], d, config)
817+
return []interface{}{transformed}
818+
}
819+
func flattenApphubServiceServicePropertiesRegistrationTypeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
820+
return v
821+
}
822+
823+
func flattenApphubServiceServicePropertiesExtendedMetadata(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
824+
if v == nil {
825+
return v
826+
}
827+
l := v.([]interface{})
828+
transformed := make([]interface{}, 0, len(l))
829+
for _, raw := range l {
830+
original := raw.(map[string]interface{})
831+
if len(original) < 1 {
832+
// Do not include empty json objects coming back from the api
833+
continue
834+
}
835+
transformed = append(transformed, map[string]interface{}{
836+
"key": flattenApphubServiceServicePropertiesExtendedMetadataKey(original["key"], d, config),
837+
"value": flattenApphubServiceServicePropertiesExtendedMetadataValue(original["value"], d, config),
838+
})
839+
}
840+
return transformed
841+
}
842+
func flattenApphubServiceServicePropertiesExtendedMetadataKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
843+
return v
844+
}
845+
846+
func flattenApphubServiceServicePropertiesExtendedMetadataValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
847+
if v == nil {
848+
return nil
849+
}
850+
original := v.(map[string]interface{})
851+
if len(original) == 0 {
852+
return nil
853+
}
854+
transformed := make(map[string]interface{})
855+
transformed["metadata_struct"] =
856+
flattenApphubServiceServicePropertiesExtendedMetadataValueMetadataStruct(original["metadataStruct"], d, config)
857+
transformed["extended_metadata_schema"] =
858+
flattenApphubServiceServicePropertiesExtendedMetadataValueExtendedMetadataSchema(original["extendedMetadataSchema"], d, config)
859+
return []interface{}{transformed}
860+
}
861+
func flattenApphubServiceServicePropertiesExtendedMetadataValueMetadataStruct(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
862+
return v
863+
}
864+
865+
func flattenApphubServiceServicePropertiesExtendedMetadataValueExtendedMetadataSchema(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
866+
return v
867+
}
868+
722869
func flattenApphubServiceAttributes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
723870
if v == nil {
724871
return nil

google-beta/services/apphub/resource_apphub_service_generated_meta.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ fields:
2727
- api_field: 'name'
2828
- field: 'service_id'
2929
provider_only: true
30+
- api_field: 'serviceProperties.extendedMetadata.key'
31+
- api_field: 'serviceProperties.extendedMetadata.value.extendedMetadataSchema'
32+
- api_field: 'serviceProperties.extendedMetadata.value.metadataStruct'
33+
- api_field: 'serviceProperties.functionalType.type'
3034
- api_field: 'serviceProperties.gcpProject'
3135
- api_field: 'serviceProperties.location'
36+
- api_field: 'serviceProperties.registrationType.type'
3237
- api_field: 'serviceProperties.zone'
3338
- api_field: 'serviceReference.uri'
3439
- api_field: 'state'

google-beta/services/apphub/resource_apphub_workload.go

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,53 @@ func ResourceApphubWorkload() *schema.Resource {
273273
Description: `Properties of an underlying compute resource represented by the Workload.`,
274274
Elem: &schema.Resource{
275275
Schema: map[string]*schema.Schema{
276+
"extended_metadata": {
277+
Type: schema.TypeList,
278+
Computed: true,
279+
Description: `Output only. Additional metadata specific to the resource type.`,
280+
Elem: &schema.Resource{
281+
Schema: map[string]*schema.Schema{
282+
"key": {
283+
Type: schema.TypeString,
284+
Computed: true,
285+
Description: `The key of the extended metadata.`,
286+
},
287+
"value": {
288+
Type: schema.TypeList,
289+
Computed: true,
290+
Description: `The value of the extended metadata.`,
291+
Elem: &schema.Resource{
292+
Schema: map[string]*schema.Schema{
293+
"extended_metadata_schema": {
294+
Type: schema.TypeString,
295+
Computed: true,
296+
Description: `The resource name for the Extended Metadata Schema.`,
297+
},
298+
"metadata_struct": {
299+
Type: schema.TypeString,
300+
Computed: true,
301+
Description: `The metadata contents as a JSON string.`,
302+
},
303+
},
304+
},
305+
},
306+
},
307+
},
308+
},
309+
"functional_type": {
310+
Type: schema.TypeList,
311+
Computed: true,
312+
Description: `Output only. The functional type of a service or workload.`,
313+
Elem: &schema.Resource{
314+
Schema: map[string]*schema.Schema{
315+
"type": {
316+
Type: schema.TypeString,
317+
Computed: true,
318+
Description: `Output only. The functional type of a service or workload.`,
319+
},
320+
},
321+
},
322+
},
276323
"gcp_project": {
277324
Type: schema.TypeString,
278325
Computed: true,
@@ -702,6 +749,10 @@ func flattenApphubWorkloadWorkloadProperties(v interface{}, d *schema.ResourceDa
702749
flattenApphubWorkloadWorkloadPropertiesLocation(original["location"], d, config)
703750
transformed["zone"] =
704751
flattenApphubWorkloadWorkloadPropertiesZone(original["zone"], d, config)
752+
transformed["functional_type"] =
753+
flattenApphubWorkloadWorkloadPropertiesFunctionalType(original["functionalType"], d, config)
754+
transformed["extended_metadata"] =
755+
flattenApphubWorkloadWorkloadPropertiesExtendedMetadata(original["extendedMetadata"], d, config)
705756
return []interface{}{transformed}
706757
}
707758
func flattenApphubWorkloadWorkloadPropertiesGcpProject(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -716,6 +767,69 @@ func flattenApphubWorkloadWorkloadPropertiesZone(v interface{}, d *schema.Resour
716767
return v
717768
}
718769

770+
func flattenApphubWorkloadWorkloadPropertiesFunctionalType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
771+
if v == nil {
772+
return nil
773+
}
774+
original := v.(map[string]interface{})
775+
if len(original) == 0 {
776+
return nil
777+
}
778+
transformed := make(map[string]interface{})
779+
transformed["type"] =
780+
flattenApphubWorkloadWorkloadPropertiesFunctionalTypeType(original["type"], d, config)
781+
return []interface{}{transformed}
782+
}
783+
func flattenApphubWorkloadWorkloadPropertiesFunctionalTypeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
784+
return v
785+
}
786+
787+
func flattenApphubWorkloadWorkloadPropertiesExtendedMetadata(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
788+
if v == nil {
789+
return v
790+
}
791+
l := v.([]interface{})
792+
transformed := make([]interface{}, 0, len(l))
793+
for _, raw := range l {
794+
original := raw.(map[string]interface{})
795+
if len(original) < 1 {
796+
// Do not include empty json objects coming back from the api
797+
continue
798+
}
799+
transformed = append(transformed, map[string]interface{}{
800+
"key": flattenApphubWorkloadWorkloadPropertiesExtendedMetadataKey(original["key"], d, config),
801+
"value": flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValue(original["value"], d, config),
802+
})
803+
}
804+
return transformed
805+
}
806+
func flattenApphubWorkloadWorkloadPropertiesExtendedMetadataKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
807+
return v
808+
}
809+
810+
func flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
811+
if v == nil {
812+
return nil
813+
}
814+
original := v.(map[string]interface{})
815+
if len(original) == 0 {
816+
return nil
817+
}
818+
transformed := make(map[string]interface{})
819+
transformed["metadata_struct"] =
820+
flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValueMetadataStruct(original["metadataStruct"], d, config)
821+
transformed["extended_metadata_schema"] =
822+
flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValueExtendedMetadataSchema(original["extendedMetadataSchema"], d, config)
823+
return []interface{}{transformed}
824+
}
825+
func flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValueMetadataStruct(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
826+
return v
827+
}
828+
829+
func flattenApphubWorkloadWorkloadPropertiesExtendedMetadataValueExtendedMetadataSchema(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
830+
return v
831+
}
832+
719833
func flattenApphubWorkloadDiscoveredWorkload(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
720834
return v
721835
}

google-beta/services/apphub/resource_apphub_workload_generated_meta.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ fields:
3030
- api_field: 'updateTime'
3131
- field: 'workload_id'
3232
provider_only: true
33+
- api_field: 'workloadProperties.extendedMetadata.key'
34+
- api_field: 'workloadProperties.extendedMetadata.value.extendedMetadataSchema'
35+
- api_field: 'workloadProperties.extendedMetadata.value.metadataStruct'
36+
- api_field: 'workloadProperties.functionalType.type'
3337
- api_field: 'workloadProperties.gcpProject'
3438
- api_field: 'workloadProperties.location'
3539
- api_field: 'workloadProperties.zone'

website/docs/r/apphub_service.html.markdown

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,56 @@ In addition to the arguments listed above, the following computed attributes are
441441
(Output)
442442
Output only. The location that the underlying resource resides in if it is zonal, for example, us-west1-a).
443443

444+
* `functional_type` -
445+
(Output)
446+
Output only. The type of the service.
447+
Structure is [documented below](#nested_service_properties_functional_type).
448+
449+
* `registration_type` -
450+
(Output)
451+
Output only. The registration type of the service.
452+
Structure is [documented below](#nested_service_properties_registration_type).
453+
454+
* `extended_metadata` -
455+
(Output)
456+
Output only. Additional metadata specific to the resource type.
457+
Structure is [documented below](#nested_service_properties_extended_metadata).
458+
459+
460+
<a name="nested_service_properties_functional_type"></a>The `functional_type` block contains:
461+
462+
* `type` -
463+
(Output)
464+
Output only. The functional type of a service or workload.
465+
466+
<a name="nested_service_properties_registration_type"></a>The `registration_type` block contains:
467+
468+
* `type` -
469+
(Output)
470+
Output only. The registration type of a service.
471+
472+
<a name="nested_service_properties_extended_metadata"></a>The `extended_metadata` block contains:
473+
474+
* `key` -
475+
(Output)
476+
The key of the extended metadata.
477+
478+
* `value` -
479+
(Output)
480+
The value of the extended metadata.
481+
Structure is [documented below](#nested_service_properties_extended_metadata_extended_metadata_value).
482+
483+
484+
<a name="nested_service_properties_extended_metadata_extended_metadata_value"></a>The `value` block contains:
485+
486+
* `metadata_struct` -
487+
(Output)
488+
The metadata contents as a JSON string.
489+
490+
* `extended_metadata_schema` -
491+
(Output)
492+
The resource name for the Extended Metadata Schema.
493+
444494
## Timeouts
445495

446496
This resource provides the following

0 commit comments

Comments
 (0)