Skip to content

Commit 5437e41

Browse files
authored
add auto_proetction_group_id (#6607)
* add auto_proetction_group_id * update code * update doc
1 parent 8d8fdca commit 5437e41

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ibm/service/backuprecovery/resource_ibm_backup_recovery_source_registration.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,11 @@ func ResourceIbmBackupRecoverySourceRegistration() *schema.Resource {
418418
},
419419
},
420420
},
421+
"auto_proetction_group_id": &schema.Schema{
422+
Type: schema.TypeString,
423+
Computed: true,
424+
Description: "The user specified name for this source.",
425+
},
421426
"source_id": &schema.Schema{
422427
Type: schema.TypeInt,
423428
Computed: true,
@@ -1441,6 +1446,16 @@ func resourceIbmBackupRecoverySourceRegistrationCreate(context context.Context,
14411446

14421447
registrationId := fmt.Sprintf("%s::%s", tenantId, strconv.Itoa(int(*sourceRegistrationReponseParams.ID)))
14431448
d.SetId(registrationId)
1449+
1450+
if sourceRegistrationReponseParams.KubernetesParams != nil && sourceRegistrationReponseParams.KubernetesParams.AutoProtectConfig != nil && sourceRegistrationReponseParams.KubernetesParams.AutoProtectConfig.ProtectionGroupID != nil {
1451+
1452+
err := d.Set("auto_proetction_group_id", *sourceRegistrationReponseParams.KubernetesParams.AutoProtectConfig.ProtectionGroupID)
1453+
if err != nil {
1454+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("RegisterProtectionSourceWithContext failed: %s", err.Error()), "ibm_backup_recovery_source_registration", "create")
1455+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
1456+
return tfErr.GetDiag()
1457+
}
1458+
}
14441459
return resourceIbmBackupRecoverySourceRegistrationRead(context, d, meta)
14451460
}
14461461

@@ -1584,6 +1599,11 @@ func resourceIbmBackupRecoverySourceRegistrationRead(context context.Context, d
15841599
}
15851600
}
15861601
if !core.IsNil(sourceRegistrationReponseParams.KubernetesParams) {
1602+
group_id, ok := d.GetOk("auto_proetction_group_id")
1603+
if ok && group_id.(string) != "" {
1604+
autoProetctionGroupId := group_id.(string)
1605+
sourceRegistrationReponseParams.KubernetesParams.AutoProtectConfig.ProtectionGroupID = &autoProetctionGroupId
1606+
}
15871607
kubernetesParamsMap, err := ResourceIbmBackupRecoverySourceRegistrationKubernetesSourceRegistrationParamsToMap(sourceRegistrationReponseParams.KubernetesParams)
15881608
if err != nil {
15891609
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_backup_recovery_source_registration", "read", "kubernetes_params-to-map").GetDiag()

website/docs/r/backup_recovery_source_registration.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ Nested schema for **external_metadata**:
216216
* `last_refreshed_time_msecs` - (Integer) Specifies the time when the source was last refreshed in milliseconds.
217217
* `registration_time_msecs` - (Integer) Specifies the time when the source was registered in milliseconds.
218218
* `source_id` - (Integer) ID of top level source object discovered after the registration.
219+
* `auto_proetction_group_id` - (String) Id of the protection group created using auto protect config
219220
* `source_info` - (List) Specifies information about an object.
220221
Nested schema for **source_info**:
221222
* `child_objects` - (List) Specifies child object details.

0 commit comments

Comments
 (0)