-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: main
Are you sure you want to change the base?
Changes from all commits
cb9e762
891a429
ba41586
3a8d2ef
c06ecaf
ca42d48
d59b5ba
123422f
a37cb57
3af5fc9
39b7d8a
9c8aec9
68885fb
79e70f0
bbe4112
d178f91
f0e5d33
b53585f
b6c9684
84761fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
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. | ||
*/ | ||
@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" "For backward compatibility" | ||
sku: Sku; | ||
|
||
@doc("The resource-specific properties for this resource.") | ||
@Azure.ResourceManager.Private.conditionalClientFlatten | ||
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(true) | ||
properties?: NamespaceProperties; | ||
} | ||
|
||
@armResourceOperations | ||
interface NamespaceResources { | ||
/** | ||
* Returns the given namespace. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@operationId("Namespaces_Get") | ||
Comment on lines
+39
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we rename the interface to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I'll change anything until we have a mature design and mitigation plan on the deprecating operation id. |
||
get is ArmResourceRead<NamespaceResource>; | ||
|
||
/** | ||
* Creates / Updates a Notification Hub namespace. This operation is idempotent. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@operationId("Namespaces_CreateOrUpdate") | ||
createOrUpdate is ArmResourceCreateOrReplaceAsync<NamespaceResource>; | ||
|
||
/** | ||
* Patches the existing namespace. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@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" "non-standard operations" | ||
@operationId("Namespaces_Delete") | ||
delete is ArmResourceDeleteSync<NamespaceResource>; | ||
|
||
/** | ||
* Lists the available namespaces within a resource group. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "For backward compatibility" | ||
sku?: Sku; | ||
} | ||
|
||
@armResourceOperations | ||
interface NotificationHubResources { | ||
/** | ||
* Gets the notification hub. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@operationId("NotificationHubs_Get") | ||
get is ArmResourceRead<NotificationHubResource>; | ||
|
||
/** | ||
* Creates/Update a NotificationHub in a namespace. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@operationId("NotificationHubs_CreateOrUpdate") | ||
createOrUpdate is ArmResourceCreateOrReplaceSync<NotificationHubResource>; | ||
|
||
/** | ||
* Patch a NotificationHub in a namespace. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@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" "non-standard operations" | ||
@operationId("NotificationHubs_Delete") | ||
delete is ArmResourceDeleteSync<NotificationHubResource>; | ||
|
||
/** | ||
* Lists the notification hubs associated with a namespace. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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 | ||
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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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" "non-standard operations" | ||
@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." | ||
); |
There was a problem hiding this comment.
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?