Skip to content

Convert Notificationhubs Swagger to Tsp #34320

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 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cb9e762
convert generated
mcgallan Apr 29, 2025
891a429
update
mcgallan Apr 29, 2025
ba41586
update
mcgallan Apr 29, 2025
3a8d2ef
update
mcgallan Apr 30, 2025
c06ecaf
update
mcgallan May 6, 2025
ca42d48
Merge remote-tracking branch 'upstream/main' into Convert-Notificatio…
mcgallan May 6, 2025
d59b5ba
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs …
May 7, 2025
123422f
Merge branch 'Convert-Notificationhubs' of https://github.com/mcgalla…
May 7, 2025
a37cb57
update
mcgallan May 7, 2025
3af5fc9
update
mcgallan May 7, 2025
39b7d8a
Merge branch 'Convert-Notificationhubs' of https://github.com/mcgalla…
May 7, 2025
9c8aec9
update
mcgallan May 8, 2025
68885fb
fix name
mcgallan May 9, 2025
79e70f0
Merge branch 'main' into Convert-Notificationhubs
mcgallan May 9, 2025
bbe4112
update
mcgallan May 9, 2025
d178f91
Merge branch 'Convert-Notificationhubs' of https://github.com/mcgalla…
mcgallan May 9, 2025
f0e5d33
update
mcgallan May 9, 2025
b53585f
update
mcgallan May 9, 2025
b6c9684
update
mcgallan May 9, 2025
84761fc
fix
mcgallan May 9, 2025
91b30fa
Merge branch 'main' into Convert-Notificationhubs
mcgallan May 22, 2025
3dbdf19
update
mcgallan May 22, 2025
dee7799
Merge branch 'main' into Convert-Notificationhubs
v-jiaodi May 26, 2025
8e58cf4
Merge remote-tracking branch 'upstream/main' into Convert-Notificatio…
melina5656 Jun 6, 2025
9d47626
Delete conditionalClientFlatten
melina5656 Jun 6, 2025
4968c34
update
mcgallan Jun 9, 2025
e7be1c4
update justification
melina5656 Jun 10, 2025
99da564
update
melina5656 Jun 19, 2025
0e461f7
update
melina5656 Jun 19, 2025
a9244cf
Merge remote-tracking branch 'upstream/main' into Convert-Notificatio…
mcgallan Jun 19, 2025
67b11dc
Merge branch 'Convert-Notificationhubs' of https://github.com/mcgalla…
mcgallan Jun 19, 2025
b1538ce
update
mcgallan Jun 19, 2025
c9d272e
remove legacy.tsp
welovej Jun 19, 2025
8efcc17
Merge branch 'Convert-Notificationhubs' of https://github.com/mcgalla…
welovej Jun 19, 2025
1273ec6
update
mcgallan Jun 20, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
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.NotificationHubs;
/**
* Notification Hubs Namespace Resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@Azure.ResourceManager.Private.armResourceInternal(NamespaceProperties)
@Http.Private.includeInapplicableMetadataInPayload(false)
model NamespaceResource extends Foundations.TrackedResource {
...ResourceNameParameter<
Resource = NamespaceResource,
KeyName = "namespaceName",
SegmentName = "namespaces",
NamePattern = "^[a-zA-Z][a-zA-Z0-9-]*$"
>;

/**
* The Sku description for a namespace
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
sku: Sku;

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@doc("The resource-specific properties for this resource.")
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(true)
properties?: NamespaceProperties;
}

@armResourceOperations
interface NamespaceResources {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Weidong, all the interface names now have a suffix "Resources." This change introduces many breaking changes: https://github.com/azure-sdk/azure-sdk-for-go/pull/14591/files. Should they remain consistent with the previous naming?

/**
* Returns the given namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("Namespaces_Get")
get is ArmResourceRead<NamespaceResource>;

/**
* Creates / Updates a Notification Hub namespace. This operation is idempotent.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("Namespaces_CreateOrUpdate")
createOrUpdate is ArmResourceCreateOrReplaceAsync<NamespaceResource>;

/**
* Patches the existing namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@patch(#{ implicitOptionality: false })
@operationId("Namespaces_Update")
update is ArmCustomPatchSync<
NamespaceResource,
PatchModel = NamespacePatchParameters
>;

/**
* Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("Namespaces_Delete")
delete is ArmResourceDeleteSync<NamespaceResource>;

/**
* Lists the available namespaces within a resource group.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("Namespaces_List")
list is ArmResourceListByParent<
NamespaceResource,
Parameters = {
/**
* Skip token for subsequent requests.
*/
@query("$skipToken")
$skipToken?: string;

/**
* Maximum number of results to return.
*/
@query("$top")
$top?: int32 = 100;
},
Response = NamespaceListResult
>;

/**
* Lists all the available namespaces within the subscription.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("Namespaces_ListAll")
listAll is ArmListBySubscription<
NamespaceResource,
Parameters = {
/**
* Skip token for subsequent requests.
*/
@query("$skipToken")
$skipToken?: string;

/**
* Maximum number of results to return.
*/
@query("$top")
$top?: int32 = 100;
},
Response = NamespaceListResult
>;

/**
* Checks the availability of the given notificationHub in a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("NotificationHubs_CheckNotificationHubAvailability")
checkNotificationHubAvailability is ArmResourceActionSync<
NamespaceResource,
CheckAvailabilityParameters,
ArmResponse<CheckAvailabilityResult>
>;

/**
* Lists the PNS credentials associated with a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@action("pnsCredentials")
@operationId("Namespaces_GetPnsCredentials")
getPnsCredentials is ArmResourceActionSync<
NamespaceResource,
void,
ArmResponse<PnsCredentialsResource>
>;
}

@@maxLength(NamespaceResource.name, 50);
@@minLength(NamespaceResource.name, 1);
@@doc(NamespaceResource.name, "Namespace name");
@@doc(NamespaceResource.properties, "Represents namespace properties.");
@@doc(NamespaceResources.createOrUpdate::parameters.resource,
"Request content."
);
@@doc(NamespaceResources.update::parameters.properties, "Request content.");
@@doc(NamespaceResources.checkNotificationHubAvailability::parameters.body,
"Request content."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./NamespaceResource.tsp";

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

namespace Microsoft.NotificationHubs;
/**
* Notification Hub Resource.
*/
@parentResource(NamespaceResource)
model NotificationHubResource
is Azure.ResourceManager.TrackedResource<NotificationHubProperties> {
...ResourceNameParameter<
Resource = NotificationHubResource,
KeyName = "notificationHubName",
SegmentName = "notificationHubs",
NamePattern = "^[a-zA-Z][a-zA-Z0-9-./_]*$"
>;

/**
* The Sku description for a namespace
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
sku?: Sku;
}

@armResourceOperations
interface NotificationHubResources {
/**
* Gets the notification hub.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("NotificationHubs_Get")
get is ArmResourceRead<NotificationHubResource>;

/**
* Creates/Update a NotificationHub in a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("NotificationHubs_CreateOrUpdate")
createOrUpdate is ArmResourceCreateOrReplaceSync<NotificationHubResource>;

/**
* Patch a NotificationHub in a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@patch(#{ implicitOptionality: false })
@operationId("NotificationHubs_Update")
update is ArmCustomPatchSync<
NotificationHubResource,
PatchModel = NotificationHubPatchParameters
>;

/**
* Deletes a notification hub associated with a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("NotificationHubs_Delete")
delete is ArmResourceDeleteSync<NotificationHubResource>;

/**
* Lists the notification hubs associated with a namespace.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("NotificationHubs_List")
list is ArmResourceListByParent<
NotificationHubResource,
Parameters = {
/**
* Continuation token.
*/
@query("$skipToken")
$skipToken?: string;

/**
* Page size.
*/
@query("$top")
$top?: int32 = 100;
},
Response = NotificationHubListResult
>;

/**
* Test send a push notification.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@action("debugsend")
@operationId("NotificationHubs_DebugSend")
debugSend is ArmResourceActionSync<
NotificationHubResource,
void,
ArmResponse<DebugSendResponse>
>;

/**
* Lists the PNS Credentials associated with a notification hub.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@action("pnsCredentials")
@operationId("NotificationHubs_GetPnsCredentials")
getPnsCredentials is ArmResourceActionSync<
NotificationHubResource,
void,
ArmResponse<PnsCredentialsResource>
>;
}

@@maxLength(NotificationHubResource.name, 265);
@@minLength(NotificationHubResource.name, 1);
@@doc(NotificationHubResource.name, "Notification Hub name");
@@doc(NotificationHubResource.properties, "NotificationHub properties.");
@@doc(NotificationHubResources.createOrUpdate::parameters.resource,
"Request content."
);
@@doc(NotificationHubResources.update::parameters.properties,
"Request content."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./NamespaceResource.tsp";

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

namespace Microsoft.NotificationHubs;
/**
* Represents a Private Endpoint Connection ARM resource - a sub-resource of Notification Hubs namespace.
*/
@parentResource(NamespaceResource)
model PrivateEndpointConnectionResource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrivateEndpointConnectionResource

Putting 'Resource' on the name is more of a naming antipattern I think - were we already doing it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's original name.

is Azure.ResourceManager.ProxyResource<PrivateEndpointConnectionProperties> {
...ResourceNameParameter<
Resource = PrivateEndpointConnectionResource,
KeyName = "privateEndpointConnectionName",
SegmentName = "privateEndpointConnections",
NamePattern = "^[a-zA-Z][a-zA-Z0-9-]*\\.[a-fA-F0-9\\-]+$"
>;
}

@armResourceOperations
interface PrivateEndpointConnectionResources {
/**
* Returns a Private Endpoint Connection with a given name.
* This is a public API that can be called directly by Notification Hubs users.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("PrivateEndpointConnections_Get")
get is ArmResourceRead<PrivateEndpointConnectionResource>;

/**
* Approves or rejects Private Endpoint Connection.
* This is a public API that can be called directly by Notification Hubs users.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("PrivateEndpointConnections_Update")
update is ArmResourceCreateOrReplaceAsync<PrivateEndpointConnectionResource>;

/**
* Deletes the Private Endpoint Connection.
* This is a public API that can be called directly by Notification Hubs users.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("PrivateEndpointConnections_Delete")
delete is ArmResourceDeleteWithoutOkAsync<PrivateEndpointConnectionResource>;

/**
* Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace.
* This is a public API that can be called directly by Notification Hubs users.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@operationId("PrivateEndpointConnections_List")
list is ArmResourceListByParent<PrivateEndpointConnectionResource>;
}

@@maxLength(PrivateEndpointConnectionResource.name, 87);
@@minLength(PrivateEndpointConnectionResource.name, 1);
@@doc(PrivateEndpointConnectionResource.name,
"Private Endpoint Connection Name"
);
@@doc(PrivateEndpointConnectionResource.properties,
"Private Endpoint Connection properties."
);
@@doc(PrivateEndpointConnectionResources.update::parameters.resource,
"Description of the Private Endpoint Connection resource."
);
Loading
Loading