Skip to content

Compare TSP conversion of Microsoft.AzureSphere #26895

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
214 changes: 117 additions & 97 deletions specification/sphere/Sphere.Management/catalog.tsp
Original file line number Diff line number Diff line change
@@ -1,118 +1,138 @@
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";

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

namespace Microsoft.AzureSphere;

//Catalogs
@doc("An Azure Sphere catalog")
model Catalog is TrackedResource<CatalogProperties> {
@doc("Name of catalog")
@pattern("^[A-Za-z0-9_-]{1,50}$")
@key("catalogName")
@path
@key("catalogName")
@segment("catalogs")
name: string;
}

@doc("Catalog properties")
model CatalogProperties {
@visibility("read")
@doc("The status of the last operation.")
provisioningState?: ProvisioningState;
}

@doc("Request of the action to list device groups for a catalog.")
model ListDeviceGroupsRequest {
@doc("Device Group name.")
deviceGroupName?: string;
}
@doc("Device insight report.")
model DeviceInsight {
@doc("Device ID")
deviceId: string;

@doc("Event description")
description: string;

@doc("Event start timestamp")
startTimestampUtc: utcDateTime;

@doc("Event end timestamp")
endTimestampUtc: utcDateTime;

@doc("Event category")
eventCategory: string;

@doc("Event class")
eventClass: string;

@doc("Event type")
eventType: string;

@doc("Event count")
eventCount: int32;
}

@armResourceOperations
interface Catalogs
extends Azure.ResourceManager.TrackedResourceOperations<
Catalog,
CatalogProperties
> {
@autoRoute
interface Catalogs {
@doc("Get a Catalog")
get is ArmResourceRead<Catalog>;
@doc("Create a Catalog")
createOrUpdate is ArmResourceCreateOrUpdateAsync<Catalog>;
@doc("Update a Catalog")
update is ArmTagsPatchSync<Catalog>;
@doc("Delete a Catalog")
delete is ArmResourceDeleteAsync<Catalog>;
@doc("List Catalog resources by resource group")
listByResourceGroup is ArmResourceListByParent<Catalog>;
@doc("List Catalog resources by subscription ID")
listBySubscription is ArmListBySubscription<Catalog>;
@doc("Counts devices in catalog.")
@armResourceAction(Catalog)
@post
countDevices(
...ResourceInstanceParameters<Catalog>,
): ArmResponse<CountDeviceResponse> | ErrorResponse;

@autoRoute
@doc("Lists device insights for catalog.")
@armResourceAction(Catalog)
@post
listDeviceInsights(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters,
): ArmResponse<Page<DeviceInsight>> | ErrorResponse;

@autoRoute
@doc("Lists devices for catalog.")
@armResourceAction(Catalog)
@post
listDevices(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters,
): ArmResponse<ResourceListResult<Device>> | ErrorResponse;

@autoRoute
countDevices is ArmResourceActionSync<Catalog, {}, CountDeviceResponse>;
@doc("Lists deployments for catalog.")
@armResourceAction(Catalog)
@post
listDeployments(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters,
): ArmResponse<ResourceListResult<Deployment>> | ErrorResponse;

@autoRoute
@armResourceAction(Catalog)
listDeployments is ArmResourceActionSync<
Catalog,
{},
ResourceListResult<Deployment>,
{
...BaseParameters<Catalog>;

@doc("Filter the result list using the given expression")
@query("$filter")
filter?: string;

@doc("The number of result items to return.")
@query("$top")
top?: int32;

@doc("The number of result items to skip.")
@query("$skip")
skip?: int32;

@doc("The maximum number of result items per page.")
@query("$maxpagesize")
maxpagesize?: int32;
}
>;
@doc("List the device groups for the catalog.")
@post
listDeviceGroups(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters,

@doc("List device groups for catalog.")
@body
listDeviceGroupsRequest: ListDeviceGroupsRequest,
): ArmResponse<ResourceListResult<DeviceGroup>> | ErrorResponse;
listDeviceGroups is ArmResourceActionSync<
Catalog,
ListDeviceGroupsRequest,
ResourceListResult<DeviceGroup>,
{
...BaseParameters<Catalog>;

@doc("Filter the result list using the given expression")
@query("$filter")
filter?: string;

@doc("The number of result items to return.")
@query("$top")
top?: int32;

@doc("The number of result items to skip.")
@query("$skip")
skip?: int32;

@doc("The maximum number of result items per page.")
@query("$maxpagesize")
maxpagesize?: int32;
}
>;
@doc("Lists device insights for catalog.")
listDeviceInsights is ArmResourceActionSync<
Catalog,
{},
PagedDeviceInsight,
{
...BaseParameters<Catalog>;

@doc("Filter the result list using the given expression")
@query("$filter")
filter?: string;

@doc("The number of result items to return.")
@query("$top")
top?: int32;

@doc("The number of result items to skip.")
@query("$skip")
skip?: int32;

@doc("The maximum number of result items per page.")
@query("$maxpagesize")
maxpagesize?: int32;
}
>;
@doc("Lists devices for catalog.")
listDevices is ArmResourceActionSync<
Catalog,
{},
ResourceListResult<Device>,
{
...BaseParameters<Catalog>;

@doc("Filter the result list using the given expression")
@query("$filter")
filter?: string;

@doc("The number of result items to return.")
@query("$top")
top?: int32;

@doc("The number of result items to skip.")
@query("$skip")
skip?: int32;

@doc("The maximum number of result items per page.")
@query("$maxpagesize")
maxpagesize?: int32;
}
>;
}
117 changes: 42 additions & 75 deletions specification/sphere/Sphere.Management/certificate.tsp
Original file line number Diff line number Diff line change
@@ -1,95 +1,62 @@
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";
import "./catalog.tsp";

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

namespace Microsoft.AzureSphere;

//Certificates
@doc("An certificate resource belonging to a catalog resource.")
@parentResource(Catalog)
model Certificate is ProxyResource<CertificateProperties> {
@doc("Serial number of the certificate. Use '.default' to get current active certificate.")
@key("serialNumber")
@path
@key("serialNumber")
@segment("certificates")
name: string;
}

@armResourceOperations
interface Certificates
extends ProxyResourceOperationsReadList<Certificate, ListQueryParameters> {
@autoRoute
interface Certificates {
@doc("Get a Certificate")
get is ArmResourceRead<Certificate>;
@doc("List Certificate resources by Catalog")
listByCatalog is ArmResourceListByParent<
Certificate,
{
...BaseParameters<Certificate>;

@doc("Filter the result list using the given expression")
@query("$filter")
filter?: string;

@doc("The number of result items to return.")
@query("$top")
top?: int32;

@doc("The number of result items to skip.")
@query("$skip")
skip?: int32;

@doc("The maximum number of result items per page.")
@query("$maxpagesize")
maxpagesize?: int32;
}
>;
@doc("Retrieves cert chain.")
@armResourceAction(Certificate)
@post
retrieveCertChain(
...ResourceInstanceParameters<Certificate>,
): ArmResponse<CertificateChainResponse> | ErrorResponse;

@autoRoute
@armResourceAction(Certificate)
@post
retrieveCertChain is ArmResourceActionSync<
Certificate,
{},
CertificateChainResponse
>;
@doc("Gets the proof of possession nonce.")
retrieveProofOfPossessionNonce(
...ResourceInstanceParameters<Certificate>,

@doc("Proof of possession nonce request body ")
@body
proofOfPossessionNonceRequest: ProofOfPossessionNonceRequest,
): ArmResponse<ProofOfPossessionNonceResponse> | ErrorResponse;
}

@doc("The properties of certificate")
model CertificateProperties {
@doc("The certificate as a UTF-8 encoded base 64 string.")
@visibility("read")
certificate?: string;

@visibility("read")
@doc("The certificate status.")
status?: CertificateStatus;

@visibility("read")
@doc("The certificate subject.")
subject?: string;

@visibility("read")
@doc("The certificate thumbprint.")
thumbprint?: string;

@visibility("read")
@doc("The certificate expiry date.")
expiryUtc?: utcDateTime;

@visibility("read")
@doc("The certificate not before date.")
notBeforeUtc?: utcDateTime;

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

@doc("The certificate chain response.")
model CertificateChainResponse {
@doc("The certificate chain.")
@visibility("read")
certificateChain?: string;
retrieveProofOfPossessionNonce is ArmResourceActionSync<
Certificate,
ProofOfPossessionNonceRequest,
ProofOfPossessionNonceResponse
>;
}

@doc("Request for the proof of possession nonce")
model ProofOfPossessionNonceRequest {
@doc("The proof of possession nonce")
proofOfPossessionNonce: string;
}

@doc("Result of the action to generate a proof of possession nonce")
model ProofOfPossessionNonceResponse extends CertificateProperties {}
Loading