Skip to content

Commit e4ee008

Browse files
authored
[Key Vault] Generate Fakes for Go (Azure#33285)
1 parent b6f29a6 commit e4ee008

File tree

13 files changed

+227
-35
lines changed

13 files changed

+227
-35
lines changed

specification/keyvault/Security.KeyVault.BackupRestore/tspconfig.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ options:
2929
package-dir: "azadmin/backup"
3030
inject-spans: true
3131
single-client: true
32+
generate-fakes: true
33+
module: "github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin"
34+
module-version: "0.0.1"
3235
"@azure-tools/typespec-client-generator-cli":
3336
additionalDirectories:
3437
- "specification/keyvault/Security.KeyVault.Common/"

specification/keyvault/Security.KeyVault.Certificates/client.tsp

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import "./main.tsp";
22
import "@azure-tools/typespec-client-generator-core";
33

44
using Azure.ClientGenerator.Core;
5+
using TypeSpec.Versioning;
6+
using TypeSpec.Http;
7+
8+
@versioned(KeyVault.Versions)
9+
namespace Customizations;
510

611
@@clientName(KeyVault, "Certificate", "java");
712
@@clientName(KeyVault, "Client", "go");
@@ -24,8 +29,92 @@ using KeyVault;
2429
@@clientName(KeyUsageType, "CertificateKeyUsage", "java");
2530
@@clientName(SubjectAlternativeNames.upns, "userPrincipalNames", "java");
2631

27-
// rename Go operations
32+
// Go configuration
33+
34+
/**
35+
* The GetCertificates operation returns the set of certificates resources in the specified key vault. This operation requires the certificates/list permission.
36+
*/
37+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
38+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
39+
@summary("List certificates in a specified key vault")
40+
@route("/certificates")
41+
@get
42+
op listCertificateProperties is KeyVaultOperation<
43+
{
44+
/**
45+
* Specifies whether to include certificates which are not completely provisioned.
46+
*/
47+
@query("includePending")
48+
includePending?: boolean;
49+
},
50+
CertificateListResult
51+
>;
52+
53+
/**
54+
* The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
55+
*/
56+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
57+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
58+
@summary("List certificate issuers for a specified key vault.")
59+
@route("/certificates/issuers")
60+
@get
61+
op listIssuerProperties is KeyVaultOperation<{}, CertificateIssuerListResult>;
62+
63+
/**
64+
* The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This operation requires the certificates/list permission.
65+
*/
66+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
67+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
68+
@summary("List the versions of a certificate.")
69+
@route("/certificates/{certificate-name}/versions")
70+
@get
71+
op listCertificatePropertiesVersions is KeyVaultOperation<
72+
{
73+
/**
74+
* The name of the certificate.
75+
*/
76+
@path("certificate-name")
77+
@clientName("name", "go")
78+
certificateName: string;
79+
},
80+
CertificateListResult
81+
>;
82+
83+
/**
84+
* 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.
85+
*/
86+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
87+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
88+
@summary("Lists the deleted certificates in the specified vault currently available for recovery.")
89+
@route("/deletedcertificates")
90+
@get
91+
op listDeletedCertificateProperties is KeyVaultOperation<
92+
{
93+
/**
94+
* Specifies whether to include certificates which are not completely provisioned.
95+
*/
96+
@query("includePending")
97+
includePending?: boolean;
98+
},
99+
DeletedCertificateListResult
100+
>;
101+
102+
@@override(getCertificates, listCertificateProperties, "go");
103+
@@override(getCertificateIssuers, listIssuerProperties, "go");
104+
@@override(getCertificateVersions, listCertificatePropertiesVersions, "go");
105+
@@override(getDeletedCertificates, listDeletedCertificateProperties, "go");
106+
28107
@@clientName(setCertificateContacts, "SetContacts", "go");
108+
@@clientName(getCertificates, "ListCertificateProperties", "go");
109+
@@clientName(getCertificateIssuers, "ListIssuerProperties", "go");
110+
@@clientName(getCertificateVersions, "ListCertificatePropertiesVersions", "go");
111+
@@clientName(getDeletedCertificates, "ListDeletedCertificateProperties", "go");
112+
@@clientName(getCertificateContacts, "GetContacts", "go");
113+
@@clientName(deleteCertificateContacts, "DeleteContacts", "go");
114+
@@clientName(setCertificateIssuer, "SetIssuer", "go");
115+
@@clientName(updateCertificateIssuer, "UpdateIssuer", "go");
116+
@@clientName(getCertificateIssuer, "GetIssuer", "go");
117+
@@clientName(deleteCertificateIssuer, "DeleteIssuer", "go");
29118

30119
@@clientName(CertificateCreateParameters, "CreateCertificateParameters", "go");
31120
@@clientName(CertificateImportParameters, "ImportCertificateParameters", "go");
@@ -41,23 +130,11 @@ using KeyVault;
41130
"go"
42131
);
43132
@@clientName(CertificateUpdateParameters, "UpdateCertificateParameters", "go");
44-
45-
@@clientName(getCertificates, "ListCertificateProperties", "go");
46-
@@clientName(getCertificateIssuers, "ListIssuerProperties", "go");
47-
@@clientName(getCertificateVersions, "ListCertificatePropertiesVersions", "go");
48-
@@clientName(getDeletedCertificates, "ListDeletedCertificateProperties", "go");
49133
@@clientName(CertificateListResult, "CertificatePropertiesListResult", "go");
50134
@@clientName(DeletedCertificateListResult,
51135
"DeletedCertificatePropertiesListResult",
52136
"go"
53137
);
54-
55-
@@clientName(getCertificateContacts, "GetContacts", "go");
56-
@@clientName(deleteCertificateContacts, "DeleteContacts", "go");
57-
@@clientName(setCertificateIssuer, "SetIssuer", "go");
58-
@@clientName(updateCertificateIssuer, "UpdateIssuer", "go");
59-
@@clientName(getCertificateIssuer, "GetIssuer", "go");
60-
@@clientName(deleteCertificateIssuer, "DeleteIssuer", "go");
61138
@@clientName(CertificateIssuerListResult, "IssuerPropertiesListResult", "go");
62139

63140
@@clientName(Action, "LifetimeActionType", "go");

specification/keyvault/Security.KeyVault.Certificates/routes.tsp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import "@typespec/rest";
44
import "./models.tsp";
55
import "../Security.KeyVault.Common/common.tsp";
66

7-
using Azure.Core;
8-
using Azure.Core.Traits;
97
using Azure.ClientGenerator.Core;
10-
using TypeSpec.Rest;
118
using TypeSpec.Http;
129

1310
namespace KeyVault;
@@ -129,6 +126,7 @@ op setCertificateIssuer is KeyVaultOperation<
129126
* 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.
130127
*/
131128
@path("issuer-name")
129+
@clientName("name", "go")
132130
issuerName: string;
133131

134132
/**
@@ -155,6 +153,7 @@ op updateCertificateIssuer is KeyVaultOperation<
155153
* The name of the issuer.
156154
*/
157155
@path("issuer-name")
156+
@clientName("name", "go")
158157
issuerName: string;
159158

160159
/**
@@ -181,6 +180,7 @@ op getCertificateIssuer is KeyVaultOperation<
181180
* The name of the issuer.
182181
*/
183182
@path("issuer-name")
183+
@clientName("name", "go")
184184
issuerName: string;
185185
},
186186
IssuerBundle
@@ -199,6 +199,7 @@ op deleteCertificateIssuer is KeyVaultOperation<
199199
* The name of the issuer.
200200
*/
201201
@path("issuer-name")
202+
@clientName("name", "go")
202203
issuerName: string;
203204
},
204205
IssuerBundle

specification/keyvault/Security.KeyVault.Certificates/tspconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ options:
5656
override-client-name: "Client"
5757
single-client: true
5858
inject-spans: true
59+
generate-fakes: true
5960
"@azure-tools/typespec-rust":
6061
crate-name: "azure_security_keyvault_certificates"
6162
crate-version: "0.0.1"

specification/keyvault/Security.KeyVault.Keys/client.tsp

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import "./main.tsp";
22
import "@azure-tools/typespec-client-generator-core";
33

44
using Azure.ClientGenerator.Core;
5+
using TypeSpec.Versioning;
6+
using TypeSpec.Http;
7+
8+
@versioned(KeyVault.Versions)
9+
namespace Customizations;
510

611
@@clientName(KeyVault, "Key", "java");
712
@@clientName(KeyVault, "Client", "go");
@@ -21,6 +26,61 @@ using KeyVault;
2126
@@clientName(JsonWebKeyType, "KeyType", "java");
2227

2328
// Go configuration
29+
30+
/**
31+
* The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission.
32+
*/
33+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
34+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
35+
@summary("Retrieves a list of individual key versions with the same key name.")
36+
@route("/keys/{key-name}/versions")
37+
@get
38+
op listKeyPropertiesVersions is KeyVaultOperation<
39+
{
40+
/**
41+
* The name of the key.
42+
*/
43+
@path("key-name")
44+
@clientName("name", "go")
45+
keyName: string;
46+
},
47+
KeyListResult
48+
>;
49+
50+
/**
51+
* Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the keys/list permission.
52+
*/
53+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
54+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
55+
@summary("List keys in the specified vault.")
56+
@route("/keys")
57+
@get
58+
op listKeyProperties is KeyVaultOperation<{}, KeyListResult>;
59+
60+
/**
61+
* Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/list permission.
62+
*/
63+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
64+
#suppress "@azure-tools/typespec-azure-core/use-standard-names" "Operation name is already established"
65+
@summary("Lists the deleted keys in the specified vault.")
66+
@route("/deletedkeys")
67+
@get
68+
op listDeletedKeyProperties is KeyVaultOperation<{}, DeletedKeyListResult>;
69+
70+
@@override(getKeyVersions, listKeyPropertiesVersions, "go");
71+
@@override(getKeys, listKeyProperties, "go");
72+
@@override(getDeletedKeys, listDeletedKeyProperties, "go");
73+
74+
@@clientName(getDeletedKeys, "ListDeletedKeyProperties", "go");
75+
@@clientName(getKeys, "ListKeyProperties", "go");
76+
@@clientName(getKeyVersions, "ListKeyPropertiesVersions", "go");
77+
78+
// renaming KeyItem to KeyProperties.
79+
// renaming existing KeyProperties to something else
80+
// to avoid a naming conflict as it's not part of the public surface area
81+
@@clientName(KeyProperties, "ShouldNotGenerate", "go");
82+
@@clientName(KeyItem, "KeyProperties", "go");
83+
2484
@@clientName(KeyCreateParameters, "CreateKeyParameters", "go");
2585
@@clientName(KeyExportParameters, "ExportKeyParameters", "go");
2686
@@clientName(KeyImportParameters, "ImportKeyParameters", "go");
@@ -30,12 +90,8 @@ using KeyVault;
3090
@@clientName(KeyUpdateParameters, "UpdateKeyParameters", "go");
3191
@@clientName(KeyVerifyParameters, "VerifyParameters", "go");
3292
@@clientName(GetRandomBytesRequest, "GetRandomBytesParameters", "go");
33-
@@clientName(getDeletedKeys, "ListDeletedKeyProperties", "go");
34-
@@clientName(getKeys, "ListKeyProperties", "go");
35-
@@clientName(getKeyVersions, "ListKeyPropertiesVersions", "go");
93+
3694
@@clientName(DeletedKeyBundle, "DeletedKey", "go");
37-
@@clientName(KeyProperties, "KeyP", "go");
38-
@@clientName(KeyItem, "KeyProperties", "go");
3995
@@clientName(DeletedKeyItem, "DeletedKeyProperties", "go");
4096
@@clientName(DeletedKeyListResult, "DeletedKeyPropertiesListResult", "go");
4197
@@clientName(KeyListResult, "KeyPropertiesListResult", "go");

specification/keyvault/Security.KeyVault.Keys/routes.tsp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import "@typespec/rest";
55
import "./models.tsp";
66
import "../Security.KeyVault.Common/common.tsp";
77

8-
using Azure.Core;
9-
using Azure.Core.Traits;
108
using Azure.ClientGenerator.Core;
119
using TypeSpec.Http;
1210
using TypeSpec.OpenAPI;
13-
using TypeSpec.Rest;
1411

1512
namespace KeyVault;
1613

specification/keyvault/Security.KeyVault.Keys/tspconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ options:
5656
override-client-name: "Client"
5757
single-client: true
5858
inject-spans: true
59+
generate-fakes: true
5960
"@azure-tools/typespec-rust":
6061
crate-name: "azure_security_keyvault_keys"
6162
crate-version: "0.0.1"

specification/keyvault/Security.KeyVault.RBAC/routes.tsp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import "@typespec/rest";
33
import "./models.tsp";
44

55
using TypeSpec.Http;
6-
using TypeSpec.Rest;
7-
using Azure.Core;
86

97
namespace KeyVault;
108

specification/keyvault/Security.KeyVault.RBAC/tspconfig.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ options:
2929
package-dir: "azadmin/rbac"
3030
inject-spans: true
3131
single-client: true
32+
generate-fakes: true
33+
module: "github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin"
34+
module-version: "0.0.1"
3235
"@azure-tools/typespec-client-generator-cli":
3336
additionalDirectories:
3437
- "specification/keyvault/Security.KeyVault.Common/"

0 commit comments

Comments
 (0)