Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
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
182 changes: 69 additions & 113 deletions specification/edge/Microsoft.Edge.Sites.Management/Site.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,151 +9,107 @@ import "./main.tsp";
using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;
using TypeSpec.Versioning;

namespace Microsoft.Edge;

@doc("Site as ARM Resource")
model Site is ProxyResource<SiteProperties> {
#suppress "@typespec/http/metadata-ignored" ""
@doc("Name of Site resource")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$")
@path
@key("siteName")
@segment("sites")
@visibility(Lifecycle.Read)
name: string;
...ResourceNameParameter<
Resource = Site,
KeyName = "siteName",
SegmentName = "sites",
NamePattern = "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
>;
}

alias SiteOps = Azure.ResourceManager.Legacy.LegacyOperations<
{
...ApiVersionParameter;
...SubscriptionIdParameter;
...ResourceGroupParameter;
...Azure.ResourceManager.Legacy.Provider;
},
KeysOf<Site>
>;

@armResourceOperations
interface Sites {
get is ArmResourceRead<Site>;
createOrUpdate is ArmResourceCreateOrReplaceAsync<Site>;
update is ArmCustomPatchSync<Site, SiteUpdate>;
delete is ArmResourceDeleteSync<Site>;
listByResourceGroup is ArmResourceListByParent<Site>;
get is SiteOps.Read<Site>;
createOrUpdate is SiteOps.CreateOrUpdateAsync<Site>;
update is SiteOps.CustomPatchSync<Site, SiteUpdate>;
delete is SiteOps.DeleteSync<Site>;
listByResourceGroup is SiteOps.List<Site>;
}

alias SubscriptionParameters = Azure.ResourceManager.Foundations.SubscriptionBaseParameters;
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" "Custom operation on the scope of subscription"
alias SiteBySubscriptionOps = Azure.ResourceManager.Legacy.LegacyOperations<
{
...ApiVersionParameter;
...SubscriptionIdParameter;
...Azure.ResourceManager.Legacy.Provider;
},
KeysOf<Site>
>;

@armResourceOperations(#{ omitTags: true })
interface SitesBySubscription {
list is ArmListBySubscription<Site>;
get is ArmResourceRead<Site, BaseParameters = SubscriptionParameters>;
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Site,
BaseParameters = SubscriptionParameters
>;
update is ArmCustomPatchSync<
Site,
SiteUpdate,
BaseParameters = SubscriptionParameters
>;
delete is ArmResourceDeleteSync<
Site,
BaseParameters = SubscriptionParameters
>;
/** List Site resources by subscription ID */
list is SiteBySubscriptionOps.List<Site>;
get is SiteBySubscriptionOps.Read<Site>;
createOrUpdate is SiteBySubscriptionOps.CreateOrUpdateAsync<Site>;
update is SiteBySubscriptionOps.CustomPatchSync<Site, SiteUpdate>;
delete is SiteBySubscriptionOps.DeleteSync<Site>;
}

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" "Custom operation on the scope of Tenant"
alias SiteByServiceGroupOps = Azure.ResourceManager.Legacy.ExtensionOperations<
{
...ApiVersionParameter;

/** the provider namespace */
@path
@segment("providers")
@key
providerNamespace: "Microsoft.Management";

/**
* The name of the service group
*/
@segment("serviceGroups")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
@key
@path
servicegroupName: string;
},
Extension.ExtensionProviderNamespace<Site>,
{
...Extension.ExtensionProviderNamespace<Site>;
...KeysOf<Site>;
}
>;

@armResourceOperations(#{ omitTags: true })
interface SitesByServiceGroup {
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Custom operation for tenant scope"
@route("/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites")
@doc("list Site at SG scope")
@added(Versions.v2025_03_01_preview)
@list
listByServiceGroup(
...ApiVersionParameter,
listByServiceGroup is SiteByServiceGroupOps.List<Site>;

@path
@doc("The name of the service group")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
servicegroupName: string,
): ArmResponse<ResourceListResult<Site>> | ErrorResponse;

@route("/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}")
@doc("Get Site at SG scope")
@added(Versions.v2025_03_01_preview)
get(
...ApiVersionParameter,

@path
@doc("The name of the service group")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
servicegroupName: string,

@path
@doc("The name of the site")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$")
siteName: string,
): ArmResponse<Site> | ErrorResponse;
get is SiteByServiceGroupOps.Read<Site>;

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "custom PUT call"
@route("/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}")
@put
@doc("create or update Site at SG scope")
@added(Versions.v2025_03_01_preview)
createOrUpdate(
...ApiVersionParameter,
createOrUpdate is SiteByServiceGroupOps.CreateOrUpdateAsync<Site>;

@path
@doc("The name of the service group")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
servicegroupName: string,

@path
@doc("The name of the site")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$")
siteName: string,

@body
@doc("The properties of the site")
resource: Site,
): ArmResourceUpdatedResponse<Site> | ArmResourceCreatedResponse<
Site,
ArmAsyncOperationHeader<FinalResult = Site> &
Azure.Core.Foundations.RetryAfterHeader
> | ErrorResponse;

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "custom PATCH call"
@route("/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}")
@patch(#{ implicitOptionality: true })
@doc("update Site at SG scope")
@added(Versions.v2025_03_01_preview)
update(
...ApiVersionParameter,

@path
@doc("The name of the service group")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
servicegroupName: string,
update is SiteByServiceGroupOps.CustomPatchSync<Site, SiteUpdate>;

@path
@doc("The name of the site")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$")
siteName: string,

@body
@doc("The properties of the site")
properties: SiteUpdate,
): ArmResponse<Site> | ErrorResponse;

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "custom DELETE call"
@route("/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}")
@delete
@doc("delete Site at SG scope")
@added(Versions.v2025_03_01_preview)
delete(
...ApiVersionParameter,

@path
@doc("The name of the service group")
@pattern("^[a-zA-Z0-9\\-_().]{1,90}$")
servicegroupName: string,

@path
@doc("The name of the site")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$")
siteName: string,
): ArmDeletedResponse | ArmDeletedNoContentResponse | ErrorResponse;
delete is SiteByServiceGroupOps.DeleteSync<Site>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down Expand Up @@ -133,7 +133,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down Expand Up @@ -202,15 +202,15 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
},
{
"name": "properties",
"in": "body",
"description": "The resource properties to be updated.",
"description": "Resource create parameters.",
"required": true,
"schema": {
"$ref": "#/definitions/SiteUpdate"
Expand Down Expand Up @@ -250,7 +250,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down Expand Up @@ -283,7 +283,7 @@
"tags": [
"Sites"
],
"description": "List Site resources by resource group",
"description": "List a Site",
"parameters": [
{
"$ref": "../../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter"
Expand Down Expand Up @@ -339,7 +339,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down Expand Up @@ -384,7 +384,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down Expand Up @@ -459,15 +459,15 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
},
{
"name": "properties",
"in": "body",
"description": "The resource properties to be updated.",
"description": "Resource create parameters.",
"required": true,
"schema": {
"$ref": "#/definitions/SiteUpdate"
Expand Down Expand Up @@ -513,7 +513,7 @@
{
"name": "siteName",
"in": "path",
"description": "Name of Site resource",
"description": "The name of the Site",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]{2,22}[a-zA-Z0-9]$"
Expand Down
Loading
Loading