Skip to content

Commit

Permalink
Fixed comment Azure#713 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 committed Aug 28, 2024
1 parent 15ef204 commit 1e5a35e
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 292 deletions.
132 changes: 30 additions & 102 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,36 @@ Expected response body:
}
```

### Azure_ResourceManager_Models_Resources_ListingAvailableOperations_list

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /providers/Azure.ResourceManager.Models.Resources/operations
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [
{
"name": "Microsoft.Compute/virtualMachines/write",
"isDataAction": true,
"display": {
"provider": "Microsoft Compute",
"resource": "Virtual Machines",
"operation": "Create or Update Virtual Machine.",
"description": "Add or modify virtual machines."
},
"origin": "user,system",
"actionType": "Internal"
}
],
"nextLink": "Azure.ResourceManager.Models.Resources/operations?api-version=2023-12-01-preview"
}
```

### Azure_ResourceManager_Models_Resources_NestedProxyResources_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down Expand Up @@ -1056,108 +1086,6 @@ Expected response body:
}
```

### Azure_ResourceManager_Models_Resources_OperationStatuses_getRgStatus

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"name": "ResourceGroupOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
}
```

### Azure_ResourceManager_Models_Resources_OperationStatuses_getStatus

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"name": "TenantOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
}
```

### Azure_ResourceManager_Models_Resources_OperationStatuses_getSubscriptionStatus

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"name": "SubscriptionOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
}
```

### Azure_ResourceManager_Models_Resources_SingletonTrackedResources_createOrUpdate

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,114 +39,32 @@ union ProvisioningState {
Accepted: "Accepted",
}

@resource("operationStatuses")
@parentResource(TenantLocationResource)
model TenantOperationStatus is ArmOperationStatus;

@parentResource(SubscriptionLocationResource)
model SubscriptionOperationStatus is ArmOperationStatus;

@parentResource(ResourceGroupLocationResource)
model ResourceGroupOperationStatus is ArmOperationStatus;

@armResourceOperations
interface OperationStatuses {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected query parameter: api-version=2023-12-01-preview
Expected response body:
```json
{
"name": "TenantOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
}
```
""")
getStatus is ArmResourceRead<TenantOperationStatus>;

@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected query parameter: api-version=2023-12-01-preview
Expected response body:
```json
{
"name": "SubscriptionOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
}
```
""")
getSubscriptionStatus is ArmResourceRead<SubscriptionOperationStatus>;

interface ListingAvailableOperations {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/westus/operationStatuses/00000000-0000-0000-0000-000000000000
Expected path: /providers/Azure.ResourceManager.Models.Resources/operations
Expected query parameter: api-version=2023-12-01-preview
Expected response body:
```json
{
"name": "ResourceGroupOperation",
"startTime": <any date>,
"endTime": <any date>,
"percentComplete": 2,
"status": "Failed",
"ManagementError": {
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
"details": [{
"code": "404",
"message": "The error message of status test. ",
"target": "The target of status test.",
}],
"additionalInfo": [{
"type": "additionalType",
"info": "additionalInfo"
}]
}
"value": [{
"name": "Microsoft.Compute/virtualMachines/write",
"isDataAction": true,
"display": {
"provider": "Microsoft Compute",
"resource": "Virtual Machines",
"operation": "Create or Update Virtual Machine.",
"description": "Add or modify virtual machines."
},
"origin": "user,system",
"actionType": "Internal"
}],
"nextLink": "Azure.ResourceManager.Models.Resources/operations?api-version=2023-12-01-preview",
}
```
""")
getRgStatus is ArmResourceRead<ResourceGroupOperationStatus>;
list is Operations.list;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,101 +63,30 @@ const validSingletonResource = {
},
};

const validOperationStatus = {
name: "TenantOperation",
startTime: new Date(),
endTime: new Date(),
percentComplete: 2,
status: "Failed",
ManagementError: {
code: "404",
message: "The error message of status test. ",
target: "The target of status test.",
details: [
{
code: "404",
message: "The error message of status test. ",
target: "The target of status test.",
},
],
additionalInfo: [
{
type: "additionalType",
info: "additionalInfo",
},
],
const validAvailableOperations = {
name: "Microsoft.Compute/virtualMachines/write",
isDataAction: true,
display: {
provider: "Microsoft Compute",
resource: "Virtual Machines",
operation: "Create or Update Virtual Machine.",
description: "Add or modify virtual machines.",
},
origin: "user,system",
actionType: "Internal",
};

// operation status
Scenarios.Azure_ResourceManager_Models_Resources_OperationStatuses_getStatus = passOnSuccess([
mockapi.get(
"/providers/Azure.ResourceManager.Models.Resources/locations/:location/operationStatuses/:operationId",
(req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.location !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected location", LOCATION_EXPECTED, req.params.location);
}
if (req.params.operationId !== OPERATION_ID_EXPECTED) {
throw new ValidationError("Unexpected operationId", OPERATION_ID_EXPECTED, req.params.operationId);
}
return {
status: 200,
body: json(validOperationStatus),
};
},
),
]);

Scenarios.Azure_ResourceManager_Models_Resources_OperationStatuses_getSubscriptionStatus = passOnSuccess([
mockapi.get(
"/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Models.Resources/locations/:location/operationStatuses/:operationId",
(req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) {
throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId);
}
if (req.params.location !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected location", LOCATION_EXPECTED, req.params.location);
}
if (req.params.operationId !== OPERATION_ID_EXPECTED) {
throw new ValidationError("Unexpected operationId", OPERATION_ID_EXPECTED, req.params.operationId);
}
const resource = JSON.parse(JSON.stringify(validOperationStatus));
resource.name = "SubscriptionOperation";
return {
status: 200,
body: json(resource),
};
},
),
]);

Scenarios.Azure_ResourceManager_Models_Resources_OperationStatuses_getRgStatus = passOnSuccess([
mockapi.get(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/operationStatuses/:operationId",
(req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) {
throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId);
}
if (req.params.resourceGroup.toLowerCase() !== RESOURCE_GROUP_EXPECTED) {
throw new ValidationError("Unexpected resourceGroup", RESOURCE_GROUP_EXPECTED, req.params.resourceGroup);
}
if (req.params.location !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected location", LOCATION_EXPECTED, req.params.location);
}
if (req.params.operationId !== OPERATION_ID_EXPECTED) {
throw new ValidationError("Unexpected operationId", OPERATION_ID_EXPECTED, req.params.operationId);
}
const resource = JSON.parse(JSON.stringify(validOperationStatus));
resource.name = "ResourceGroupOperation";
return {
status: 200,
body: json(resource),
};
},
),
// operation list
Scenarios.Azure_ResourceManager_Models_Resources_ListingAvailableOperations_list = passOnSuccess([
mockapi.get("/providers/Azure.ResourceManager.Models.Resources/operations", (req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
return {
status: 200,
body: json({
value: [validAvailableOperations],
}),
};
}),
]);

// singleton tracked resource
Expand Down

0 comments on commit 1e5a35e

Please sign in to comment.