Skip to content

Creating a sample ARM sample project based on standard template #30040

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 17 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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 ArmResourcePatchSync<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