-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Adding cadl sample project #21722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Adding cadl sample project #21722
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d82ebd9
Adding cadl sample project
raych1 1f66627
cadl sample: packaqe.json & cadl-project.yaml (#21903)
dw511214992 9b110a2
Use faked shared model
raych1 2d0bf4e
Update documentation/cadl-sample-project/specification/contosowidgetm…
raych1 92c1e51
Update cadl-project.yaml
dw511214992 1a3d8ea
Adjusted to minimum file set
raych1 4124164
update .Net emitter configuration
dw511214992 040a6d2
update java emitter config
dw511214992 7fa10dd
Fixed examples issues
raych1 c7af4a5
Fixed example style issue
raych1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...-sample-project/specification/contosowidgetmanager/Contoso.WidgetManager.Shared/main.cadl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @doc("Faked shared model") | ||
| model FakedSharedModel { | ||
| @doc("The tag.") | ||
| tag: string; | ||
|
|
||
| @doc("The created date.") | ||
| createdDate: zonedDateTime; | ||
| } |
36 changes: 36 additions & 0 deletions
36
...sample-project/specification/contosowidgetmanager/Contoso.WidgetManager/cadl-project.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| parameters: | ||
| "python-sdk-folder": | ||
| default: "{cwd}/azure-sdk-for-python/" | ||
| "java-sdk-folder": | ||
| default: "{cwd}/azure-sdk-for-java/" | ||
| "js-sdk-folder": | ||
| default: "{cwd}/azure-sdk-for-js/" | ||
| "csharp-sdk-folder": | ||
| default: "{cwd}/azure-sdk-for-csharp/" | ||
| "service-directory-name": | ||
| default: "contosowidgetmanager" | ||
| emit: | ||
| - "@azure-tools/cadl-autorest" | ||
| options: | ||
| "@azure-tools/cadl-autorest": | ||
| output-file: widgets.json | ||
| azure-resource-provider-folder: ../../../../data-plane | ||
raych1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| examples-directory: ./examples | ||
| "@azure-tools/cadl-python": | ||
| "package-name": "azure-contosowidgetmanager" | ||
| "emitter-output-dir": "{python-sdk-folder}/sdk/{service-directory-name}/{package-name}" | ||
| "package-mode": "dataplane" | ||
| "@azure-tools/cadl-csharp": | ||
| namespace: Azure.Contoso.Widgetmanager | ||
| "emitter-output-dir": "{csharp-sdk-folder}/sdk/{service-directory-name}/{namespace}/src" | ||
| "@azure-tools/cadl-typescript": | ||
| "emitter-output-dir": "{js-sdk-folder}/sdk/{service-directory-name}/contosowidgetmanager-rest" | ||
| generateMetadata: true | ||
| generateTest: true | ||
| azureSdkForJs: true | ||
| packageDetails: | ||
| name: "@azure-rest/contosowidgetmanager-rest" | ||
| description: "Contoso WidgetManager Service" | ||
| "@azure-tools/cadl-java": | ||
| "emitter-output-dir": "{java-sdk-folder}/sdk/{service-directory-name}/azure-contoso-widgetmanager" | ||
| namespace: com.azure.contosowidgetmanager | ||
25 changes: 25 additions & 0 deletions
25
...manager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_DeleteWidgetSample.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "operationId": "Widgets_DeleteWidget", | ||
| "title": "Delete widget by widget name using long-running operation.", | ||
| "parameters": { | ||
| "api-version": "2022-11-01-preview", | ||
| "widgetName": "searchbox" | ||
| }, | ||
| "responses": { | ||
| "204": {}, | ||
| "202": { | ||
| "headers": { | ||
| "location": "https://contosowidgetmanager.azure.com/operations/00000000-0000-0000-0000-000000000123/result?api-version=2022-11-01-preview", | ||
| "operation-location": "https://contosowidgetmanager.azure.com/operations/00000000-0000-0000-0000-000000000123?api-version=2022-11-01-preview" | ||
| } | ||
| }, | ||
| "default": { | ||
| "body": { | ||
| "error": { | ||
| "code": "Error code", | ||
| "message": "Error message" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...getmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetSample.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "operationId": "Widgets_GetWidget", | ||
| "title": "Get widget by widget name.", | ||
| "parameters": { | ||
| "api-version": "2022-11-01-preview", | ||
| "widgetName": "searchbox" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "bingsearch", | ||
| "manufacturerId": "a-22-01" | ||
| } | ||
| }, | ||
| "default": { | ||
| "body": { | ||
| "error": { | ||
| "code": "Error code", | ||
| "message": "Error message" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
...on/cadl-sample-project/specification/contosowidgetmanager/Contoso.WidgetManager/main.cadl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import "@cadl-lang/rest"; | ||
| import "@cadl-lang/versioning"; | ||
| import "@azure-tools/cadl-azure-core"; | ||
| import "../Contoso.WidgetManager.Shared"; | ||
|
|
||
| using Cadl.Http; | ||
| using Cadl.Rest; | ||
| using Cadl.Versioning; | ||
| using Azure.Core; | ||
|
|
||
| @service({ | ||
| title: "Contoso Widget Manager", | ||
| }) | ||
| @versioned(Contoso.WidgetManager.Versions) | ||
| @versionedDependency([[Contoso.WidgetManager.Versions.v2022_11_01_Preview, Azure.Core.Versions.v1_0_Preview_1]]) | ||
| namespace Azure.Contoso.WidgetManager; | ||
|
|
||
| enum Versions { | ||
| v2022_11_01_Preview: "2022-11-01-preview", | ||
| } | ||
|
|
||
| @doc("A widget.") | ||
| @resource("widgets") | ||
| model Widget { | ||
| @key("widgetName") | ||
| @doc("The widget name.") | ||
| @visibility("read") | ||
| name: string; | ||
|
|
||
| @doc("The ID of the widget's manufacturer.") | ||
| manufacturerId: string; | ||
|
|
||
| @doc("The faked shared model.") | ||
| sharedModel?: FakedSharedModel; | ||
| } | ||
|
|
||
| interface Widgets { | ||
| @doc("Fetch a Widget by name.") | ||
| getWidget is ResourceRead<Widget>; | ||
|
|
||
| @doc("Gets status of a Widget operation.") | ||
| getWidgetOperationStatus is GetResourceOperationStatus<Widget>; | ||
|
|
||
| @doc("Creates or updates a Widget asynchronously.") | ||
| @pollingOperation(Widgets.getWidgetOperationStatus) | ||
| createOrUpdateWidget is LongRunningResourceCreateOrUpdate<Widget>; | ||
|
|
||
| @doc("Delete a Widget asynchronously.") | ||
| @pollingOperation(Widgets.getWidgetOperationStatus) | ||
| deleteWidget is LongRunningResourceDelete<Widget>; | ||
|
|
||
| @doc("List Widget resources") | ||
| listWidgets is ResourceList< | ||
| Widget, | ||
| { | ||
| parameters: StandardListQueryParameters & SelectQueryParameter; | ||
| } | ||
| >; | ||
| } |
7 changes: 7 additions & 0 deletions
7
...cadl-sample-project/specification/contosowidgetmanager/Contoso.WidgetManager/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "contoso-widget-manager", | ||
| "dependencies": { | ||
| "@azure-tools/cadl-autorest": "latest" | ||
| }, | ||
| "private": true | ||
| } |
25 changes: 25 additions & 0 deletions
25
...Contoso.WidgetManager/preview/2022-11-01-preview/examples/Widgets_DeleteWidgetSample.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "operationId": "Widgets_DeleteWidget", | ||
| "title": "Delete widget by widget name using long-running operation.", | ||
| "parameters": { | ||
| "api-version": "2022-11-01-preview", | ||
| "widgetName": "searchbox" | ||
| }, | ||
| "responses": { | ||
| "204": {}, | ||
| "202": { | ||
| "headers": { | ||
| "location": "https://contosowidgetmanager.azure.com/operations/00000000-0000-0000-0000-000000000123/result?api-version=2022-11-01-preview", | ||
| "operation-location": "https://contosowidgetmanager.azure.com/operations/00000000-0000-0000-0000-000000000123?api-version=2022-11-01-preview" | ||
| } | ||
| }, | ||
| "default": { | ||
| "body": { | ||
| "error": { | ||
| "code": "Error code", | ||
| "message": "Error message" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...re.Contoso.WidgetManager/preview/2022-11-01-preview/examples/Widgets_GetWidgetSample.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "operationId": "Widgets_GetWidget", | ||
| "title": "Get widget by widget name.", | ||
| "parameters": { | ||
| "api-version": "2022-11-01-preview", | ||
| "widgetName": "searchbox" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "bingsearch", | ||
| "manufacturerId": "a-22-01" | ||
| } | ||
| }, | ||
| "default": { | ||
| "body": { | ||
| "error": { | ||
| "code": "Error code", | ||
| "message": "Error message" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.