Skip to content

Commit

Permalink
Creating a sample ARM sample project based on standard template (Azur…
Browse files Browse the repository at this point in the history
…e#30040)

* tsp init ARM sample project

* Update readme.md & output file name

* Adding sample SDK config

* Added SDK emitter configs

* Removed arm schema from SDK automation config

* Update tspconfig.yaml

* Update readme.python.md

* Update readme.python.md

* Update tspconfig.yaml

* Remove the optional options for TS emitter

* Update tspconfig.yaml

* use custom patch

* remove swagger to sdk section and config

---------

Co-authored-by: Ray Chen <[email protected]>
Co-authored-by: Yuchao Yan <[email protected]>
Co-authored-by: kazrael2119 <[email protected]>
Co-authored-by: Renhe Li <[email protected]>
Co-authored-by: qiaozha <[email protected]>
Co-authored-by: Qiaoqiao Zhang <[email protected]>
  • Loading branch information
7 people authored Aug 2, 2024
1 parent ad73e42 commit c4b3316
Show file tree
Hide file tree
Showing 19 changed files with 1,330 additions and 0 deletions.
69 changes: 69 additions & 0 deletions specification/contosowidgetmanager/Contoso.Management/employee.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import "@typespec/rest";
import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.Core;
using Azure.ResourceManager;

namespace Microsoft.Contoso;

/** Employee resource */
model Employee is TrackedResource<EmployeeProperties> {
...ResourceNameParameter<Employee>;
}

/** Employee properties */
model EmployeeProperties {
/** Age of employee */
age?: int32;

/** City of employee */
city?: string;

/** Profile of employee */
@encode("base64url")
profile?: bytes;

/** The status of the last operation. */
@visibility("read")
provisioningState?: ProvisioningState;
}

/** The resource provisioning state. */
@lroStatus
union ProvisioningState {
ResourceProvisioningState,

/** The resource is being provisioned */
Provisioning: "Provisioning",

/** The resource is updating */
Updating: "Updating",

/** The resource is being deleted */
Deleting: "Deleting",

/** The resource create request has been accepted */
Accepted: "Accepted",

string,
}

@armResourceOperations
interface Employees {
get is ArmResourceRead<Employee>;
createOrUpdate is ArmResourceCreateOrReplaceAsync<Employee>;
update is ArmCustomPatchSync<
Employee,
Azure.ResourceManager.Foundations.ResourceUpdateModel<
Employee,
EmployeeProperties
>
>;
delete is ArmResourceDeleteWithoutOkAsync<Employee>;
listByResourceGroup is ArmResourceListByParent<Employee>;
listBySubscription is ArmListBySubscription<Employee>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"title": "Employees_CreateOrUpdate",
"operationId": "Employees_CreateOrUpdate",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "9KF-f-8b",
"resource": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl"
}
},
"responses": {
"200": {
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
},
"201": {
"headers": {
"Azure-AsyncOperation": "https://contoso.com/operationstatus"
},
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/9KF-f-8b",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"title": "Employees_Delete",
"operationId": "Employees_Delete",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "5vX--BxSu3ux48rI4O9OQ569"
},
"responses": {
"202": {
"headers": {
"Retry-After": 30,
"location": "https://contoso.com/operationstatus"
}
},
"204": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"title": "Employees_Get",
"operationId": "Employees_Get",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "le-8MU--J3W6q8D386p3-iT3"
},
"responses": {
"200": {
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"title": "Employees_ListByResourceGroup",
"operationId": "Employees_ListByResourceGroup",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi"
},
"responses": {
"200": {
"body": {
"value": [
{
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
],
"nextLink": "https://microsoft.com/a"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"title": "Employees_ListBySubscription",
"operationId": "Employees_ListBySubscription",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9"
},
"responses": {
"200": {
"body": {
"value": [
{
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
],
"nextLink": "https://microsoft.com/a"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"title": "Employees_Update",
"operationId": "Employees_Update",
"parameters": {
"api-version": "2021-10-01-preview",
"subscriptionId": "11809CA1-E126-4017-945E-AA795CD5C5A9",
"resourceGroupName": "rgopenapi",
"employeeName": "-XhyNJ--",
"properties": {
"tags": {
"key7952": "no"
},
"properties": {
"age": 24,
"city": "uyfg",
"profile": "oapgijcswfkruiuuzbwco"
}
}
},
"responses": {
"200": {
"body": {
"properties": {
"age": 30,
"city": "gydhnntudughbmxlkyzrskcdkotrxn",
"profile": "ms",
"provisioningState": "Succeeded"
},
"tags": {
"key2913": "urperxmkkhhkp"
},
"location": "itajgxyqozseoygnl",
"id": "/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/contoso/providers/Microsoft.Contoso/employees/test",
"name": "xepyxhpb",
"type": "svvamxrdnnv",
"systemData": {
"createdBy": "iewyxsnriqktsvp",
"createdByType": "User",
"createdAt": "2023-05-19T00:28:48.610Z",
"lastModifiedBy": "xrchbnnuzierzpxw",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-05-19T00:28:48.610Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": "Operations_List",
"operationId": "Operations_List",
"parameters": {
"api-version": "2021-10-01-preview"
},
"responses": {
"200": {
"body": {
"value": [
{
"name": "ymeow",
"isDataAction": true,
"display": {
"provider": "qxyznq",
"resource": "bqfwkox",
"operation": "td",
"description": "yvgkhsuwartgxb"
},
"origin": "user",
"actionType": "Internal"
}
],
"nextLink": "https://sample.com/nextLink"
}
}
}
}
31 changes: 31 additions & 0 deletions specification/contosowidgetmanager/Contoso.Management/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "@typespec/http";
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "./employee.tsp";

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

/** Microsoft.Contoso Resource Provider management API. */
@armProviderNamespace
@service({
title: "Microsoft.Contoso management service",
})
@versioned(Microsoft.Contoso.Versions)
namespace Microsoft.Contoso;

/** The available API versions. */
enum Versions {
/** 2021-10-01-preview version */
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
v2021_10_01_preview: "2021-10-01-preview",
}

interface Operations extends Azure.ResourceManager.Operations {}
Loading

0 comments on commit c4b3316

Please sign in to comment.