diff --git a/sdk/security/keyvault/azcertificates/CHANGELOG.md b/sdk/security/keyvault/azcertificates/CHANGELOG.md index c2bfec9f6798..abe59e73efcf 100644 --- a/sdk/security/keyvault/azcertificates/CHANGELOG.md +++ b/sdk/security/keyvault/azcertificates/CHANGELOG.md @@ -1,14 +1,12 @@ # Release History -## 1.5.0-beta.2 (Unreleased) - +## 1.5.0-beta.2 (2026-05-18) ### Features Added -### Breaking Changes - -### Bugs Fixed +- New struct `PlatformManaged` +- New field `PlatformManaged` in struct `CertificatePolicy` +- New function `NewPlatformManaged` -### Other Changes ## 1.5.0-beta.1 (2026-04-08) diff --git a/sdk/security/keyvault/azcertificates/assets.json b/sdk/security/keyvault/azcertificates/assets.json index bcd8e4fa3fa5..e429b2240cbd 100644 --- a/sdk/security/keyvault/azcertificates/assets.json +++ b/sdk/security/keyvault/azcertificates/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/security/keyvault/azcertificates", - "Tag": "go/security/keyvault/azcertificates_6fa8ef386c" + "Tag": "go/security/keyvault/azcertificates_fa9d1951e5" } diff --git a/sdk/security/keyvault/azcertificates/client.go b/sdk/security/keyvault/azcertificates/client.go index 2e51d2cdd7d0..ac13b13c2a5f 100644 --- a/sdk/security/keyvault/azcertificates/client.go +++ b/sdk/security/keyvault/azcertificates/client.go @@ -18,6 +18,8 @@ import ( // Client - The key vault client performs cryptographic key operations and vault operations against the Key Vault service. // Don't use this type directly, use a constructor function instead. +// +// Generated from API version 2026-03-01-preview type Client struct { internal *azcore.Client vaultBaseUrl string @@ -28,8 +30,6 @@ type Client struct { // Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be // downloaded. This operation requires the certificates/backup permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - options - BackupCertificateOptions contains the optional parameters for the Client.BackupCertificate method. func (client *Client) BackupCertificate(ctx context.Context, name string, options *BackupCertificateOptions) (BackupCertificateResponse, error) { @@ -66,8 +66,8 @@ func (client *Client) backupCertificateCreateRequest(ctx context.Context, name s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -85,8 +85,6 @@ func (client *Client) backupCertificateHandleResponse(resp *http.Response) (Back // // If this is the first version, the certificate resource is created. This operation requires the certificates/create permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. The value you provide may be copied globally for the purpose of running the service. // The value provided should not include personally identifiable or sensitive information. // - parameters - The parameters to create a certificate. @@ -125,8 +123,8 @@ func (client *Client) createCertificateCreateRequest(ctx context.Context, name s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -149,8 +147,6 @@ func (client *Client) createCertificateHandleResponse(resp *http.Response) (Crea // Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used to remove // individual versions of a certificate object. This operation requires the certificates/delete permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - options - DeleteCertificateOptions contains the optional parameters for the Client.DeleteCertificate method. func (client *Client) DeleteCertificate(ctx context.Context, name string, options *DeleteCertificateOptions) (DeleteCertificateResponse, error) { @@ -187,8 +183,8 @@ func (client *Client) deleteCertificateCreateRequest(ctx context.Context, name s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -207,8 +203,6 @@ func (client *Client) deleteCertificateHandleResponse(resp *http.Response) (Dele // Deletes the creation operation for a specified certificate that is in the process of being created. The certificate is // no longer created. This operation requires the certificates/update permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - options - DeleteCertificateOperationOptions contains the optional parameters for the Client.DeleteCertificateOperation // method. @@ -246,8 +240,8 @@ func (client *Client) deleteCertificateOperationCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -266,8 +260,6 @@ func (client *Client) deleteCertificateOperationHandleResponse(resp *http.Respon // Deletes the certificate contacts for a specified key vault certificate. This operation requires the certificates/managecontacts // permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - options - DeleteContactsOptions contains the optional parameters for the Client.DeleteContacts method. func (client *Client) DeleteContacts(ctx context.Context, options *DeleteContactsOptions) (DeleteContactsResponse, error) { var err error @@ -299,8 +291,8 @@ func (client *Client) deleteContactsCreateRequest(ctx context.Context, _ *Delete return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -319,8 +311,6 @@ func (client *Client) deleteContactsHandleResponse(resp *http.Response) (DeleteC // The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This operation // requires the certificates/manageissuers/deleteissuers permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the issuer. // - options - DeleteIssuerOptions contains the optional parameters for the Client.DeleteIssuer method. func (client *Client) DeleteIssuer(ctx context.Context, name string, options *DeleteIssuerOptions) (DeleteIssuerResponse, error) { @@ -357,8 +347,8 @@ func (client *Client) deleteIssuerCreateRequest(ctx context.Context, name string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -376,8 +366,6 @@ func (client *Client) deleteIssuerHandleResponse(resp *http.Response) (DeleteIss // // Gets information about a specific certificate. This operation requires the certificates/get permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate in the given vault. // - version - The version of the certificate. This URI fragment is optional. If not specified, the latest version of the certificate // is returned. @@ -417,8 +405,8 @@ func (client *Client) getCertificateCreateRequest(ctx context.Context, name stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -436,8 +424,6 @@ func (client *Client) getCertificateHandleResponse(resp *http.Response) (GetCert // // Gets the creation operation associated with a specified certificate. This operation requires the certificates/get permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - options - GetCertificateOperationOptions contains the optional parameters for the Client.GetCertificateOperation method. func (client *Client) GetCertificateOperation(ctx context.Context, name string, options *GetCertificateOperationOptions) (GetCertificateOperationResponse, error) { @@ -474,8 +460,8 @@ func (client *Client) getCertificateOperationCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -494,8 +480,6 @@ func (client *Client) getCertificateOperationHandleResponse(resp *http.Response) // The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. This // operation requires the certificates/get permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate in a given key vault. // - options - GetCertificatePolicyOptions contains the optional parameters for the Client.GetCertificatePolicy method. func (client *Client) GetCertificatePolicy(ctx context.Context, name string, options *GetCertificatePolicyOptions) (GetCertificatePolicyResponse, error) { @@ -532,8 +516,8 @@ func (client *Client) getCertificatePolicyCreateRequest(ctx context.Context, nam return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -552,8 +536,6 @@ func (client *Client) getCertificatePolicyHandleResponse(resp *http.Response) (G // The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. This // operation requires the certificates/managecontacts permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - options - GetContactsOptions contains the optional parameters for the Client.GetContacts method. func (client *Client) GetContacts(ctx context.Context, options *GetContactsOptions) (GetContactsResponse, error) { var err error @@ -585,8 +567,8 @@ func (client *Client) getContactsCreateRequest(ctx context.Context, _ *GetContac return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -606,8 +588,6 @@ func (client *Client) getContactsHandleResponse(resp *http.Response) (GetContact // interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the certificates/get // permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate // - options - GetDeletedCertificateOptions contains the optional parameters for the Client.GetDeletedCertificate method. func (client *Client) GetDeletedCertificate(ctx context.Context, name string, options *GetDeletedCertificateOptions) (GetDeletedCertificateResponse, error) { @@ -644,8 +624,8 @@ func (client *Client) getDeletedCertificateCreateRequest(ctx context.Context, na return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -664,8 +644,6 @@ func (client *Client) getDeletedCertificateHandleResponse(resp *http.Response) ( // The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. This // operation requires the certificates/manageissuers/getissuers permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the issuer. // - options - GetIssuerOptions contains the optional parameters for the Client.GetIssuer method. func (client *Client) GetIssuer(ctx context.Context, name string, options *GetIssuerOptions) (GetIssuerResponse, error) { @@ -702,8 +680,8 @@ func (client *Client) getIssuerCreateRequest(ctx context.Context, name string, _ return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -723,8 +701,6 @@ func (client *Client) getIssuerHandleResponse(resp *http.Response) (GetIssuerRes // permission. The certificate to be imported can be in either PFX or PEM format. If the certificate is in PEM format the // PEM file must contain the key as well as x509 certificates. Key Vault will only accept a key in PKCS#8 format. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. The value you provide may be copied globally for the purpose of running the service. // The value provided should not include personally identifiable or sensitive information. // - parameters - The parameters to import the certificate. @@ -763,8 +739,8 @@ func (client *Client) importCertificateCreateRequest(ctx context.Context, name s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -786,8 +762,6 @@ func (client *Client) importCertificateHandleResponse(resp *http.Response) (Impo // // The GetCertificates operation returns the set of certificates resources in the specified key vault. This operation requires // the certificates/list permission. -// -// Generated from API version 2025-07-01 // - options - ListCertificatePropertiesOptions contains the optional parameters for the Client.NewListCertificatePropertiesPager // method. func (client *Client) NewListCertificatePropertiesPager(options *ListCertificatePropertiesOptions) *runtime.Pager[ListCertificatePropertiesResponse] { @@ -821,11 +795,11 @@ func (client *Client) listCertificatePropertiesCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") + reqQP.Set("api-version", version20260301Preview) if options != nil && options.IncludePending != nil { reqQP.Set("includePending", strconv.FormatBool(*options.IncludePending)) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -843,8 +817,6 @@ func (client *Client) listCertificatePropertiesHandleResponse(resp *http.Respons // // The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This operation requires // the certificates/list permission. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - options - ListCertificatePropertiesVersionsOptions contains the optional parameters for the Client.NewListCertificatePropertiesVersionsPager // method. @@ -883,8 +855,8 @@ func (client *Client) listCertificatePropertiesVersionsCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -904,8 +876,6 @@ func (client *Client) listCertificatePropertiesVersionsHandleResponse(resp *http // The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state and ready // for recovery or purging. This operation includes deletion-specific information. This operation requires the certificates/get/list // permission. This operation can only be enabled on soft-delete enabled vaults. -// -// Generated from API version 2025-07-01 // - options - ListDeletedCertificatePropertiesOptions contains the optional parameters for the Client.NewListDeletedCertificatePropertiesPager // method. func (client *Client) NewListDeletedCertificatePropertiesPager(options *ListDeletedCertificatePropertiesOptions) *runtime.Pager[ListDeletedCertificatePropertiesResponse] { @@ -939,11 +909,11 @@ func (client *Client) listDeletedCertificatePropertiesCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") + reqQP.Set("api-version", version20260301Preview) if options != nil && options.IncludePending != nil { reqQP.Set("includePending", strconv.FormatBool(*options.IncludePending)) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -961,8 +931,6 @@ func (client *Client) listDeletedCertificatePropertiesHandleResponse(resp *http. // // The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. This operation // requires the certificates/manageissuers/getissuers permission. -// -// Generated from API version 2025-07-01 // - options - ListIssuerPropertiesOptions contains the optional parameters for the Client.NewListIssuerPropertiesPager method. func (client *Client) NewListIssuerPropertiesPager(options *ListIssuerPropertiesOptions) *runtime.Pager[ListIssuerPropertiesResponse] { return runtime.NewPager(runtime.PagingHandler[ListIssuerPropertiesResponse]{ @@ -995,8 +963,8 @@ func (client *Client) listIssuerPropertiesCreateRequest(ctx context.Context, _ * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -1015,8 +983,6 @@ func (client *Client) listIssuerPropertiesHandleResponse(resp *http.Response) (L // The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair currently available // in the service. This operation requires the certificates/create permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - parameters - The parameters to merge certificate. // - options - MergeCertificateOptions contains the optional parameters for the Client.MergeCertificate method. @@ -1054,8 +1020,8 @@ func (client *Client) mergeCertificateCreateRequest(ctx context.Context, name st return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -1079,8 +1045,6 @@ func (client *Client) mergeCertificateHandleResponse(resp *http.Response) (Merge // for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This operation requires // the certificate/purge permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate // - options - PurgeDeletedCertificateOptions contains the optional parameters for the Client.PurgeDeletedCertificate method. func (client *Client) PurgeDeletedCertificate(ctx context.Context, name string, options *PurgeDeletedCertificateOptions) (PurgeDeletedCertificateResponse, error) { @@ -1116,8 +1080,8 @@ func (client *Client) purgeDeletedCertificateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } @@ -1127,8 +1091,6 @@ func (client *Client) purgeDeletedCertificateCreateRequest(ctx context.Context, // enabled for soft-delete, and must be issued during the retention interval (available in the deleted certificate's attributes). // This operation requires the certificates/recover permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the deleted certificate // - options - RecoverDeletedCertificateOptions contains the optional parameters for the Client.RecoverDeletedCertificate method. func (client *Client) RecoverDeletedCertificate(ctx context.Context, name string, options *RecoverDeletedCertificateOptions) (RecoverDeletedCertificateResponse, error) { @@ -1165,8 +1127,8 @@ func (client *Client) recoverDeletedCertificateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -1184,8 +1146,6 @@ func (client *Client) recoverDeletedCertificateHandleResponse(resp *http.Respons // // Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - parameters - The parameters to restore the certificate. // - options - RestoreCertificateOptions contains the optional parameters for the Client.RestoreCertificate method. func (client *Client) RestoreCertificate(ctx context.Context, parameters RestoreCertificateParameters, options *RestoreCertificateOptions) (RestoreCertificateResponse, error) { @@ -1218,8 +1178,8 @@ func (client *Client) restoreCertificateCreateRequest(ctx context.Context, param return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -1241,8 +1201,6 @@ func (client *Client) restoreCertificateHandleResponse(resp *http.Response) (Res // // Sets the certificate contacts for the specified key vault. This operation requires the certificates/managecontacts permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - contacts - The contacts for the key vault certificate. // - options - SetContactsOptions contains the optional parameters for the Client.SetContacts method. func (client *Client) SetContacts(ctx context.Context, contacts Contacts, options *SetContactsOptions) (SetContactsResponse, error) { @@ -1275,8 +1233,8 @@ func (client *Client) setContactsCreateRequest(ctx context.Context, contacts Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, contacts); err != nil { @@ -1299,8 +1257,6 @@ func (client *Client) setContactsHandleResponse(resp *http.Response) (SetContact // The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the certificates/setissuers // permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the issuer. The value you provide may be copied globally for the purpose of running the service. The // value provided should not include personally identifiable or sensitive information. // - parameter - Certificate issuer set parameter. @@ -1339,8 +1295,8 @@ func (client *Client) setIssuerCreateRequest(ctx context.Context, name string, p return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameter); err != nil { @@ -1363,8 +1319,6 @@ func (client *Client) setIssuerHandleResponse(resp *http.Response) (SetIssuerRes // The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated are the // certificate's attributes. This operation requires the certificates/update permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate in the given key vault. // - version - The version of the certificate. // - parameters - The parameters for certificate update. @@ -1404,8 +1358,8 @@ func (client *Client) updateCertificateCreateRequest(ctx context.Context, name s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -1427,8 +1381,6 @@ func (client *Client) updateCertificateHandleResponse(resp *http.Response) (Upda // // Updates a certificate creation operation that is already in progress. This operation requires the certificates/update permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate. // - certificateOperation - The certificate operation response. // - options - UpdateCertificateOperationOptions contains the optional parameters for the Client.UpdateCertificateOperation @@ -1467,8 +1419,8 @@ func (client *Client) updateCertificateOperationCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, certificateOperation); err != nil { @@ -1491,8 +1443,6 @@ func (client *Client) updateCertificateOperationHandleResponse(resp *http.Respon // Set specified members in the certificate policy. Leave others as null. This operation requires the certificates/update // permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the certificate in the given vault. // - certificatePolicy - The policy for the certificate. // - options - UpdateCertificatePolicyOptions contains the optional parameters for the Client.UpdateCertificatePolicy method. @@ -1530,8 +1480,8 @@ func (client *Client) updateCertificatePolicyCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, certificatePolicy); err != nil { @@ -1554,8 +1504,6 @@ func (client *Client) updateCertificatePolicyHandleResponse(resp *http.Response) // The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires // the certificates/setissuers permission. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2025-07-01 // - name - The name of the issuer. // - parameter - Certificate issuer update parameter. // - options - UpdateIssuerOptions contains the optional parameters for the Client.UpdateIssuer method. @@ -1593,8 +1541,8 @@ func (client *Client) updateIssuerCreateRequest(ctx context.Context, name string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2025-07-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20260301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameter); err != nil { diff --git a/sdk/security/keyvault/azcertificates/constants.go b/sdk/security/keyvault/azcertificates/constants.go index bb6c4eb8f94b..ba8d8eeef110 100644 --- a/sdk/security/keyvault/azcertificates/constants.go +++ b/sdk/security/keyvault/azcertificates/constants.go @@ -4,6 +4,10 @@ package azcertificates +const ( + version20260301Preview string = "2026-03-01-preview" +) + // CertificatePolicyAction - The type of the action. type CertificatePolicyAction string diff --git a/sdk/security/keyvault/azcertificates/custom_client.go b/sdk/security/keyvault/azcertificates/custom_client.go index e3f1421f0574..272c3a934626 100644 --- a/sdk/security/keyvault/azcertificates/custom_client.go +++ b/sdk/security/keyvault/azcertificates/custom_client.go @@ -25,6 +25,14 @@ type ClientOptions struct { DisableChallengeResourceVerification bool } +// NewPlatformManaged creates a PlatformManaged certificate policy configuration. +func NewPlatformManaged(certificateUsage string, metadata map[string]any) *PlatformManaged { + return &PlatformManaged{ + CertificateUsage: &certificateUsage, + Metadata: metadata, + } +} + // NewClient creates a client that accesses a Key Vault's certificates. You should validate that // vaultURL references a valid Key Vault. See https://aka.ms/azsdk/blog/vault-uri for details. func NewClient(vaultURL string, credential azcore.TokenCredential, options *ClientOptions) (*Client, error) { diff --git a/sdk/security/keyvault/azcertificates/custom_client_test.go b/sdk/security/keyvault/azcertificates/custom_client_test.go new file mode 100644 index 000000000000..ba7645e8bf49 --- /dev/null +++ b/sdk/security/keyvault/azcertificates/custom_client_test.go @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azcertificates + +import ( + "context" + "encoding/json" + "io" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/stretchr/testify/require" +) + +func TestNewPlatformManaged(t *testing.T) { + metadata := map[string]any{ + "issuer": "internal-ca", + "rotationDays": 90, + } + + pm := NewPlatformManaged("tls-server", metadata) + + require.NotNil(t, pm.CertificateUsage) + require.Equal(t, "tls-server", *pm.CertificateUsage) + require.Equal(t, metadata, pm.Metadata) +} + +func TestNewPlatformManagedNilMetadata(t *testing.T) { + pm := NewPlatformManaged("tls-server", nil) + + require.NotNil(t, pm.CertificateUsage) + require.Equal(t, "tls-server", *pm.CertificateUsage) + require.Nil(t, pm.Metadata) + + data, err := json.Marshal(pm) + require.NoError(t, err) + require.JSONEq(t, `{ + "certificateUsage": "tls-server" + }`, string(data)) +} + +func TestPlatformManagedSerde(t *testing.T) { + policy := CertificatePolicy{ + IssuerParameters: &IssuerParameters{Name: to.Ptr("Self")}, + PlatformManaged: NewPlatformManaged("tls-server", map[string]any{ + "issuer": "internal-ca", + "nested": map[string]any{ + "enabled": true, + }, + "usages": []any{"server", "client"}, + }), + } + + data, err := json.Marshal(policy) + require.NoError(t, err) + require.JSONEq(t, `{ + "issuer": {"name": "Self"}, + "platformManaged": { + "certificateUsage": "tls-server", + "metadata": { + "issuer": "internal-ca", + "nested": {"enabled": true}, + "usages": ["server", "client"] + } + } + }`, string(data)) + + var roundTrip CertificatePolicy + err = json.Unmarshal(data, &roundTrip) + require.NoError(t, err) + require.NotNil(t, roundTrip.PlatformManaged) + require.NotNil(t, roundTrip.PlatformManaged.CertificateUsage) + require.Equal(t, "tls-server", *roundTrip.PlatformManaged.CertificateUsage) + require.Equal(t, "internal-ca", roundTrip.PlatformManaged.Metadata["issuer"]) + require.Equal(t, map[string]any{"enabled": true}, roundTrip.PlatformManaged.Metadata["nested"]) + require.Equal(t, []any{"server", "client"}, roundTrip.PlatformManaged.Metadata["usages"]) +} + +func TestCreateCertificateRequestIncludesPlatformManaged(t *testing.T) { + client := &Client{vaultBaseUrl: "https://fakevault.vault.azure.net"} + parameters := CreateCertificateParameters{ + CertificatePolicy: &CertificatePolicy{ + IssuerParameters: &IssuerParameters{Name: to.Ptr("Self")}, + PlatformManaged: NewPlatformManaged("tls-server", map[string]any{ + "issuer": "internal-ca", + "rotationDays": 90, + }), + }, + } + + req, err := client.createCertificateCreateRequest(context.Background(), "cert-name", parameters, nil) + require.NoError(t, err) + require.Equal(t, version20260301Preview, req.Raw().URL.Query().Get("api-version")) + + body, err := io.ReadAll(req.Raw().Body) + require.NoError(t, err) + require.JSONEq(t, `{ + "policy": { + "issuer": {"name": "Self"}, + "platformManaged": { + "certificateUsage": "tls-server", + "metadata": { + "issuer": "internal-ca", + "rotationDays": 90 + } + } + } + }`, string(body)) +} + +func TestUpdateCertificatePolicyRequestIncludesPlatformManaged(t *testing.T) { + client := &Client{vaultBaseUrl: "https://fakevault.vault.azure.net"} + policy := CertificatePolicy{ + IssuerParameters: &IssuerParameters{Name: to.Ptr("Self")}, + PlatformManaged: NewPlatformManaged("tls-client", map[string]any{ + "issuer": "internal-ca", + "renewal": map[string]any{ + "enabled": true, + }, + }), + } + + req, err := client.updateCertificatePolicyCreateRequest(context.Background(), "cert-name", policy, nil) + require.NoError(t, err) + require.Equal(t, version20260301Preview, req.Raw().URL.Query().Get("api-version")) + + body, err := io.ReadAll(req.Raw().Body) + require.NoError(t, err) + require.JSONEq(t, `{ + "issuer": {"name": "Self"}, + "platformManaged": { + "certificateUsage": "tls-client", + "metadata": { + "issuer": "internal-ca", + "renewal": { + "enabled": true + } + } + } + }`, string(body)) +} diff --git a/sdk/security/keyvault/azcertificates/fake/internal.go b/sdk/security/keyvault/azcertificates/fake/internal.go index 88d11305e74b..c6cbd9a6db98 100644 --- a/sdk/security/keyvault/azcertificates/fake/internal.go +++ b/sdk/security/keyvault/azcertificates/fake/internal.go @@ -23,15 +23,6 @@ func (nonRetriableError) NonRetriable() { // marker method } -func contains[T comparable](s []T, v T) bool { - for _, vv := range s { - if vv == v { - return true - } - } - return false -} - func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { if v == "" { return nil, nil @@ -40,7 +31,7 @@ func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) if err != nil { return nil, err } - return &t, err + return &t, nil } func newTracker[T any]() *tracker[T] { diff --git a/sdk/security/keyvault/azcertificates/fake/server.go b/sdk/security/keyvault/azcertificates/fake/server.go index fc98418bf951..0444d4391285 100644 --- a/sdk/security/keyvault/azcertificates/fake/server.go +++ b/sdk/security/keyvault/azcertificates/fake/server.go @@ -16,6 +16,7 @@ import ( "net/http" "net/url" "regexp" + "slices" "strconv" ) @@ -165,9 +166,7 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { } func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -235,10 +234,7 @@ func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -268,7 +264,7 @@ func (s *ServerTransport) dispatchBackupCertificate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackupCertificateResult, req) @@ -301,7 +297,7 @@ func (s *ServerTransport) dispatchCreateCertificate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusAccepted}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusAccepted}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateOperation, req) @@ -330,7 +326,7 @@ func (s *ServerTransport) dispatchDeleteCertificate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeletedCertificate, req) @@ -359,7 +355,7 @@ func (s *ServerTransport) dispatchDeleteCertificateOperation(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateOperation, req) @@ -378,7 +374,7 @@ func (s *ServerTransport) dispatchDeleteContacts(req *http.Request) (*http.Respo return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Contacts, req) @@ -407,7 +403,7 @@ func (s *ServerTransport) dispatchDeleteIssuer(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Issuer, req) @@ -440,7 +436,7 @@ func (s *ServerTransport) dispatchGetCertificate(req *http.Request) (*http.Respo return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -469,7 +465,7 @@ func (s *ServerTransport) dispatchGetCertificateOperation(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateOperation, req) @@ -498,7 +494,7 @@ func (s *ServerTransport) dispatchGetCertificatePolicy(req *http.Request) (*http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificatePolicy, req) @@ -517,7 +513,7 @@ func (s *ServerTransport) dispatchGetContacts(req *http.Request) (*http.Response return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Contacts, req) @@ -546,7 +542,7 @@ func (s *ServerTransport) dispatchGetDeletedCertificate(req *http.Request) (*htt return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeletedCertificate, req) @@ -575,7 +571,7 @@ func (s *ServerTransport) dispatchGetIssuer(req *http.Request) (*http.Response, return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Issuer, req) @@ -608,7 +604,7 @@ func (s *ServerTransport) dispatchImportCertificate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -625,11 +621,7 @@ func (s *ServerTransport) dispatchNewListCertificatePropertiesPager(req *http.Re newListCertificatePropertiesPager := s.newListCertificatePropertiesPager.get(req) if newListCertificatePropertiesPager == nil { qp := req.URL.Query() - includePendingUnescaped, err := url.QueryUnescape(qp.Get("includePending")) - if err != nil { - return nil, err - } - includePendingParam, err := parseOptional(includePendingUnescaped, strconv.ParseBool) + includePendingParam, err := parseOptional(qp.Get("includePending"), strconv.ParseBool) if err != nil { return nil, err } @@ -650,7 +642,7 @@ func (s *ServerTransport) dispatchNewListCertificatePropertiesPager(req *http.Re if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { s.newListCertificatePropertiesPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -687,7 +679,7 @@ func (s *ServerTransport) dispatchNewListCertificatePropertiesVersionsPager(req if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { s.newListCertificatePropertiesVersionsPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -704,11 +696,7 @@ func (s *ServerTransport) dispatchNewListDeletedCertificatePropertiesPager(req * newListDeletedCertificatePropertiesPager := s.newListDeletedCertificatePropertiesPager.get(req) if newListDeletedCertificatePropertiesPager == nil { qp := req.URL.Query() - includePendingUnescaped, err := url.QueryUnescape(qp.Get("includePending")) - if err != nil { - return nil, err - } - includePendingParam, err := parseOptional(includePendingUnescaped, strconv.ParseBool) + includePendingParam, err := parseOptional(qp.Get("includePending"), strconv.ParseBool) if err != nil { return nil, err } @@ -729,7 +717,7 @@ func (s *ServerTransport) dispatchNewListDeletedCertificatePropertiesPager(req * if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { s.newListDeletedCertificatePropertiesPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -756,7 +744,7 @@ func (s *ServerTransport) dispatchNewListIssuerPropertiesPager(req *http.Request if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { s.newListIssuerPropertiesPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -789,7 +777,7 @@ func (s *ServerTransport) dispatchMergeCertificate(req *http.Request) (*http.Res return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusCreated}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusCreated}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -818,7 +806,7 @@ func (s *ServerTransport) dispatchPurgeDeletedCertificate(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -847,7 +835,7 @@ func (s *ServerTransport) dispatchRecoverDeletedCertificate(req *http.Request) ( return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -870,7 +858,7 @@ func (s *ServerTransport) dispatchRestoreCertificate(req *http.Request) (*http.R return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -893,7 +881,7 @@ func (s *ServerTransport) dispatchSetContacts(req *http.Request) (*http.Response return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Contacts, req) @@ -926,7 +914,7 @@ func (s *ServerTransport) dispatchSetIssuer(req *http.Request) (*http.Response, return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Issuer, req) @@ -963,7 +951,7 @@ func (s *ServerTransport) dispatchUpdateCertificate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Certificate, req) @@ -996,7 +984,7 @@ func (s *ServerTransport) dispatchUpdateCertificateOperation(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateOperation, req) @@ -1029,7 +1017,7 @@ func (s *ServerTransport) dispatchUpdateCertificatePolicy(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificatePolicy, req) @@ -1062,7 +1050,7 @@ func (s *ServerTransport) dispatchUpdateIssuer(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Issuer, req) diff --git a/sdk/security/keyvault/azcertificates/go.mod b/sdk/security/keyvault/azcertificates/go.mod index f81e453cafaa..353fc75b35e0 100644 --- a/sdk/security/keyvault/azcertificates/go.mod +++ b/sdk/security/keyvault/azcertificates/go.mod @@ -3,9 +3,9 @@ module github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates go 1.25.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 github.com/stretchr/testify v1.11.1 ) @@ -18,9 +18,9 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.49.0 // indirect - golang.org/x/net v0.52.0 // indirect - golang.org/x/sys v0.42.0 // indirect - golang.org/x/text v0.35.0 // indirect + golang.org/x/crypto v0.50.0 // indirect + golang.org/x/net v0.53.0 // indirect + golang.org/x/sys v0.43.0 // indirect + golang.org/x/text v0.36.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/security/keyvault/azcertificates/go.sum b/sdk/security/keyvault/azcertificates/go.sum index 50f8444bd350..5683726ff60c 100644 --- a/sdk/security/keyvault/azcertificates/go.sum +++ b/sdk/security/keyvault/azcertificates/go.sum @@ -1,11 +1,11 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 h1:jHb/wfvRikGdxMXYV3QG/SzUOPYN9KEUUuC0Yd0/vC0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1/go.mod h1:pzBXCYn05zvYIrwLgtK8Ap8QcjRg+0i76tMQdWN6wOk= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 h1:fhqpLE3UEXi9lPaBRpQ6XuRW0nU7hgg4zlmZZa+a9q4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0/go.mod h1:7dCRMLwisfRH3dBupKeNCioWYUZ4SS09Z14H+7i8ZoY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 h1:nCYfgcSyHZXJI8J0IWE5MsCGlb2xp9fJiXyxWgmOFg4= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0/go.mod h1:ucUjca2JtSZboY8IoUqyQyuuXvwbMBVwFOm0vdQPNhA= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= @@ -34,15 +34,15 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4= -golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= -golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0= -golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw= +golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= +golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= +golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= +golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= -golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= -golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= +golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= +golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= +golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/security/keyvault/azcertificates/models.go b/sdk/security/keyvault/azcertificates/models.go index f2f3d5b88cd1..73db74bca27a 100644 --- a/sdk/security/keyvault/azcertificates/models.go +++ b/sdk/security/keyvault/azcertificates/models.go @@ -135,6 +135,10 @@ type CertificatePolicy struct { // Actions that will be performed by Key Vault over the lifetime of a certificate. LifetimeActions []*LifetimeAction + // Configuration that enables the platform to manage the certificate on behalf of the user. This feature is currently intended + // for internal use only. + PlatformManaged *PlatformManaged + // Properties of the secret backing a certificate. SecretProperties *SecretProperties @@ -442,6 +446,16 @@ type OrganizationDetails struct { ID *string } +// PlatformManaged - Properties of the platform managed certificate. This feature is currently intended for internal use only. +type PlatformManaged struct { + // REQUIRED; The intended usage of the certificate. + CertificateUsage *string + + // JSON-formatted platform managed metadata. The schema is intentionally undefined as this feature is currently intended for + // internal use only. + Metadata map[string]any +} + // RestoreCertificateParameters - The certificate restore parameters. type RestoreCertificateParameters struct { // REQUIRED; The backup blob associated with a certificate bundle. diff --git a/sdk/security/keyvault/azcertificates/models_serde.go b/sdk/security/keyvault/azcertificates/models_serde.go index 9576bff6e829..2c687de9ccda 100644 --- a/sdk/security/keyvault/azcertificates/models_serde.go +++ b/sdk/security/keyvault/azcertificates/models_serde.go @@ -9,7 +9,9 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime" "reflect" + "time" ) // MarshalJSON implements the json.Marshaller interface for type AdministratorContact. @@ -156,13 +158,13 @@ func (c *Certificate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CertificateAttributes. func (c CertificateAttributes) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeUnix(objectMap, "created", c.Created) + populateTime[datetime.Unix](objectMap, "created", c.Created) populate(objectMap, "enabled", c.Enabled) - populateTimeUnix(objectMap, "exp", c.Expires) - populateTimeUnix(objectMap, "nbf", c.NotBefore) + populateTime[datetime.Unix](objectMap, "exp", c.Expires) + populateTime[datetime.Unix](objectMap, "nbf", c.NotBefore) populate(objectMap, "recoverableDays", c.RecoverableDays) populate(objectMap, "recoveryLevel", c.RecoveryLevel) - populateTimeUnix(objectMap, "updated", c.Updated) + populateTime[datetime.Unix](objectMap, "updated", c.Updated) return json.Marshal(objectMap) } @@ -176,16 +178,16 @@ func (c *CertificateAttributes) UnmarshalJSON(data []byte) error { var err error switch key { case "created": - err = unpopulateTimeUnix(val, "Created", &c.Created) + err = unpopulateTime[datetime.Unix](val, "Created", &c.Created) delete(rawMsg, key) case "enabled": err = unpopulate(val, "Enabled", &c.Enabled) delete(rawMsg, key) case "exp": - err = unpopulateTimeUnix(val, "Expires", &c.Expires) + err = unpopulateTime[datetime.Unix](val, "Expires", &c.Expires) delete(rawMsg, key) case "nbf": - err = unpopulateTimeUnix(val, "NotBefore", &c.NotBefore) + err = unpopulateTime[datetime.Unix](val, "NotBefore", &c.NotBefore) delete(rawMsg, key) case "recoverableDays": err = unpopulate(val, "RecoverableDays", &c.RecoverableDays) @@ -194,7 +196,7 @@ func (c *CertificateAttributes) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RecoveryLevel", &c.RecoveryLevel) delete(rawMsg, key) case "updated": - err = unpopulateTimeUnix(val, "Updated", &c.Updated) + err = unpopulateTime[datetime.Unix](val, "Updated", &c.Updated) delete(rawMsg, key) } if err != nil { @@ -279,6 +281,7 @@ func (c CertificatePolicy) MarshalJSON() ([]byte, error) { populate(objectMap, "issuer", c.IssuerParameters) populate(objectMap, "key_props", c.KeyProperties) populate(objectMap, "lifetime_actions", c.LifetimeActions) + populate(objectMap, "platformManaged", c.PlatformManaged) populate(objectMap, "secret_props", c.SecretProperties) populate(objectMap, "x509_props", c.X509CertificateProperties) return json.Marshal(objectMap) @@ -308,6 +311,9 @@ func (c *CertificatePolicy) UnmarshalJSON(data []byte) error { case "lifetime_actions": err = unpopulate(val, "LifetimeActions", &c.LifetimeActions) delete(rawMsg, key) + case "platformManaged": + err = unpopulate(val, "PlatformManaged", &c.PlatformManaged) + delete(rawMsg, key) case "secret_props": err = unpopulate(val, "SecretProperties", &c.SecretProperties) delete(rawMsg, key) @@ -509,14 +515,14 @@ func (d DeletedCertificate) MarshalJSON() ([]byte, error) { return runtime.EncodeByteArray(d.CER, runtime.Base64StdFormat) }) populate(objectMap, "contentType", d.ContentType) - populateTimeUnix(objectMap, "deletedDate", d.DeletedDate) + populateTime[datetime.Unix](objectMap, "deletedDate", d.DeletedDate) populate(objectMap, "id", d.ID) populate(objectMap, "kid", d.KID) populate(objectMap, "policy", d.Policy) populate(objectMap, "preserveCertOrder", d.PreserveCertOrder) populate(objectMap, "recoveryId", d.RecoveryID) populate(objectMap, "sid", d.SID) - populateTimeUnix(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populateTime[datetime.Unix](objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) populate(objectMap, "tags", d.Tags) populateByteArray(objectMap, "x5t", d.X509Thumbprint, func() any { return runtime.EncodeByteArray(d.X509Thumbprint, runtime.Base64URLFormat) @@ -545,7 +551,7 @@ func (d *DeletedCertificate) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ContentType", &d.ContentType) delete(rawMsg, key) case "deletedDate": - err = unpopulateTimeUnix(val, "DeletedDate", &d.DeletedDate) + err = unpopulateTime[datetime.Unix](val, "DeletedDate", &d.DeletedDate) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &d.ID) @@ -566,7 +572,7 @@ func (d *DeletedCertificate) UnmarshalJSON(data []byte) error { err = unpopulate(val, "SID", &d.SID) delete(rawMsg, key) case "scheduledPurgeDate": - err = unpopulateTimeUnix(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) + err = unpopulateTime[datetime.Unix](val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) @@ -588,10 +594,10 @@ func (d *DeletedCertificate) UnmarshalJSON(data []byte) error { func (d DeletedCertificateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "attributes", d.Attributes) - populateTimeUnix(objectMap, "deletedDate", d.DeletedDate) + populateTime[datetime.Unix](objectMap, "deletedDate", d.DeletedDate) populate(objectMap, "id", d.ID) populate(objectMap, "recoveryId", d.RecoveryID) - populateTimeUnix(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populateTime[datetime.Unix](objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) populate(objectMap, "tags", d.Tags) populateByteArray(objectMap, "x5t", d.X509Thumbprint, func() any { return runtime.EncodeByteArray(d.X509Thumbprint, runtime.Base64URLFormat) @@ -612,7 +618,7 @@ func (d *DeletedCertificateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Attributes", &d.Attributes) delete(rawMsg, key) case "deletedDate": - err = unpopulateTimeUnix(val, "DeletedDate", &d.DeletedDate) + err = unpopulateTime[datetime.Unix](val, "DeletedDate", &d.DeletedDate) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &d.ID) @@ -621,7 +627,7 @@ func (d *DeletedCertificateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RecoveryID", &d.RecoveryID) delete(rawMsg, key) case "scheduledPurgeDate": - err = unpopulateTimeUnix(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) + err = unpopulateTime[datetime.Unix](val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) @@ -763,9 +769,9 @@ func (i *Issuer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IssuerAttributes. func (i IssuerAttributes) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeUnix(objectMap, "created", i.Created) + populateTime[datetime.Unix](objectMap, "created", i.Created) populate(objectMap, "enabled", i.Enabled) - populateTimeUnix(objectMap, "updated", i.Updated) + populateTime[datetime.Unix](objectMap, "updated", i.Updated) return json.Marshal(objectMap) } @@ -779,13 +785,13 @@ func (i *IssuerAttributes) UnmarshalJSON(data []byte) error { var err error switch key { case "created": - err = unpopulateTimeUnix(val, "Created", &i.Created) + err = unpopulateTime[datetime.Unix](val, "Created", &i.Created) delete(rawMsg, key) case "enabled": err = unpopulate(val, "Enabled", &i.Enabled) delete(rawMsg, key) case "updated": - err = unpopulateTimeUnix(val, "Updated", &i.Updated) + err = unpopulateTime[datetime.Unix](val, "Updated", &i.Updated) delete(rawMsg, key) } if err != nil { @@ -1134,6 +1140,37 @@ func (o *OrganizationDetails) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PlatformManaged. +func (p PlatformManaged) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificateUsage", p.CertificateUsage) + populate(objectMap, "metadata", p.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlatformManaged. +func (p *PlatformManaged) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateUsage": + err = unpopulate(val, "CertificateUsage", &p.CertificateUsage) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &p.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type RestoreCertificateParameters. func (r RestoreCertificateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1428,6 +1465,17 @@ func populate(m map[string]any, k string, v any) { } } +func populateTime[T dateTimeConstraints](m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + } else if !reflect.ValueOf(t).IsNil() { + newTime := T(*t) + m[k] = (*T)(&newTime) + } +} + func populateByteArray[T any](m map[string]any, k string, b []T, convert func() any) { if azcore.IsNullValue(b) { m[k] = nil @@ -1447,3 +1495,20 @@ func unpopulate(data json.RawMessage, fn string, v any) error { } return nil } + +func unpopulateTime[T dateTimeConstraints](data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux T + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + newTime := time.Time(aux) + *t = &newTime + return nil +} + +type dateTimeConstraints interface { + datetime.PlainDate | datetime.PlainTime | datetime.RFC1123 | datetime.RFC3339 | datetime.Unix +} diff --git a/sdk/security/keyvault/azcertificates/testdata/_metadata.json b/sdk/security/keyvault/azcertificates/testdata/_metadata.json index 2df4d87535b7..fde386ee0a38 100644 --- a/sdk/security/keyvault/azcertificates/testdata/_metadata.json +++ b/sdk/security/keyvault/azcertificates/testdata/_metadata.json @@ -1,4 +1,6 @@ { - "apiVersion": "2025-07-01", - "emitterVersion": "0.8.2" -} \ No newline at end of file + "apiVersions": { + "KeyVault": "2026-03-01-preview" + }, + "emitterVersion": "0.13.0" +} diff --git a/sdk/security/keyvault/azcertificates/time_unix.go b/sdk/security/keyvault/azcertificates/time_unix.go deleted file mode 100644 index a9698ee84f6e..000000000000 --- a/sdk/security/keyvault/azcertificates/time_unix.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. - -package azcertificates - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "time" -) - -type timeUnix time.Time - -func (t timeUnix) MarshalJSON() ([]byte, error) { - return json.Marshal(time.Time(t).Unix()) -} - -func (t *timeUnix) UnmarshalJSON(data []byte) error { - var seconds int64 - if err := json.Unmarshal(data, &seconds); err != nil { - return err - } - *t = timeUnix(time.Unix(seconds, 0)) - return nil -} - -func (t timeUnix) String() string { - return fmt.Sprintf("%d", time.Time(t).Unix()) -} - -func populateTimeUnix(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*timeUnix)(t) -} - -func unpopulateTimeUnix(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || string(data) == "null" { - return nil - } - var aux timeUnix - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/security/keyvault/azcertificates/tsp-location.yaml b/sdk/security/keyvault/azcertificates/tsp-location.yaml index b6ceafea8bfe..cc7af6a78f02 100644 --- a/sdk/security/keyvault/azcertificates/tsp-location.yaml +++ b/sdk/security/keyvault/azcertificates/tsp-location.yaml @@ -1,5 +1,5 @@ -directory: specification/keyvault/Security.KeyVault.Certificates -commit: 6733bfe4447e09f501d691efb69b4045dd536f8d +directory: specification/keyvault/data-plane/Certificates +commit: ea20c467080ed3d3875c8b5aeff28ce52f6a55ca repo: Azure/azure-rest-api-specs additionalDirectories: -- specification/keyvault/Security.KeyVault.Common +- specification/keyvault/data-plane/Certificates/common