Skip to content

Commit de58f9e

Browse files
authored
tsp - Add test case for databox (#1533)
1 parent a0746c6 commit de58f9e

File tree

1,542 files changed

+282731
-20
lines changed

Some content is hidden

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

1,542 files changed

+282731
-20
lines changed

packages/typespec-powershell/src/utils/modelUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ function getSchemaForModel(
989989
} else {
990990
// If discriminator value is union variant, it will be constant type
991991
// Otherwise, it will be sealed choice type
992-
modelSchema.discriminatorValue = propSchema.type === 'constant' ? (<ConstantSchema>propSchema).value.value : (<SealedChoiceSchema>propSchema).choices[0].value.toString();
992+
modelSchema.discriminatorValue = propSchema.type === 'constant' ? (<ConstantSchema>propSchema).value.value : (propSchema.value ? propSchema.value : (<SealedChoiceSchema>propSchema).choices[0].value.toString());
993993
}
994994
if (discriminator && propName === discriminator.propertyName) {
995995
property.isDiscriminator = true;
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
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.DataBox;
13+
/**
14+
* Job Resource.
15+
*/
16+
model JobResource
17+
is Azure.ResourceManager.TrackedResource<JobProperties, false> {
18+
...ResourceNameParameter<
19+
Resource = JobResource,
20+
KeyName = "jobName",
21+
SegmentName = "jobs",
22+
NamePattern = "^[-\\w\\.]+$"
23+
>;
24+
25+
/**
26+
* The sku type.
27+
*/
28+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
29+
sku: Sku;
30+
31+
/**
32+
* Msi identity of the resource
33+
*/
34+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
35+
identity?: ResourceIdentity;
36+
}
37+
38+
@armResourceOperations
39+
interface JobResources {
40+
/**
41+
* Gets information about the specified job.
42+
*/
43+
get is ArmResourceRead<
44+
JobResource,
45+
Parameters = {
46+
/**
47+
* $expand is supported on details parameter for job, which provides details on the job stages.
48+
*/
49+
@query("$expand")
50+
$expand?: string;
51+
},
52+
Error = ApiError
53+
>;
54+
55+
/**
56+
* Creates a new job with the specified parameters. Existing job cannot be updated with this API and should instead be updated with the Update job API.
57+
*/
58+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
59+
create is ArmResourceCreateOrReplaceAsync<
60+
JobResource,
61+
Response = ArmResourceUpdatedResponse<JobResource> | ArmAcceptedLroResponse<LroHeaders = ArmLroLocationHeader<FinalResult = JobResource> &
62+
Azure.Core.Foundations.RetryAfterHeader>,
63+
Error = ApiError
64+
>;
65+
66+
/**
67+
* Updates the properties of an existing job.
68+
*/
69+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-patch" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
70+
@patch(#{ implicitOptionality: false })
71+
update is ArmCustomPatchAsync<
72+
JobResource,
73+
PatchModel = JobResourceUpdateParameter,
74+
Parameters = {
75+
/**
76+
* Defines the If-Match condition. The patch will be performed only if the ETag of the job on the server matches this value.
77+
*/
78+
#suppress "@azure-tools/typespec-azure-core/casing-style" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
79+
@header("If-Match")
80+
`If-Match`?: string;
81+
},
82+
Error = ApiError
83+
>;
84+
85+
/**
86+
* Deletes a job.
87+
*/
88+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
89+
delete is ArmResourceDeleteWithoutOkAsync<
90+
JobResource,
91+
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse,
92+
Error = ApiError
93+
>;
94+
95+
/**
96+
* Lists all the jobs available under the given resource group.
97+
*/
98+
listByResourceGroup is ArmResourceListByParent<
99+
JobResource,
100+
Parameters = {
101+
/**
102+
* $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs.
103+
*/
104+
@query("$skipToken")
105+
$skipToken?: string;
106+
},
107+
Response = ArmResponse<JobResourceList>,
108+
Error = ApiError
109+
>;
110+
111+
/**
112+
* Lists all the jobs available under the subscription.
113+
*/
114+
list is ArmListBySubscription<
115+
JobResource,
116+
Parameters = {
117+
/**
118+
* $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs.
119+
*/
120+
@query("$skipToken")
121+
$skipToken?: string;
122+
},
123+
Response = ArmResponse<JobResourceList>,
124+
Error = ApiError
125+
>;
126+
127+
/**
128+
* Book shipment pick up.
129+
*/
130+
bookShipmentPickUp is ArmResourceActionSync<
131+
JobResource,
132+
ShipmentPickUpRequest,
133+
ArmResponse<ShipmentPickUpResponse>,
134+
Error = ApiError
135+
>;
136+
137+
/**
138+
* CancelJob.
139+
*/
140+
cancel is ArmResourceActionSync<
141+
JobResource,
142+
CancellationReason,
143+
NoContentResponse,
144+
Error = ApiError
145+
>;
146+
147+
/**
148+
* This method gets the unencrypted secrets related to the job.
149+
*/
150+
@list
151+
listCredentials is ArmResourceActionSync<
152+
JobResource,
153+
void,
154+
ArmResponse<UnencryptedCredentialsList>,
155+
Error = ApiError
156+
>;
157+
158+
/**
159+
* Request to mark devices for a given job as shipped
160+
*/
161+
markDevicesShipped is ArmResourceActionSync<
162+
JobResource,
163+
MarkDevicesShippedRequest,
164+
NoContentResponse,
165+
Error = ApiError
166+
>;
167+
}
168+
169+
/**
170+
* Request to mitigate for a given job
171+
*/
172+
@action("mitigate")
173+
@tag("JobResources")
174+
op mitigate is ArmResourceActionSync<
175+
JobResource,
176+
MitigateJobRequest,
177+
NoContentResponse,
178+
Error = ApiError
179+
>;
180+
181+
@@maxLength(JobResource.name, 24);
182+
@@minLength(JobResource.name, 3);
183+
@@doc(JobResource.name,
184+
"The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only"
185+
);
186+
@@doc(JobResource.properties, "Properties of a job.");
187+
@@doc(JobResources.create::parameters.resource,
188+
"Job details from request body."
189+
);
190+
@@doc(JobResources.update::parameters.properties,
191+
"Job update parameters from request body."
192+
);
193+
@@doc(JobResources.bookShipmentPickUp::parameters.body,
194+
"Details of shipment pick up request."
195+
);
196+
@@doc(JobResources.cancel::parameters.body, "Reason for cancellation.");
197+
@@doc(JobResources.markDevicesShipped::parameters.body,
198+
"Mark Devices Shipped Request"
199+
);
200+
@@doc(mitigate::parameters.body, "Mitigation Request");
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.DataBox;
5+
6+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
7+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(AddressValidationOutput.properties,
8+
"!csharp"
9+
);
10+
11+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
12+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(ValidationResponse.properties
13+
);
14+
15+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
16+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(JobResourceUpdateParameter.properties
17+
);
18+
19+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
20+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(SkuInformation.properties);
21+
22+
@@clientLocation(JobResources.get, "Jobs", "!csharp");
23+
24+
@@clientLocation(JobResources.create, "Jobs", "!csharp");
25+
26+
@@clientName(JobResources.create::parameters.resource, "jobResource");
27+
28+
@@clientLocation(JobResources.update, "Jobs", "!csharp");
29+
30+
@@clientName(JobResources.update::parameters.properties,
31+
"jobResourceUpdateParameter"
32+
);
33+
34+
@@clientLocation(JobResources.delete, "Jobs", "!csharp");
35+
36+
@@clientLocation(JobResources.listByResourceGroup, "Jobs", "!csharp");
37+
38+
@@clientLocation(JobResources.list, "Jobs", "!csharp");
39+
40+
@@clientLocation(JobResources.bookShipmentPickUp, "Jobs", "!csharp");
41+
42+
@@clientName(JobResources.bookShipmentPickUp::parameters.body,
43+
"shipmentPickUpRequest"
44+
);
45+
46+
@@clientLocation(JobResources.cancel, "Jobs", "!csharp");
47+
48+
@@clientName(JobResources.cancel::parameters.body, "cancellationReason");
49+
50+
@@clientLocation(JobResources.listCredentials, "Jobs", "!csharp");
51+
52+
@@clientLocation(JobResources.markDevicesShipped, "Jobs", "!csharp");
53+
54+
@@clientName(JobResources.markDevicesShipped::parameters.body,
55+
"markDevicesShippedRequest"
56+
);
57+
58+
@@clientName(mitigate::parameters.body, "mitigateJobRequest");
59+
60+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
61+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(JobResource.properties);
62+
63+
@@clientLocation(ServiceOperationGroup.regionConfiguration,
64+
"Service",
65+
"!csharp"
66+
);
67+
68+
@@clientLocation(ServiceOperationGroup.validateAddress, "Service", "!csharp");
69+
70+
@@clientLocation(ServiceOperationGroup.validateInputs, "Service", "!csharp");
71+
72+
@@clientLocation(ServiceOperationGroup.listAvailableSkusByResourceGroup,
73+
"Service",
74+
"!csharp"
75+
);
76+
77+
@@clientLocation(ServiceOperationGroup.regionConfigurationByResourceGroup,
78+
"Service",
79+
"!csharp"
80+
);
81+
82+
@@clientLocation(ServiceOperationGroup.validateInputsByResourceGroup,
83+
"Service",
84+
"!csharp"
85+
);
86+
87+
@@clientName(ServiceOperationGroup.regionConfiguration::parameters.body,
88+
"regionConfigurationRequest"
89+
);
90+
@@clientName(ServiceOperationGroup.validateAddress::parameters.body,
91+
"validateAddress"
92+
);
93+
@@clientName(ServiceOperationGroup.validateInputs::parameters.body,
94+
"validationRequest"
95+
);
96+
97+
@@clientLocation(mitigate, "Management", "go");
98+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
99+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(Operation.properties);

0 commit comments

Comments
 (0)