From d695ba3ca49726cd14616c3afe5b9a6c7f7627bf Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Tue, 13 Jun 2023 19:57:04 -0700 Subject: [PATCH] [TypeSpec CI] Revert formatting check and changes to eventgrid (#24430) - Blocked until https://github.com/microsoft/typespec/issues/2060 is fixed --- eng/pipelines/templates/steps/typespec-ci.yml | 3 +- .../Azure.Messaging.EventGrid/main.tsp | 282 ++++++++---------- 2 files changed, 130 insertions(+), 155 deletions(-) diff --git a/eng/pipelines/templates/steps/typespec-ci.yml b/eng/pipelines/templates/steps/typespec-ci.yml index 064c647087a2..8df38330272d 100644 --- a/eng/pipelines/templates/steps/typespec-ci.yml +++ b/eng/pipelines/templates/steps/typespec-ci.yml @@ -33,7 +33,8 @@ steps: fi # Format parent folder to include shared files - npx tsp format ../**/*.tsp + # Disabled until https://github.com/microsoft/typespec/issues/2060 is fixed + # npx tsp format ../**/*.tsp popd diff --git a/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp b/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp index b4efa9a5166d..f8c3e64ae92f 100644 --- a/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp +++ b/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp @@ -3,7 +3,10 @@ import "@typespec/rest"; import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; -@useAuth(ApiKeyAuth) +@useAuth( + ApiKeyAuth +) + @service({ title: "Azure.Messaging.EventGridClient", }) @@ -16,6 +19,8 @@ import "@azure-tools/typespec-azure-core"; // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge?api-Version={apiVersion} // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release?api-version={apiVersion} // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject?api-version={apiVersion} + + @server( "{endpoint}", "The host name of the namespace", @@ -24,24 +29,10 @@ import "@azure-tools/typespec-azure-core"; endpoint: url, } ) + @doc("Azure Messaging EventGrid Client") @versioned(ServiceApiVersions) namespace Azure.Messaging.EventGrid { - -// Publish Operation: -// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}:publish?api-version={apiVersion}} - -// Receive Operation: -// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive?api-Version={apiVersion}&maxWaitTime=60&maxEvents={maxEvents} - -// Acknowledge Operation: -// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge&apiVersion={apiVersion} - -// Release Operation: -// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release?api-version={apiVersion} - -// Reject Operation: -// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject?api-version={apiVersion} using TypeSpec.Http; using TypeSpec.Rest; using TypeSpec.Versioning; @@ -51,7 +42,7 @@ namespace Azure.Messaging.EventGrid { #suppress "@azure-tools/typespec-azure-core/documentation-required" "https://github.com/Azure/typespec-azure/issues/3107" enum ServiceApiVersions { @useDependency(Azure.Core.Versions.v1_0_Preview_2) - v2023_06_01_preview: "2023-06-01-preview", + v2023_06_01_preview: "2023-06-01-preview" } @doc("Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema.") @@ -67,7 +58,7 @@ namespace Azure.Messaging.EventGrid { @doc("Event data specific to the event type, encoded as a base64 string.") data_base64?: bytes; - + @doc("Type of event related to the originating occurrence.") type: string; @@ -110,7 +101,7 @@ namespace Azure.Messaging.EventGrid { @doc("Array of receive responses, one per cloud event.") value: ReceiveDetails[]; } - + @doc("Failed LockToken information.") model FailedLockToken { @doc("LockToken value") @@ -120,7 +111,7 @@ namespace Azure.Messaging.EventGrid { errorCode: string; @doc("Description of the token error.") - errorDescription: string; + errorDescription: string; } @doc("The result of the Publish operation.") @@ -171,150 +162,133 @@ namespace Azure.Messaging.EventGrid { lockTokens: string[]; } + // Publish Operation: + // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}:publish?api-version={apiVersion}} + @doc("Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ") - @route( - "/topics/{topicName}:publish", - { - shared: true, - } - ) - @post - op PublishCloudEvent is Azure.Core.RpcOperation< - { - @doc("content type") - @header("content-type") - contentType: "application/cloudevents+json; charset=utf-8"; - - @doc("Topic Name.") - @path - topicName: string; - - @doc("Single Cloud Event being published.") - @body - event: CloudEvent; - }, - PublishResult - >; - - @doc("Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ") - @route( - "/topics/{topicName}:publish", - { - shared: true, - } - ) - @post - op PublishCloudEvents is Azure.Core.RpcOperation< - { - @doc("content type") - @header("content-type") - contentType: "application/cloudevents-batch+json; charset=utf-8"; - - @doc("Topic Name.") - @path - topicName: string; - - @doc("Array of Cloud Events being published.") - @body - events: CloudEvent[]; - }, - PublishResult - >; + @route("/topics/{topicName}:publish", {shared: true}) + @post op PublishCloudEvent is Azure.Core.RpcOperation<{ + @doc("content type") + @header("content-type") + contentType: "application/cloudevents+json; charset=utf-8"; + + @doc("Topic Name.") + @path + topicName: string; + + @doc("Single Cloud Event being published.") + @body + event: CloudEvent; + }, PublishResult>; + + + @doc("Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ") + @route("/topics/{topicName}:publish", {shared: true}) + @post op PublishCloudEvents is Azure.Core.RpcOperation<{ + @doc("content type") + @header("content-type") + contentType: "application/cloudevents-batch+json; charset=utf-8"; + + @doc("Topic Name.") + @path + topicName: string; + @doc("Array of Cloud Events being published.") + @body + events: CloudEvent[]; + }, PublishResult>; + + // Receive Operation: + // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive?api-Version={apiVersion}&maxWaitTime=60&maxEvents={maxEvents} + @doc("Receive Batch of Cloud Events from the Event Subscription.") @route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive") - @post - op ReceiveCloudEvents is Azure.Core.RpcOperation< - { - @doc("Topic Name.") - @path - topicName: string; - - @doc("Event Subscription Name.") - @path - eventSubscriptionName: string; - - @doc("Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1.") - @query - maxEvents?: int32 = 1; - - @doc("Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds.") - @encode("seconds", int32) - @query - maxWaitTime?: duration; - }, - ReceiveResult - >; + @post op ReceiveCloudEvents is Azure.Core.RpcOperation<{ + @doc("Topic Name.") + @path + topicName: string; + + @doc("Event Subscription Name.") + @path + eventSubscriptionName: string; + + @doc("Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1.") + @query + maxEvents?: int32 = 1; + + @doc("Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds.") + @encode("seconds", int32) + @query + maxWaitTime?: duration; + }, ReceiveResult>; + + // Acknowledge Operation: + // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge&apiVersion={apiVersion} @doc("Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully acknowledged. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.") - @route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge") - @post - op AcknowledgeCloudEvents is Azure.Core.RpcOperation< - { - @doc("content type") - @header("content-type") - contentType: "application/json; charset=utf-8"; - - @doc("Topic Name.") - @path - topicName: string; - - @doc("Event Subscription Name.") - @path - eventSubscriptionName: string; - - @doc("AcknowledgeOptions.") - @body - lockTokens: AcknowledgeOptions; - }, - AcknowledgeResult - >; + @route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge") + @post op AcknowledgeCloudEvents is Azure.Core.RpcOperation<{ + @doc("content type") + @header("content-type") + contentType: "application/json; charset=utf-8"; + + @doc("Topic Name.") + @path + topicName: string; + + @doc("Event Subscription Name.") + @path + eventSubscriptionName: string; + + @doc("AcknowledgeOptions.") + @body + lockTokens: AcknowledgeOptions; + }, AcknowledgeResult>; + + // Release Operation: + // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release?api-version={apiVersion} + @doc("Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully released. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.") @route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release") - @post - op ReleaseCloudEvents is Azure.Core.RpcOperation< - { - @doc("content type") - @header("content-type") - contentType: "application/json; charset=utf-8"; - - @doc("Topic Name.") - @path - topicName: string; - - @doc("Event Subscription Name.") - @path - eventSubscriptionName: string; - - @doc("ReleaseOptions") - @body - lockTokens: ReleaseOptions; - }, - ReleaseResult - >; + @post op ReleaseCloudEvents is Azure.Core.RpcOperation<{ + @doc("content type") + @header("content-type") + contentType: "application/json; charset=utf-8"; + + @doc("Topic Name.") + @path + topicName: string; + + @doc("Event Subscription Name.") + @path + eventSubscriptionName: string; + + @doc("ReleaseOptions") + @body + lockTokens : ReleaseOptions; + }, ReleaseResult>; + + // Reject Operation: + // POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject?api-version={apiVersion} @doc("Reject batch of Cloud Events.") @route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject") - @post - op RejectCloudEvents is Azure.Core.RpcOperation< - { - @doc("content type") - @header("content-type") - contentType: "application/json; charset=utf-8"; - - @doc("Topic Name.") - @path - topicName: string; - - @doc("Event Subscription Name.") - @path - eventSubscriptionName: string; - - @doc("RejectOptions") - @body - lockTokens: RejectOptions; - }, - RejectResult - >; + @post op RejectCloudEvents is Azure.Core.RpcOperation<{ + @doc("content type") + @header("content-type") + contentType: "application/json; charset=utf-8"; + + @doc("Topic Name.") + @path + topicName: string; + + @doc("Event Subscription Name.") + @path + eventSubscriptionName: string; + + @doc("RejectOptions") + @body + lockTokens : RejectOptions; + }, RejectResult>; }