Skip to content

Commit 1c92269

Browse files
authored
feat(secret-manager): add secret types in create secret request (#1764)
1 parent ee8d2c5 commit 1c92269

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

api/secret/v1alpha1/secret_sdk.go

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,39 @@ func (enum *SecretStatus) UnmarshalJSON(data []byte) error {
145145
return nil
146146
}
147147

148+
type SecretType string
149+
150+
const (
151+
SecretTypeUnknownSecretType = SecretType("unknown_secret_type")
152+
// default type.
153+
SecretTypeOpaque = SecretType("opaque")
154+
// Certificates used by load balancers, the format must be PEM concatenated and contains exactly one PKCS8 private key and the certificate full chain containing all intermediates CA.
155+
SecretTypeNetworkEdgeCertificate = SecretType("network_edge_certificate")
156+
)
157+
158+
func (enum SecretType) String() string {
159+
if enum == "" {
160+
// return default value if empty
161+
return "unknown_secret_type"
162+
}
163+
return string(enum)
164+
}
165+
166+
func (enum SecretType) MarshalJSON() ([]byte, error) {
167+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
168+
}
169+
170+
func (enum *SecretType) UnmarshalJSON(data []byte) error {
171+
tmp := ""
172+
173+
if err := json.Unmarshal(data, &tmp); err != nil {
174+
return err
175+
}
176+
177+
*enum = SecretType(SecretType(tmp).String())
178+
return nil
179+
}
180+
148181
type SecretVersionStatus string
149182

150183
const (
@@ -252,8 +285,12 @@ type Secret struct {
252285
VersionCount uint32 `json:"version_count"`
253286
// Description: updated description of the secret.
254287
Description *string `json:"description"`
255-
// IsManaged: true for secrets that are managed by another product.
288+
// IsManaged: returns `true` for secrets that are managed by another product.
256289
IsManaged bool `json:"is_managed"`
290+
// Type: type of the secret.
291+
// See `Secret.Type` enum for description of values.
292+
// Default value: unknown_secret_type
293+
Type SecretType `json:"type"`
257294
// Region: region of the secret.
258295
Region scw.Region `json:"region"`
259296
}
@@ -300,6 +337,10 @@ type CreateSecretRequest struct {
300337
Tags []string `json:"tags"`
301338
// Description: description of the secret.
302339
Description *string `json:"description"`
340+
// Type: type of the secret.
341+
// (Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`.
342+
// Default value: unknown_secret_type
343+
Type SecretType `json:"type"`
303344
}
304345

305346
// CreateSecret: create a secret.
@@ -588,9 +629,10 @@ type AddSecretOwnerRequest struct {
588629
Region scw.Region `json:"-"`
589630
// SecretID: ID of the secret.
590631
SecretID string `json:"-"`
591-
// Deprecated: ProductName: (Deprecated: use product field) ID of the product to add (see product enum).
632+
// Deprecated: ProductName: (Deprecated: use `product` field) Name of the product to add.
592633
ProductName *string `json:"product_name,omitempty"`
593-
// Product: ID of the product to add (see product enum).
634+
// Product: ID of the product to add.
635+
// See `Product` enum for description of values.
594636
// Default value: unknown
595637
Product Product `json:"product"`
596638
}

0 commit comments

Comments
 (0)