Skip to content

Commit b25268f

Browse files
authored
tsp - Add a new test case - DeviceProvisioningServices (#1525)
1 parent 1550e4c commit b25268f

File tree

450 files changed

+106466
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

450 files changed

+106466
-1
lines changed
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "./models.tsp";
6+
import "./ProvisioningServiceDescription.tsp";
7+
8+
using TypeSpec.Rest;
9+
using Azure.ResourceManager;
10+
using TypeSpec.Http;
11+
using TypeSpec.OpenAPI;
12+
13+
namespace Microsoft.Devices;
14+
/**
15+
* The X509 Certificate.
16+
*/
17+
@parentResource(ProvisioningServiceDescription)
18+
model CertificateResponse
19+
is Azure.ResourceManager.ProxyResource<CertificateProperties> {
20+
...ResourceNameParameter<
21+
Resource = CertificateResponse,
22+
KeyName = "certificateName",
23+
SegmentName = "certificates",
24+
NamePattern = ""
25+
>;
26+
27+
/**
28+
* The entity tag.
29+
*/
30+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
31+
@visibility(Lifecycle.Read)
32+
etag?: string;
33+
}
34+
35+
alias CertificateNameQuery1 = {
36+
/**
37+
* Common Name for the certificate.
38+
*/
39+
#suppress "@azure-tools/typespec-azure-core/casing-style" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
40+
@query("certificate.name")
41+
`certificate.name`?: string;
42+
};
43+
44+
alias CertificateNameQuery2 = {
45+
/**
46+
* This is optional, and it is the Common Name of the certificate.
47+
*/
48+
#suppress "@azure-tools/typespec-azure-core/casing-style" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
49+
@query("certificate.name")
50+
`certificate.name`?: string;
51+
};
52+
53+
alias CertificateNameQuery3 = {
54+
/**
55+
* Time the certificate is created.
56+
*/
57+
@query("certificate.created")
58+
certificateCreated?: utcDateTime;
59+
};
60+
61+
alias CertificateNameQuery4 = {
62+
/**
63+
* Certificate last updated time.
64+
*/
65+
@query("certificate.lastUpdated")
66+
certificateLastUpdated?: utcDateTime;
67+
};
68+
69+
@armResourceOperations
70+
interface CertificateResponses {
71+
/**
72+
* Get the certificate from the provisioning service.
73+
*/
74+
get is ArmResourceRead<
75+
CertificateResponse,
76+
Parameters = {
77+
/**
78+
* ETag of the certificate.
79+
*/
80+
@header("If-Match")
81+
ifMatch?: string;
82+
},
83+
Error = ErrorDetails
84+
>;
85+
86+
/**
87+
* Add new certificate or update an existing certificate.
88+
*/
89+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
90+
createOrUpdate is ArmResourceCreateOrReplaceSync<
91+
CertificateResponse,
92+
Parameters = {
93+
/**
94+
* ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate.
95+
*/
96+
@header("If-Match")
97+
ifMatch?: string;
98+
},
99+
Response = ArmResourceUpdatedResponse<CertificateResponse>,
100+
Error = ErrorDetails
101+
>;
102+
103+
/**
104+
* Deletes the specified certificate associated with the Provisioning Service
105+
*/
106+
delete is ArmResourceDeleteSync<
107+
CertificateResponse,
108+
Parameters = {
109+
/**
110+
* ETag of the certificate
111+
*/
112+
@header("If-Match")
113+
ifMatch: string;
114+
115+
...CertificateNameQuery2;
116+
117+
/**
118+
* Raw data within the certificate.
119+
*/
120+
@query("certificate.rawBytes")
121+
certificateRawBytes?: bytes;
122+
123+
/**
124+
* Indicates if certificate has been verified by owner of the private key.
125+
*/
126+
@query("certificate.isVerified")
127+
certificateIsVerified?: boolean;
128+
129+
/**
130+
* A description that mentions the purpose of the certificate.
131+
*/
132+
@query("certificate.purpose")
133+
certificatePurpose?: CertificatePurpose;
134+
135+
...CertificateNameQuery3;
136+
...CertificateNameQuery4;
137+
138+
/**
139+
* Indicates if the certificate contains a private key.
140+
*/
141+
@query("certificate.hasPrivateKey")
142+
certificateHasPrivateKey?: boolean;
143+
144+
/**
145+
* Random number generated to indicate Proof of Possession.
146+
*/
147+
@query("certificate.nonce")
148+
certificateNonce?: string;
149+
},
150+
Error = ErrorDetails
151+
>;
152+
153+
/**
154+
* Get all the certificates tied to the provisioning service.
155+
*/
156+
list is ArmResourceListByParent<
157+
CertificateResponse,
158+
Response = ArmResponse<CertificateListDescription>,
159+
Error = ErrorDetails
160+
>;
161+
162+
/**
163+
* Generate verification code for Proof of Possession.
164+
*/
165+
generateVerificationCode is ArmResourceActionSync<
166+
CertificateResponse,
167+
void,
168+
ArmResponse<VerificationCodeResponse>,
169+
Parameters = {
170+
/**
171+
* ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate.
172+
*/
173+
@header("If-Match")
174+
ifMatch: string;
175+
176+
...CertificateNameQuery1;
177+
178+
/**
179+
* Raw data of certificate.
180+
*/
181+
@query("certificate.rawBytes")
182+
certificateRawBytes?: bytes;
183+
184+
/**
185+
* Indicates if the certificate has been verified by owner of the private key.
186+
*/
187+
@query("certificate.isVerified")
188+
certificateIsVerified?: boolean;
189+
190+
/**
191+
* Description mentioning the purpose of the certificate.
192+
*/
193+
@query("certificate.purpose")
194+
certificatePurpose?: CertificatePurpose;
195+
196+
...CertificateNameQuery3;
197+
...CertificateNameQuery4;
198+
199+
/**
200+
* Indicates if the certificate contains private key.
201+
*/
202+
@query("certificate.hasPrivateKey")
203+
certificateHasPrivateKey?: boolean;
204+
205+
/**
206+
* Random number generated to indicate Proof of Possession.
207+
*/
208+
@query("certificate.nonce")
209+
certificateNonce?: string;
210+
},
211+
Error = ErrorDetails
212+
>;
213+
214+
/**
215+
* Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate.
216+
*/
217+
@action("verify")
218+
verifyCertificate is ArmResourceActionSync<
219+
CertificateResponse,
220+
VerificationCodeRequest,
221+
ArmResponse<CertificateResponse>,
222+
Parameters = {
223+
/**
224+
* ETag of the certificate.
225+
*/
226+
@header("If-Match")
227+
ifMatch: string;
228+
229+
...CertificateNameQuery1;
230+
231+
/**
232+
* Raw data of certificate.
233+
*/
234+
@query("certificate.rawBytes")
235+
certificateRawBytes?: bytes;
236+
237+
/**
238+
* Indicates if the certificate has been verified by owner of the private key.
239+
*/
240+
@query("certificate.isVerified")
241+
certificateIsVerified?: boolean;
242+
243+
/**
244+
* Describe the purpose of the certificate.
245+
*/
246+
@query("certificate.purpose")
247+
certificatePurpose?: CertificatePurpose;
248+
249+
...CertificateNameQuery3;
250+
...CertificateNameQuery4;
251+
252+
/**
253+
* Indicates if the certificate contains private key.
254+
*/
255+
@query("certificate.hasPrivateKey")
256+
certificateHasPrivateKey?: boolean;
257+
258+
/**
259+
* Random number generated to indicate Proof of Possession.
260+
*/
261+
@query("certificate.nonce")
262+
certificateNonce?: string;
263+
},
264+
Error = ErrorDetails
265+
>;
266+
}
267+
268+
@@doc(CertificateResponse.name, "Name of the certificate to retrieve.");
269+
@@doc(CertificateResponse.properties, "properties of a certificate");
270+
@@doc(CertificateResponses.createOrUpdate::parameters.resource,
271+
"The certificate body."
272+
);
273+
@@doc(CertificateResponses.verifyCertificate::parameters.body,
274+
"The name of the certificate"
275+
);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "./models.tsp";
6+
7+
using TypeSpec.Rest;
8+
using Azure.ResourceManager;
9+
using TypeSpec.Http;
10+
using TypeSpec.OpenAPI;
11+
12+
namespace Microsoft.Devices;
13+
/**
14+
* The group information for creating a private endpoint on a provisioning service
15+
*/
16+
@parentResource(ProvisioningServiceDescription)
17+
model GroupIdInformation
18+
is Azure.ResourceManager.ProxyResource<GroupIdInformationProperties, false> {
19+
...ResourceNameParameter<
20+
Resource = GroupIdInformation,
21+
KeyName = "groupId",
22+
SegmentName = "privateLinkResources",
23+
NamePattern = ""
24+
>;
25+
}
26+
27+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
28+
interface GroupIdInformationsOps
29+
extends Azure.ResourceManager.Legacy.LegacyOperations<
30+
{
31+
...ApiVersionParameter,
32+
...SubscriptionIdParameter,
33+
...ResourceGroupParameter,
34+
...Azure.ResourceManager.Legacy.Provider,
35+
36+
/**
37+
* Name of the provisioning service to retrieve.
38+
*/
39+
@path
40+
@segment("provisioningServices")
41+
resourceName: string,
42+
},
43+
{},
44+
ErrorDetails
45+
> {}
46+
47+
@armResourceOperations
48+
interface GroupIdInformations {
49+
/**
50+
* Get the specified private link resource for the given provisioning service
51+
*/
52+
getPrivateLinkResources is GroupIdInformationsOps.Read<
53+
GroupIdInformation,
54+
Parameters = {
55+
/**
56+
* The name of the private link resource
57+
*/
58+
@path
59+
@segment("privateLinkResources")
60+
groupId: string;
61+
},
62+
Response = ArmResponse<GroupIdInformation>
63+
>;
64+
65+
/**
66+
* List private link resources for the given provisioning service
67+
*/
68+
listPrivateLinkResources is GroupIdInformationsOps.List<
69+
GroupIdInformation,
70+
Response = ArmResponse<PrivateLinkResources>
71+
>;
72+
}
73+
74+
@@doc(GroupIdInformation.name, "The name of the private link resource");
75+
@@doc(GroupIdInformation.properties,
76+
"The properties for a group information object"
77+
);

0 commit comments

Comments
 (0)