Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Azure/typespec-azure into d…
Browse files Browse the repository at this point in the history
…ependabot/submodules/core-1edb744
  • Loading branch information
timotheeguerin committed Mar 7, 2025
2 parents 7355419 + abb6f19 commit 69303ec
Show file tree
Hide file tree
Showing 20 changed files with 587 additions and 294 deletions.
14 changes: 14 additions & 0 deletions .chronus/changes/change-workspace-ranges-2025-2-6-10-4-22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
changeKind: internal
packages:
- "@azure-tools/azure-http-specs"
- "@azure-tools/typespec-autorest-canonical"
- "@azure-tools/typespec-autorest"
- "@azure-tools/typespec-azure-core"
- "@azure-tools/typespec-azure-portal-core"
- "@azure-tools/typespec-azure-resource-manager"
- "@azure-tools/typespec-azure-rulesets"
- "@azure-tools/typespec-client-generator-core"
---

Updates pinning of workspace dependencies to ^ from ~
8 changes: 8 additions & 0 deletions .chronus/changes/specs_arm_error-2025-2-4-10-8-15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: feature
packages:
- "@azure-tools/azure-http-specs"
---

azure-http-specs, add ARM Exception test case
2 changes: 1 addition & 1 deletion eng/feeds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "",
"description": "",
"devDependencies": {
"@typespec/compiler": "workspace:~",
"@typespec/compiler": "workspace:^",
"vitest": "^3.0.7"
}
}
26 changes: 13 additions & 13 deletions packages/azure-http-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@
},
"homepage": "https://azure.github.io/typespec-azure",
"dependencies": {
"@typespec/spec-api": "workspace:~",
"@typespec/spector": "workspace:~"
"@typespec/spec-api": "workspace:^",
"@typespec/spector": "workspace:^"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "workspace:~",
"@azure-tools/typespec-azure-resource-manager": "workspace:~",
"@azure-tools/typespec-client-generator-core": "workspace:~",
"@azure-tools/typespec-autorest": "workspace:^",
"@azure-tools/typespec-azure-resource-manager": "workspace:^",
"@azure-tools/typespec-client-generator-core": "workspace:^",
"@types/multer": "^1.4.10",
"@types/node": "~22.13.9",
"@typespec/openapi": "workspace:~",
"@typespec/openapi3": "workspace:~",
"@typespec/openapi": "workspace:^",
"@typespec/openapi3": "workspace:^",
"concurrently": "^9.1.2",
"rimraf": "~6.0.1",
"typescript": "~5.8.2"
},
"peerDependencies": {
"@azure-tools/typespec-azure-core": "workspace:~",
"@typespec/compiler": "workspace:~",
"@typespec/http": "workspace:~",
"@typespec/rest": "workspace:~",
"@typespec/versioning": "workspace:~",
"@typespec/xml": "workspace:~"
"@azure-tools/typespec-azure-core": "workspace:^",
"@typespec/compiler": "workspace:^",
"@typespec/http": "workspace:^",
"@typespec/rest": "workspace:^",
"@typespec/versioning": "workspace:^",
"@typespec/xml": "workspace:^"
}
}
53 changes: 53 additions & 0 deletions packages/azure-http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,59 @@ maxpagesize=3
}
```

### Azure_ResourceManager_CommonProperties_Error_createForUserDefinedError

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

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/confidentialResources/confidential",
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": <any string>,
"properties": {
"username": "00"
}
}
```

Expected response status code: 400
Expected response body:

```json
{
"error": {
"code": "BadRequest",
"message": "Username should not contain only numbers.",
"innererror": {
"exceptiontype": "general"
}
}
}
```

### Azure_ResourceManager_CommonProperties_Error_getForPredefinedError

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

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/confidentialResources/confidential",
Expected query parameter: api-version=2023-12-01-preview

Expected response status code: 404
Expected response body:

```json
{
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Azure.ResourceManager.CommonProperties/confidentialResources/confidential' under resource group 'test-rg' was not found."
}
}
```

### Azure_ResourceManager_CommonProperties_ManagedIdentity_createWithSystemAssigned

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import "@typespec/http";
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/spector";

using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;
using Azure.ResourceManager;
using TypeSpec.OpenAPI;
using Spector;

namespace Azure.ResourceManager.CommonProperties;

@resource("confidentialResources")
model ConfidentialResource is TrackedResource<ConfidentialResourceProperties> {
...ResourceNameParameter<ConfidentialResource>;
}

@doc("Confidential Resource Properties.")
model ConfidentialResourceProperties {
@visibility(Lifecycle.Read)
@doc("The status of the last operation.")
provisioningState: string;

username: string;
}

/**
* Api error.
*/
model ApiError {
/**
* The Api error details
*/
details?: ApiErrorBase[];

/**
* The Api inner error
*/
innererror?: InnerError;

/**
* The error code.
*/
code?: string;

/**
* The target of the particular error.
*/
target?: string;

/**
* The error message.
*/
message?: string;
}

/**
* Api error base.
*/
model ApiErrorBase {
/**
* The error code.
*/
code?: string;

/**
* The target of the particular error.
*/
target?: string;

/**
* The error message.
*/
message?: string;
}

/**
* Inner error details.
*/
model InnerError {
/**
* The exception type.
*/
exceptiontype?: string;

/**
* The internal error message or exception dump.
*/
errordetail?: string;
}

/**
* An error response.
*/
@error
model CloudError {
/**
* Api error.
*/
error?: ApiError;
}

@armResourceOperations
interface Error {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/confidentialResources/confidential",
Expected query parameter: api-version=2023-12-01-preview
Expected response status code: 404
Expected response body:
```json
{
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Azure.ResourceManager.CommonProperties/confidentialResources/confidential' under resource group 'test-rg' was not found."
}
}
```
""")
getForPredefinedError is ArmResourceRead<ConfidentialResource>;

@scenario
@scenarioDoc("""
Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/confidentialResources/confidential",
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"location": <any string>,
"properties": {
"username": "00"
}
}
```
Expected response status code: 400
Expected response body:
```json
{
"error": {
"code": "BadRequest",
"message": "Username should not contain only numbers.",
"innererror": {
"exceptiontype": "general"
}
}
}
```
""")
createForUserDefinedError is ArmResourceCreateOrReplaceSync<
ConfidentialResource,
Error = CloudError
>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "./managed-identity.tsp";
import "./error.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
import { json, passOnCode, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

Expand Down Expand Up @@ -126,3 +126,58 @@ Scenarios.Azure_ResourceManager_CommonProperties_ManagedIdentity_updateWithUserA
},
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_CommonProperties_Error_getForPredefinedError = passOnCode(404, {
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.CommonProperties/confidentialResources/:resourceName",
method: "get",
request: {
params: {
subscriptionId: SUBSCRIPTION_ID_EXPECTED,
resourceGroup: RESOURCE_GROUP_EXPECTED,
resourceName: "confidential",
"api-version": "2023-12-01-preview",
},
status: 404,
},
response: {
status: 404,
body: json({
error: {
code: "ResourceNotFound",
message:
"The Resource 'Azure.ResourceManager.CommonProperties/confidentialResources/confidential' under resource group 'test-rg' was not found.",
},
}),
},
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_CommonProperties_Error_createForUserDefinedError = passOnCode(400, {
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.CommonProperties/confidentialResources/:resourceName",
method: "put",
request: {
body: {
properties: {
username: "00",
},
},
params: {
subscriptionId: SUBSCRIPTION_ID_EXPECTED,
resourceGroup: RESOURCE_GROUP_EXPECTED,
resourceName: "confidential",
"api-version": "2023-12-01-preview",
},
status: 400,
},
response: {
status: 400,
body: json({
code: "BadRequest",
message: "Username should not contain only numbers.",
innererror: {
exceptiontype: "general",
},
}),
},
kind: "MockApiDefinition",
});
2 changes: 1 addition & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build": ""
},
"devDependencies": {
"@typespec/compiler": "workspace:~",
"@typespec/compiler": "workspace:^",
"dotenv": "^16.4.7",
"typescript": "~5.8.2"
}
Expand Down
Loading

0 comments on commit 69303ec

Please sign in to comment.