Skip to content

[TSP Migration] Convert ElasticSan to TypeSpec #34078

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
92 changes: 92 additions & 0 deletions specification/elasticsan/ElasticSan.Management/ElasticSan.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.ElasticSan;
/**
* Response for ElasticSan request.
*/
model ElasticSan
is Azure.ResourceManager.TrackedResource<ElasticSanProperties, false> {
...ResourceNameParameter<
Resource = ElasticSan,
KeyName = "elasticSanName",
SegmentName = "elasticSans",
NamePattern = "^[A-Za-z0-9]+((-|_)[a-z0-9A-Z]+)*$"
>;
}

@armResourceOperations
interface ElasticSans {
/**
* Get a ElasticSan.
*/
get is ArmResourceRead<ElasticSan>;

/**
* Create ElasticSan.
*/
create is ArmResourceCreateOrReplaceAsync<
ElasticSan,
LroHeaders = ArmLroLocationHeader<FinalResult = ElasticSan> &
Azure.Core.Foundations.RetryAfterHeader
>;

/**
* Update a Elastic San.
*/
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchAsync<ElasticSan, PatchModel = ElasticSanUpdate>;

/**
* Delete a Elastic San.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
delete is ArmResourceDeleteWithoutOkAsync<
ElasticSan,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* Gets a list of ElasticSan in a resource group.
*/
listByResourceGroup is ArmResourceListByParent<
ElasticSan,
Response = ArmResponse<ElasticSanList>
>;

/**
* Gets a list of ElasticSans in a subscription
*/
listBySubscription is ArmListBySubscription<
ElasticSan,
Response = ArmResponse<ElasticSanList>
>;

/**
* Gets the private link resources that need to be created for a elastic San.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@get
@action("privateLinkResources")
@operationId("PrivateLinkResources_ListByElasticSan")
listByElasticSan is ArmResourceActionSync<
ElasticSan,
void,
ArmResponse<PrivateLinkResourceListResult>
>;
}

@@maxLength(ElasticSan.name, 24);
@@minLength(ElasticSan.name, 3);
@@doc(ElasticSan.name, "The name of the ElasticSan.");
@@doc(ElasticSan.properties, "Properties of ElasticSan.");
@@doc(ElasticSans.create::parameters.resource, "Elastic San object.");
@@doc(ElasticSans.update::parameters.properties, "Elastic San object.");
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./ElasticSan.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.ElasticSan;
/**
* Response for PrivateEndpoint Connection object
*/
@parentResource(ElasticSan)
model PrivateEndpointConnection
is Azure.ResourceManager.ProxyResource<
PrivateEndpointConnectionProperties,
false
> {
...ResourceNameParameter<
Resource = PrivateEndpointConnection,
KeyName = "privateEndpointConnectionName",
SegmentName = "privateEndpointConnections",
NamePattern = ""
>;
}

@armResourceOperations
interface PrivateEndpointConnections {
/**
* Gets the specified private endpoint connection associated with the Elastic San
*/
get is ArmResourceRead<PrivateEndpointConnection>;

/**
* Update the state of specified private endpoint connection associated with the Elastic San
*/
create is ArmResourceCreateOrReplaceAsync<
PrivateEndpointConnection,
LroHeaders = ArmLroLocationHeader<FinalResult = PrivateEndpointConnection> &
Azure.Core.Foundations.RetryAfterHeader
>;

/**
* Deletes the specified private endpoint connection associated with the Elastic San
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
delete is ArmResourceDeleteWithoutOkAsync<
PrivateEndpointConnection,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* List all Private Endpoint Connections associated with the Elastic San.
*/
list is ArmResourceListByParent<PrivateEndpointConnection>;
}

@@doc(PrivateEndpointConnection.name,
"The name of the Private Endpoint connection."
);
@@doc(PrivateEndpointConnection.properties,
"Private Endpoint Connection Properties."
);
@@doc(PrivateEndpointConnections.create::parameters.resource,
"Private Endpoint Connection Approval object."
);
82 changes: 82 additions & 0 deletions specification/elasticsan/ElasticSan.Management/Snapshot.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./VolumeGroup.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.ElasticSan;
/**
* Response for Volume Snapshot request.
*/
@parentResource(VolumeGroup)
model Snapshot
is Azure.ResourceManager.ProxyResource<SnapshotProperties, false> {
...ResourceNameParameter<
Resource = Snapshot,
KeyName = "snapshotName",
SegmentName = "snapshots",
NamePattern = "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"
>;
}

@armResourceOperations
interface Snapshots {
/**
* Get a Volume Snapshot.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("VolumeSnapshots_Get")
get is ArmResourceRead<Snapshot>;

/**
* Create a Volume Snapshot.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("VolumeSnapshots_Create")
create is ArmResourceCreateOrReplaceAsync<
Snapshot,
LroHeaders = ArmLroLocationHeader & Azure.Core.Foundations.RetryAfterHeader
>;

/**
* Delete a Volume Snapshot.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
@operationId("VolumeSnapshots_Delete")
delete is ArmResourceDeleteWithoutOkAsync<
Snapshot,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* List Snapshots in a VolumeGroup or List Snapshots by Volume (name) in a VolumeGroup using filter
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("VolumeSnapshots_ListByVolumeGroup")
listByVolumeGroup is ArmResourceListByParent<
Snapshot,
Parameters = {
/**
* Specify $filter='volumeName eq <volume name>' to filter on volume.
*/
@query("$filter")
$filter?: string;
},
Response = ArmResponse<SnapshotList>
>;
}

@@maxLength(Snapshot.name, 80);
@@minLength(Snapshot.name, 1);
@@doc(Snapshot.name,
"The name of the volume snapshot within the given volume group."
);
@@doc(Snapshot.properties, "Properties of Volume Snapshot.");
@@doc(Snapshots.create::parameters.resource, "Snapshot object.");
106 changes: 106 additions & 0 deletions specification/elasticsan/ElasticSan.Management/Volume.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./VolumeGroup.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.ElasticSan;
/**
* Response for Volume request.
*/
@parentResource(VolumeGroup)
model Volume is Azure.ResourceManager.ProxyResource<VolumeProperties, false> {
...ResourceNameParameter<
Resource = Volume,
KeyName = "volumeName",
SegmentName = "volumes",
NamePattern = "^[a-z0-9]+(-[a-z0-9A-Z]+)*$"
>;
}

@armResourceOperations
interface Volumes {
/**
* Get an Volume.
*/
get is ArmResourceRead<Volume>;

/**
* Create a Volume.
*/
create is ArmResourceCreateOrReplaceAsync<
Volume,
LroHeaders = ArmLroLocationHeader<FinalResult = Volume> &
Azure.Core.Foundations.RetryAfterHeader
>;

/**
* Update an Volume.
*/
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchAsync<Volume, PatchModel = VolumeUpdate>;

/**
* Delete an Volume.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
delete is ArmResourceDeleteWithoutOkAsync<
Volume,
Parameters = {
/**
* Optional, used to delete snapshots under volume. Allowed value are only true or false. Default value is false.
*/
@header
`x-ms-delete-snapshots`?: `x-ms-delete-snapshots`;

/**
* Optional, used to delete volume if active sessions present. Allowed value are only true or false. Default value is false.
*/
@header
`x-ms-force-delete`?: `x-ms-force-delete`;

/**
* Optional. Specifies that the delete operation should be a permanent delete for the soft deleted volume. The value of deleteType can only be 'permanent'.
*/
@query("deleteType")
deleteType?: DeleteType;
},
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* List Volumes in a VolumeGroup.
*/
listByVolumeGroup is ArmResourceListByParent<
Volume,
Parameters = {
/**
* Optional, returns only soft deleted volumes if set to true. If set to false or if not specified, returns only active volumes.
*/
@header
`x-ms-access-soft-deleted-resources`?: `x-ms-access-soft-deleted-resources`;
},
Response = ArmResponse<VolumeList>
>;

/**
* Restore Soft Deleted Volumes. The volume name is obtained by using the API to list soft deleted volumes by volume group
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@action("restore")
@operationId("RestoreVolume")
restoreVolume is ArmResourceActionAsync<Volume, void, Volume>;
}

@@maxLength(Volume.name, 63);
@@minLength(Volume.name, 3);
@@doc(Volume.name, "The name of the Volume.");
@@doc(Volume.properties, "Properties of Volume.");
@@doc(Volumes.create::parameters.resource, "Volume object.");
@@doc(Volumes.update::parameters.properties, "Volume object.");
Loading
Loading