Skip to content

[TSP Migration][orbital] TypeSpec migrated from swagger #34329

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 3 commits into
base: main
Choose a base branch
from
Draft
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
68 changes: 68 additions & 0 deletions specification/orbital/Orbital.Management/Contact.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./Spacecraft.tsp";

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

namespace Microsoft.Orbital;
/**
* Customer creates a contact resource for a spacecraft resource.
*/
@parentResource(Spacecraft)
model Contact
is Azure.ResourceManager.ProxyResource<ContactsProperties, false> {
...ResourceNameParameter<
Resource = Contact,
KeyName = "contactName",
SegmentName = "contacts",
NamePattern = ""
>;
}

@armResourceOperations
interface Contacts {
/**
* Gets the specified contact in a specified resource group.
*/
get is ArmResourceRead<Contact>;

/**
* Creates a contact.
*/
create is ArmResourceCreateOrReplaceAsync<Contact>;

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

/**
* Returns list of contacts by spacecraftName.
*/
list is ArmResourceListByParent<
Contact,
Parameters = {
/**
* An opaque string that the resource provider uses to skip over previously-returned results. This is used when a previous list operation call returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
*/
@query("$skiptoken")
$skiptoken?: string;
}
>;
}

@@doc(Contact.name, "Contact name.");
@@doc(Contact.properties, "Properties of the Contact Resource.");
@@doc(Contacts.create::parameters.resource,
"The parameters to provide for the created contact."
);
89 changes: 89 additions & 0 deletions specification/orbital/Orbital.Management/ContactProfile.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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.Orbital;
/**
* Customer creates a Contact Profile Resource, which will contain all of the configurations required for scheduling a contact.
*/
model ContactProfile
is Azure.ResourceManager.TrackedResource<ContactProfilesProperties, false> {
...ResourceNameParameter<
Resource = ContactProfile,
KeyName = "contactProfileName",
SegmentName = "contactProfiles",
NamePattern = ""
>;
}

@armResourceOperations
interface ContactProfiles {
/**
* Gets the specified contact Profile in a specified resource group.
*/
get is ArmResourceRead<ContactProfile>;

/**
* Creates or updates a contact profile.
*/
createOrUpdate is ArmResourceCreateOrReplaceAsync<ContactProfile>;

/**
* Updates the specified contact profile tags.
*/
@patch(#{ implicitOptionality: false })
updateTags is ArmCustomPatchAsync<ContactProfile, PatchModel = TagsObject>;

/**
* Deletes a specified contact profile resource.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
delete is ArmResourceDeleteWithoutOkAsync<
ContactProfile,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* Returns list of contact profiles by Resource Group.
*/
list is ArmResourceListByParent<
ContactProfile,
Parameters = {
/**
* An opaque string that the resource provider uses to skip over previously-returned results. This is used when a previous list operation call returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
*/
@query("$skiptoken")
$skiptoken?: string;
}
>;

/**
* Returns list of contact profiles by Subscription.
*/
listBySubscription is ArmListBySubscription<
ContactProfile,
Parameters = {
/**
* An opaque string that the resource provider uses to skip over previously-returned results. This is used when a previous list operation call returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
*/
@query("$skiptoken")
$skiptoken?: string;
}
>;
}

@@doc(ContactProfile.name, "Contact Profile name.");
@@doc(ContactProfile.properties, "Properties of the contact profile resource.");
@@doc(ContactProfiles.createOrUpdate::parameters.resource,
"The parameters to provide for the created Contact Profile."
);
@@doc(ContactProfiles.updateTags::parameters.properties,
"Parameters supplied to update contact profile tags."
);
101 changes: 101 additions & 0 deletions specification/orbital/Orbital.Management/Spacecraft.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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.Orbital;
/**
* Customer creates a spacecraft resource to schedule a contact.
*/
model Spacecraft
is Azure.ResourceManager.TrackedResource<SpacecraftsProperties, false> {
...ResourceNameParameter<
Resource = Spacecraft,
KeyName = "spacecraftName",
SegmentName = "spacecrafts",
NamePattern = ""
>;
}

@armResourceOperations
interface Spacecrafts {
/**
* Gets the specified spacecraft in a specified resource group.
*/
get is ArmResourceRead<Spacecraft>;

/**
* Creates or updates a spacecraft resource.
*/
createOrUpdate is ArmResourceCreateOrReplaceAsync<Spacecraft>;

/**
* Updates the specified spacecraft tags.
*/
@patch(#{ implicitOptionality: false })
updateTags is ArmCustomPatchAsync<Spacecraft, PatchModel = TagsObject>;

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

/**
* Returns list of spacecrafts by resource group.
*/
list is ArmResourceListByParent<
Spacecraft,
Parameters = {
/**
* An opaque string that the resource provider uses to skip over previously-returned results. This is used when a previous list operation call returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
*/
@query("$skiptoken")
$skiptoken?: string;
}
>;

/**
* Returns list of spacecrafts by subscription.
*/
listBySubscription is ArmListBySubscription<
Spacecraft,
Parameters = {
/**
* An opaque string that the resource provider uses to skip over previously-returned results. This is used when a previous list operation call returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
*/
@query("$skiptoken")
$skiptoken?: string;
}
>;

/**
* Returns list of available contacts. A contact is available if the spacecraft is visible from the ground station for more than the minimum viable contact duration provided in the contact profile.
*/
listAvailableContacts is ArmResourceActionAsync<
Spacecraft,
ContactParameters,
ArmResponse<AvailableContactsListResult>
>;
}

@@doc(Spacecraft.name, "Spacecraft ID.");
@@doc(Spacecraft.properties, "Spacecraft Properties");
@@doc(Spacecrafts.createOrUpdate::parameters.resource,
"The parameters to provide for the created spacecraft."
);
@@doc(Spacecrafts.updateTags::parameters.properties,
"Parameters supplied to update spacecraft tags."
);
@@doc(Spacecrafts.listAvailableContacts::parameters.body,
"The parameters to provide for the contacts."
);
29 changes: 29 additions & 0 deletions specification/orbital/Orbital.Management/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using Microsoft.Orbital;

#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(AvailableContacts.properties);

#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(AvailableGroundStation.properties);

#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(OperationResult.properties);

@@clientName(Spacecrafts.createOrUpdate::parameters.resource, "parameters");
@@clientName(Spacecrafts.updateTags::parameters.properties, "parameters");
@@clientName(Spacecrafts.listAvailableContacts::parameters.body, "parameters");
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(Spacecraft.properties);

@@clientName(Contacts.create::parameters.resource, "parameters");
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(Contact.properties);

@@clientName(ContactProfiles.createOrUpdate::parameters.resource, "parameters");
@@clientName(ContactProfiles.updateTags::parameters.properties, "parameters");
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(ContactProfile.properties);
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{

Check failure on line 1 in specification/orbital/Orbital.Management/examples/2022-11-01/AvailableContactsList.json

View check run for this annotation

Azure Pipelines / Swagger PrettierCheck

specification/orbital/Orbital.Management/examples/2022-11-01/AvailableContactsList.json#L1

specification/orbital/Orbital.Management/examples/2022-11-01/AvailableContactsList.json(1,1): error : Code style issues found, please run prettier. > npm install > npx prettier --write specification/orbital/Orbital.Management/examples/2022-11-01/AvailableContactsList.json
"parameters": {
"api-version": "2022-11-01",
"parameters": {
"contactProfile": {
"id": "/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"
},
"endTime": "2022-11-02T11:30:00Z",
"groundStationName": "EASTUS2_0",
"startTime": "2022-11-01T11:30:00Z"
},
"resourceGroupName": "contoso-Rgp",
"spacecraftName": "CONTOSO_SAT",
"subscriptionId": "c1be1141-a7c9-4aac-9608-3c2e2f1152c3"
},
"responses": {
"200": {
"body": {
"nextLink": "https://management.azure.com/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/spacecrafts/CONTOSO_SAT/listAvailableContacts?api-version=2022-11-01&$skiptoken=opaqueString",
"value": [
{
"groundStationName": "EASTUS2_0",
"properties": {
"endAzimuthDegrees": 330.489627,
"endElevationDegrees": 5.040625,
"maximumElevationDegrees": 26.617297,
"rxEndTime": "2022-11-01T12:05:25Z",
"rxStartTime": "2022-11-01T11:55:01Z",
"startAzimuthDegrees": 201.340472,
"startElevationDegrees": 5,
"txEndTime": "2022-11-01T12:05:25Z",
"txStartTime": "2022-11-01T11:55:01Z"
},
"spacecraft": {
"id": "/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/spacecrafts/CONTOSO_SAT"
}
},
{
"groundStationName": "EASTUS2_0",
"properties": {
"endAzimuthDegrees": 345.848482,
"endElevationDegrees": 5.048656,
"maximumElevationDegrees": 85.9796,
"rxEndTime": "2022-11-02T11:10:45Z",
"rxStartTime": "2022-11-02T10:58:30Z",
"startAzimuthDegrees": 165.758896,
"startElevationDegrees": 5,
"txEndTime": "2022-11-02T11:10:45Z",
"txStartTime": "2022-11-02T10:58:30Z"
},
"spacecraft": {
"id": "/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/spacecrafts/CONTOSO_SAT"
}
}
]
}
},
"202": {
"headers": {
"Location": "https://management.azure.com/Microsoft.Orbital/operationResults/4e2ffff7-b331-4fcb-ab11-b5fa49368188?api-version=2022-11-01"
}
}
},
"operationId": "Spacecrafts_ListAvailableContacts",
"title": "List of Contact"
}
Loading
Loading