Skip to content

Commit

Permalink
Update TypeSpec for DeviceRegistry (#29319)
Browse files Browse the repository at this point in the history
* Update TypeSpec for DeviceRegistry

* add client.tsp

* fix model validation

* fix example

* fix example

* remove unused csharp option

* update client.tsp

* fix tsp validation

* fix more tsp validation

* update csharp option
  • Loading branch information
live1206 authored Jun 11, 2024
1 parent e9f47ec commit d1bbbb3
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ interface AssetEndpointProfiles {

createOrReplace is ArmResourceCreateOrReplaceAsync<AssetEndpointProfile>;

update is ArmResourcePatchAsync<
AssetEndpointProfile,
AssetEndpointProfileProperties
>;
@parameterVisibility
update is ArmCustomPatchAsync<AssetEndpointProfile, AssetEndpointProfile>;

delete is ArmResourceDeleteWithoutOkAsync<AssetEndpointProfile>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ model AssetProperties {

@doc("A reference to the asset endpoint profile (connection information) used by brokers to connect to an endpoint that provides data points for this asset. Must have the format <ModuleCR.metadata.namespace>/<ModuleCR.metadata.name>.")
@visibility("read", "create")
assetEndpointProfileUri: string;
assetEndpointProfileUri: url;

@doc("An integer that is incremented each time the resource is modified.")
@visibility("read")
Expand All @@ -66,7 +66,7 @@ model AssetProperties {
manufacturer?: string;

@doc("Asset manufacturer URI.")
manufacturerUri?: string;
manufacturerUri?: url;

@doc("Asset model name.")
// `model` is a reserved keyname. Wrap in double quotes
Expand All @@ -82,7 +82,7 @@ model AssetProperties {
softwareRevision?: string;

@doc("Reference to the documentation.")
documentationUri?: string;
documentationUri?: url;

@doc("Asset serial number.")
serialNumber?: string;
Expand Down Expand Up @@ -207,7 +207,8 @@ interface Assets {

createOrReplace is ArmResourceCreateOrReplaceAsync<Asset>;

update is ArmResourcePatchAsync<Asset, AssetProperties>;
@parameterVisibility
update is ArmCustomPatchAsync<Asset, Asset>;

delete is ArmResourceDeleteWithoutOkAsync<Asset>;

Expand Down
18 changes: 18 additions & 0 deletions specification/deviceregistry/DeviceRegistry.Management/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;

namespace Microsoft.DeviceRegistry;

@@clientName(Asset, "DeviceRegistryAsset", "csharp");
@@clientName(AssetEndpointProfile,
"DeviceRegistryAssetEndpointProfile",
"csharp"
);
@@clientName(ExtendedLocation, "DeviceRegistryExtendedLocation", "csharp");
@@clientName(Event, "AssetEvent", "csharp");
@@clientName(ProvisioningState, "DeviceRegistryProvisioningState", "csharp");
@@clientName(ExtendedLocation.type, "ExtendedLocationType", "csharp");
@@access(OperationStatus.get, Access.internal, "csharp");
@@access(Operations.list, Access.internal, "csharp");
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
"resourceGroupName": "myResourceGroup",
"assetName": "my-asset",
"properties": {
"location": "West Europe",
"properties": {
"enabled": false,
"displayName": "NewAssetDisplayName"
"displayName": "NewAssetDisplayName",
"assetEndpointProfileUri": "https://www.example.com/myAssetEndpointProfile"
},
"extendedLocation": {
"type": "CustomLocation",
"name": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
"resourceGroupName": "myResourceGroup",
"assetEndpointProfileName": "my-assetendpointprofile",
"properties": {
"location": "West Europe",
"properties": {
"targetAddress": "https://www.example.com/myTargetAddress"
},
"extendedLocation": {
"type": "CustomLocation",
"name": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ options:
namespace: "com.azure.resourcemanager.deviceregistry"
service-name: "Device Registry"
examples-directory: "examples"
"@azure-tools/typespec-csharp":
package-dir: "Azure.ResourceManager.DeviceRegistry"
namespace: "{package-dir}"
flavor: "azure"
linter:
extends:
- "@azure-tools/typespec-azure-rulesets/resource-manager"
Loading

0 comments on commit d1bbbb3

Please sign in to comment.