-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EventGridv2 TypeSpec Api Preview (#23204)
* start typespec * adding eventgrid typespec for api w/ TODOs * update eventgrid typespec with latest eventgrid v2 operations * don't require content-type if there is no body * Update specification/eventgrid/typespec/main.tsp Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * changing naming of cloudevent and added in data_base64 * openapi.json * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <llawrence@microsoft.com> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <llawrence@microsoft.com> * Update specification/eventgrid/typespec/main.tsp Co-authored-by: Libba Lawrence <llawrence@microsoft.com> * lockTokens format, updated json, optional? params * address code review comments * name_change * add @internal for python * Update specification/eventgrid/Azure.Messaging.EventGrid/main.tsp Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * move @internal to client.tsp (#23538) * rename (#23565) * [EventGrid Typespec] breaking changes with april release of typespec (#23539) * breaking changes with april release of typespec * unknown type * [EG Typespec] Update Release behavior (#23699) * update behavior * just behavior * Add tspconfig and remove AAD auth (#23717) * add tspconfig * add namespace * remove oauth * [EG TypeSpec] Archboard Comments (#23696) * refactoring off of apiview * keep as int * no duration * aligning ack and release * remove behavioral change * ack to release * initial naming changes * Update ReleaseResult doc Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * Update AckResult doc Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * versioning twice-- remove one instance --------- Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> * Address couple of stewardship team feedback. These include: 1. Rename CloudEventEvent to simply CloudEvent, 2. Add more description to the operations including the possible erorr codes, 3. Add PublishResult with empty Json object as successful response for the Publish operation, 4. Others. * Add support for missing Reject operation + adding deliveryAttemptCount to BrokerProperties + Adding query parameter for release operation for deliveryDelayInSeconds * Update failedTokens/SuccessfulTokens Description to address code review comments * Update to match service behavior (#23754) * Update to match service behavior * remove locktoken * [EGv2] Editing unused variables (#23917) * event delivery delay not in preview * remove from url comment * [EGv2] Version dependency on Azure.Core (#23936) * verioning fix * spacing mishap? * [EventGrid] Deliveryattempt change (#23960) * deliveryCount 5/1 * small typo * [EventGrid] Remove internal (#23995) * remove internal * remove client.tsp * remove waitWaitTime (#24078) * move location of json file (#24076) * [Egv2] Encode param (#24080) * encode * remove num default on duration --------- Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com> * [EGv2] Fix pipeline (#24098) * regen off new commit for encode * reference preview tag * ignore word * update readme to have both apis * update with next autorest * change format to int32 --------- Co-authored-by: Ashraf Hamad <ahamad@ntdev.microsoft.com> Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: Ashraf Hamad <ahamad-MS@users.noreply.github.com>
- Loading branch information
1 parent
60409c8
commit f6f647a
Showing
5 changed files
with
1,039 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
293 changes: 293 additions & 0 deletions
293
specification/eventgrid/Azure.Messaging.EventGrid/main.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,293 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
import "@typespec/versioning"; | ||
import "@azure-tools/typespec-azure-core"; | ||
|
||
@useAuth( | ||
ApiKeyAuth<ApiKeyLocation.header, "SharedAccessKey"> | ||
) | ||
|
||
@service({ | ||
title: "Azure.Messaging.EventGridClient", | ||
}) | ||
|
||
// | ||
// Supported operations. | ||
// | ||
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}:publish?api-version={apiVersion} | ||
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive?api-Version={apiVersion}&maxWaitTime=60&maxEvents={maxEvents} | ||
// 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", | ||
{ | ||
@doc("The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net") | ||
endpoint: url, | ||
} | ||
) | ||
|
||
@doc("Azure Messaging EventGrid Client") | ||
@versioned(ServiceApiVersions) | ||
namespace Azure.Messaging.EventGrid { | ||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
using TypeSpec.Versioning; | ||
using Azure.Core; | ||
using Azure.Core.Foundations; | ||
|
||
enum ServiceApiVersions { | ||
@useDependency(Azure.Core.Versions.v1_0_Preview_2) | ||
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.") | ||
model CloudEvent { | ||
@doc("An identifier for the event. The combination of id and source must be unique for each distinct event.") | ||
id: string; | ||
|
||
@doc("Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.") | ||
source: string; | ||
|
||
@doc("Event data specific to the event type.") | ||
data?: unknown; | ||
|
||
@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; | ||
|
||
@doc("The time (in UTC) the event was generated, in RFC3339 format.") | ||
time?: utcDateTime; | ||
|
||
@doc("The version of the CloudEvents specification which the event uses.") | ||
specversion: string; | ||
|
||
@doc("Identifies the schema that data adheres to.") | ||
dataschema?: string; | ||
|
||
@doc("Content type of data value.") | ||
datacontenttype?: string; | ||
|
||
@doc("This describes the subject of the event in the context of the event producer (identified by source).") | ||
subject?: string; | ||
} | ||
|
||
@doc("Properties of the Event Broker operation.") | ||
model BrokerProperties { | ||
@doc("The token used to lock the event.") | ||
lockToken: string; | ||
|
||
@doc("The attempt count for delivering the event.") | ||
deliveryCount: int32; | ||
} | ||
|
||
@doc("Receive operation details per Cloud Event.") | ||
model ReceiveDetails { | ||
@doc("The Event Broker details.") | ||
brokerProperties: BrokerProperties; | ||
|
||
@doc("Cloud Event details.") | ||
event: CloudEvent; | ||
} | ||
|
||
@doc("Details of the Receive operation response.") | ||
model ReceiveResult { | ||
@doc("Array of receive responses, one per cloud event.") | ||
value: ReceiveDetails[]; | ||
} | ||
|
||
@doc("Failed LockToken information.") | ||
model FailedLockToken { | ||
@doc("LockToken value") | ||
lockToken: string; | ||
|
||
@doc("Error code related to the token. Example of such error codes are BadToken: which indicates the Token is not formatted correctly, TokenLost: which indicates that token is not found, and InternalServerError: For any internal server errors.") | ||
errorCode: string; | ||
|
||
@doc("Description of the token error.") | ||
errorDescription: string; | ||
} | ||
|
||
@doc("The result of the Publish operation.") | ||
model PublishResult {} | ||
|
||
@doc("The result of the Acknowledge operation.") | ||
model AcknowledgeResult { | ||
@doc("Array of LockToken values for failed cloud events. Each LockToken includes the lock token value along with the related error information (namely, the error code and description).") | ||
failedLockTokens: FailedLockToken[]; | ||
|
||
@doc("Array of lock tokens values for the successfully acknowledged cloud events.") | ||
succeededLockTokens: string[]; | ||
} | ||
|
||
@doc("The result of the Release operation.") | ||
model ReleaseResult { | ||
@doc("Array of LockToken values for failed cloud events. Each LockToken includes the lock token value along with the related error information (namely, the error code and description).") | ||
failedLockTokens: FailedLockToken[]; | ||
|
||
@doc("Array of lock tokens values for the successfully released cloud events.") | ||
succeededLockTokens: string[]; | ||
} | ||
|
||
@doc("The result of the Reject operation.") | ||
model RejectResult { | ||
@doc("Array of LockToken values for failed cloud events. Each LockToken includes the lock token value along with the related error information (namely, the error code and description).") | ||
failedLockTokens: FailedLockToken[]; | ||
|
||
@doc("Array of lock tokens values for the successfully rejected cloud events.") | ||
succeededLockTokens: string[]; | ||
} | ||
|
||
@doc("Array of lock token strings for the corresponding received Cloud Events to be released.") | ||
model ReleaseOptions { | ||
@doc("String array of lock tokens.") | ||
lockTokens: string[]; | ||
} | ||
|
||
@doc("Array of lock token strings for the corresponding received Cloud Events to be acknowledged.") | ||
model AcknowledgeOptions { | ||
@doc("String array of lock tokens.") | ||
lockTokens: string[]; | ||
} | ||
|
||
@doc("Array of lock token strings for the corresponding received Cloud Events to be rejected.") | ||
model RejectOptions { | ||
@doc("String array of lock tokens.") | ||
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>; | ||
|
||
// 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>; | ||
|
||
// 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>; | ||
|
||
// 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>; | ||
|
||
// 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>; | ||
} |
25 changes: 25 additions & 0 deletions
25
specification/eventgrid/Azure.Messaging.EventGrid/tspconfig.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
parameters: | ||
"python-sdk-folder": | ||
default: "{project-root}/azure-sdk-for-python/" | ||
"service-directory-name": | ||
default: "eventgrid" | ||
emit: [ | ||
"@azure-tools/typespec-autorest", | ||
] | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
examples-directory: ./examples | ||
omit-unreachable-types: true | ||
output-file: EventGrid.json | ||
emitter-output-dir: "{project-root}/../data-plane/Microsoft.EventGrid/preview/2023-06-01-preview" | ||
"@azure-tools/typespec-python": | ||
"package-pprint-name": "\"Azure Event Grid\"" | ||
"package-mode": "dataplane" | ||
"package-version": 4.12.0b1 | ||
"package-name": "azure-eventgrid" | ||
"emitter-output-dir": "{python-sdk-folder}/sdk/{service-directory-name}/{package-name}" | ||
# Uncomment this line and add "@azure-tools/typespec-csharp" to your package.json to generate C# code | ||
"@azure-tools/typespec-csharp": | ||
model-namespace: false | ||
generate-convenience-methods: false | ||
namespace: Azure.Messaging.EventGrid.Namespaces |
Oops, something went wrong.