Skip to content

Conversation

@jnzr123
Copy link
Contributor

@jnzr123 jnzr123 commented Sep 29, 2025

What this PR does / why we need it:
add postPaid mode to create instance
Which issue this PR fixes:
(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)
fixes #xxx

Special notes for your reviewer:

Release note:


PR Checklist

  • Tests added/passed.
TF_ACC=1 go test "./huaweicloud/services/acceptance/cbh" -v -coverprofile="./huaweicloud/services/acceptance/cbh/cbh_coverage.cov" -coverpkg="./huaweicloud/services/cbh" -run TestAccCBHInstance_basic -timeout 360m -parallel 10
=== RUN   TestAccCBHInstance_basic
=== PAUSE TestAccCBHInstance_basic
=== CONT  TestAccCBHInstance_basic
--- PASS: TestAccCBHInstance_basic (2099.39s)
PASS
coverage: 22.5% of statements in ./huaweicloud/services/cbh
  • Documentation updated.

  • Schema updated.

  • CheckDeleted.

    • a. During query operation (Read Context)
      aa. Resource not found
      >>>>>> Paste the screenshot here <<<<<<

    • b. During delete/disassociate/unbind operation (Delete Context)
      ba. Resource not found
      >>>>>> Paste the screenshot here <<<<<<

@jnzr123 jnzr123 force-pushed the resource_cbh_instance branch 5 times, most recently from f481907 to 8731cfa Compare September 29, 2025 14:08
@jnzr123 jnzr123 force-pushed the resource_cbh_instance branch from 8731cfa to 41f0247 Compare September 29, 2025 14:21
Changing this parameter will create a new resource.

* `period_unit` - (Required, String, ForceNew) Specifies the charging period unit of the instance.
* `period_unit` - (Optional, String, ForceNew) Specifies the charging period unit of the instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the Required description.

"month", "year",
}, false),
Description: `Specifies the charging period unit of the instance.`,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            // The current network environment only supports prepaid CBH. However, the HCSO environment supports CBH with prepaid and postpaid. Hiding postpaid capabilities as internal features.
			"period_unit": {
				Type:     schema.TypeString,
				Optional: true,
				ForceNew: true,
				ValidateFunc: validation.StringInSlice([]string{
					"month", "year",
				}, false),
				Description: utils.SchemaDesc("Specifies the charging period unit of the instance.", utils.SchemaDescInput{Required: true}),
			},

}, false),
Description: `Specifies the charging period unit of the instance.`,
},
"period": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same to field period_unit.

if err != nil {
return diag.Errorf("error creating CBH client: %s", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is poorly readable and is recommended for optimization.

	respBody, err := createCBHInstance(client, d, cfg)
	if err != nil {
		return diag.FromErr(err)
	}

    var instanceID string
   if d.Get("charging_mode").(string) == "prePaid" {
        instanceID, err := waitingPostpaidCBHComplete()
  } else {
        instanceID, err := utils.PathSearch("instance_id", respBody, "").(string)
  }

  d.SetId(instanceID)
  if err := waitingForCBHInstanceActive(ctx, client, d, d.Timeout(schema.TimeoutCreate)); err != nil {
		return diag.Errorf("error waiting for CBH instance (%s) creation to active: %s", d.Id(), err)
  }
  

@deer-hang
Copy link
Contributor

No documentation for postpaid CBH was found on the official website, and there is a lack of logical support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants