Repository: cloudflare/cloudflare-go
Pull request #1271 (2023-04-21 12:18:34)

certificate_packs: add `Status` field
## Description

This field is essential for automating tasks related to certificate packs. For instance, upon creating a certificate pack, the validation process must be repeatedly initiated until the status transitions to active.

## Has your change been tested?

Explain how the change has been tested and what you ran to confirm your
change affects other parts of the code. Automated tests are generally
expected and changes without tests should explain why they aren't
required.

## Screenshots (if appropriate):

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com) and stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/



Patch:
diff --git a/.changelog/1271.txt b/.changelog/1271.txt
new file mode 100644
index 000000000..1d2f5841c
--- /dev/null
+++ b/.changelog/1271.txt
@@ -0,0 +1,1 @@
+certificate_packs: add Status field to indicate the status of certificate pack
diff --git a/certificate_packs.go b/certificate_packs.go
index cf499de93..802ed5dfe 100644
--- a/certificate_packs.go
+++ b/certificate_packs.go
@@ -38,6 +38,7 @@ type CertificatePack struct {
 	Hosts                []string                     `json:"hosts"`
 	Certificates         []CertificatePackCertificate `json:"certificates"`
 	PrimaryCertificate   string                       `json:"primary_certificate"`
+	Status               string                       `json:"status"`
 	ValidationRecords    []SSLValidationRecord        `json:"validation_records,omitempty"`
 	ValidationErrors     []SSLValidationError         `json:"validation_errors,omitempty"`
 	ValidationMethod     string                       `json:"validation_method"`


Test patch:
diff --git a/certificate_packs_test.go b/certificate_packs_test.go
index 07aece7c0..6dc975824 100644
--- a/certificate_packs_test.go
+++ b/certificate_packs_test.go
@@ -42,6 +42,7 @@ var (
 		ID:                   "3822ff90-ea29-44df-9e55-21300bb9419b",
 		Type:                 "advanced",
 		Hosts:                []string{"example.com", "*.example.com", "www.example.com"},
+		Status:               "initializing",
 		ValidationMethod:     "txt",
 		ValidityDays:         90,
 		CertificateAuthority: "lets_encrypt",
@@ -244,6 +245,7 @@ func TestRestartAdvancedCertificateValidation(t *testing.T) {
 		ID:                   "3822ff90-ea29-44df-9e55-21300bb9419b",
 		Type:                 "advanced",
 		Hosts:                []string{"example.com", "*.example.com", "www.example.com"},
+		Status:               "initializing",
 		ValidityDays:         365,
 		ValidationMethod:     "txt",
 		CertificateAuthority: "lets_encrypt",