Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2799,3 +2799,6 @@ Metadatas
Gtid
GTID
gtid
Wifi
Nwfs

19 changes: 19 additions & 0 deletions specification/sphere/Sphere.Management/cadl-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
emit: [
"@azure-tools/cadl-autorest",
"@azure-tools/cadl-python",
"@azure-tools/cadl-csharp",
]
options:
"@azure-tools/cadl-python":
"basic-setup-py": true
"package-version": 3.0.0b6
"package-name": azure-sphere
"@azure-tools/cadl-autorest":
examples-directory: ./examples
output-file: azuresphere.json
azure-resource-provider-folder: ../../../../resource-manager
"@azure-tools/cadl-csharp":
save-inputs: false
clear-output-folder: true
namespace: Azure.Sphere
model-namespace: false
119 changes: 119 additions & 0 deletions specification/sphere/Sphere.Management/catalog.cadl
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import "@cadl-lang/rest";
import "@cadl-lang/versioning";
import "@azure-tools/cadl-autorest";
import "@azure-tools/cadl-azure-core";
import "@azure-tools/cadl-azure-resource-manager";

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

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
@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: zonedDateTime;

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

@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.ResourceOperations<Catalog, CatalogProperties> {

@autoRoute
@doc("Counts devices in catalog.")
@armResourceAction(Catalog)
@post
op countDevices(
...ResourceInstanceParameters<Catalog>,
): ArmResponse<CountDeviceResponse> | ErrorResponse;

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

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

@autoRoute
@doc("Lists deployments for catalog.")
@armResourceAction(Catalog)
@post
op listDeployments(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters
): ArmResponse<ResourceListResult<Deployment>> | ErrorResponse;

@autoRoute
@armResourceAction(Catalog)
@doc("List the device groups for the catalog.")
@post
op listDeviceGroups(
...ResourceInstanceParameters<Catalog>,
...ListQueryParameters,
@doc("List device groups for catalog.")
@body listDeviceGroupsRequest: ListDeviceGroupsRequest
): ArmResponse<ResourceListResult<DeviceGroup>> | ErrorResponse;
}



94 changes: 94 additions & 0 deletions specification/sphere/Sphere.Management/certificate.cadl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import "@cadl-lang/rest";
import "@cadl-lang/versioning";
import "@azure-tools/cadl-autorest";
import "@azure-tools/cadl-azure-core";
import "@azure-tools/cadl-azure-resource-manager";

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

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
@segment("certificates")
name: string;
}

@armResourceOperations
interface Certificates extends ProxyResourceOperationsReadList<Certificate, ListQueryParameters> {

@autoRoute
@doc("Retrieves cert chain.")
@armResourceAction(Certificate)
@post
op retrieveCertChain(
...ResourceInstanceParameters<Certificate>,
): ArmResponse<CertificateChainResponse> | ErrorResponse;

@autoRoute
@armResourceAction(Certificate)
@post
@doc("Gets the proof of possession nonce.")
op 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?: zonedDateTime;

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

@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;
}

@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 {}
146 changes: 146 additions & 0 deletions specification/sphere/Sphere.Management/common.cadl
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import "@cadl-lang/openapi";
import "@cadl-lang/rest";
import "@cadl-lang/versioning";
import "@azure-tools/cadl-autorest";
import "@azure-tools/cadl-azure-core";
import "@azure-tools/cadl-azure-resource-manager";

using Cadl.Http;
using Cadl.Rest;
using Cadl.Versioning;
using Azure.ResourceManager.Foundations;
using Azure.Core;
using Azure.ResourceManager;
using OpenAPI;

namespace Microsoft.AzureSphere;

interface Operations extends Azure.ResourceManager.Operations {}

// Common models
@lroStatus
enum ProvisioningState {
...ResourceProvisioningState,
Provisioning,
Updating,
Deleting,
Accepted,
}

@doc("Regional data boundary values.")
enum RegionalDataBoundary {
None,
EU
}

@doc("Allow crash dumps values.")
enum AllowCrashDumpCollection {
Enabled,
Disabled
}

@doc("Certificate status values.")
enum CertificateStatus {
Active,
Inactive,
Expired,
Revoked
}

@doc("Provides the custom '$filter' query parameter for list operations")
model CustomFilterQueryParameter {
@query("$filter")
@doc("Filter the result list using the given expression")
filter?: string;
}

@doc("Provides the custom '$top' query parameter for list operations.")
model CustomTopQueryParameter {
@query("$top")
@doc("The number of result items to return.")
top?: int32;
}

@doc("Provides the custom '$skip' query parameter for list operations.")
model CustomSkipQueryParameter {
@query("$skip")
@doc("The number of result items to skip.")
skip?: int32;
}

@doc("Provides the custom '$maxpagesize' query parameter for list operations.")
model CustomMaxPageSizeQueryParameter {
@query("$maxpagesize")
@doc("The maximum number of result items per page.")
maxpagesize?: int32;
}

@doc("Provides the most common query parameters for list operations.")
model StandardListQueryParametersWithCorrectNames {
...CustomTopQueryParameter;
...CustomSkipQueryParameter;
...CustomMaxPageSizeQueryParameter;
}

@doc("Response to the action call for count devices in a catalog.")
model CountDeviceResponse extends CountElementsResponse {}

@doc("Response of the count for elements.")
model CountElementsResponse {
@doc("Number of children resources in parent resource.")
value: int32;
}

@doc("Parameters for paginated APIs")
model ListQueryParameters {
...CustomFilterQueryParameter;
...StandardListQueryParametersWithCorrectNames;
}

// Templates
interface ProxyResourceOperationsReadList<
TResource extends ArmResource,
TListParameters extends object = {}>
extends Azure.ResourceManager.ResourceRead<TResource>,
ResourceListByParent<TResource, TListParameters & BaseParameters<TResource>> {}

interface ProxyResourceOperationsReadListCreateDelete<
TResource extends ArmResource,
TListParameters extends object = {}>
extends Azure.ResourceManager.ResourceRead<TResource>,
ResourceListByParent<TResource, TListParameters & BaseParameters<TResource>>,
ResourceCreate<TResource>,
Azure.ResourceManager.ResourceDelete<TResource>{}

// Custom update operations
@armResourceOperations
interface CustomUpdateOperations{
@autoRoute
@doc("Update a {name}", TResource)
@extension("x-ms-long-running-operation", true)
@extension(
"x-ms-long-running-operation-options",
{
"final-state-via": "location",
}
)
@armResourceUpdate(TResource)
@patch
op ArmCustomPatchAsyncWithLocation<
TResource extends ArmResource,
TPatchModel extends object = TagsUpdateModel<TResource>,
TBaseParameters = BaseParameters<TResource>
>(
...ResourceInstanceParameters<TResource, TBaseParameters>,

@doc("The resource properties to be updated.")
@body
properties: TPatchModel
): ArmResponse<TResource> | ArmAcceptedResponse<"Resource update request accepted."> | ErrorResponse;
}

alias CustomArmResourcePatchAsync<
TResource extends ArmResource,
TProperties extends object,
TBaseParameters = BaseParameters<TResource>
> = CustomUpdateOperations.ArmCustomPatchAsyncWithLocation<TResource, ResourceUpdateModel<TResource, TProperties>, TBaseParameters>;
Loading