Skip to content

Commit

Permalink
[EG] GA client.tsp updates (Azure#29208)
Browse files Browse the repository at this point in the history
* try this

* ver

* update

* details

* update

* renew locks result rename

* add new version - testing

* remove diff

* ga version

* update

* try alias

* all operations mark as internal to allow for topic/sub customization

* remove

* tsp format

* alias change

* details

* changes

* after merge required regen

* nit

* try

* tsp format

* edits off of lang

* only python

* nit

* Fixing some names for Go, based on Go arch feedback.

* One more rename

* Update specification/eventgrid/Azure.Messaging.EventGrid/client.tsp

* fixing go diff

* update

* update internal

---------

Co-authored-by: ripark <ripark@microsoft.com>
  • Loading branch information
l0lawrence and ripark authored Jun 3, 2024
1 parent bf97382 commit 8713240
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 293 deletions.
146 changes: 143 additions & 3 deletions specification/eventgrid/Azure.Messaging.EventGrid/client.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,148 @@
import "@azure-tools/typespec-client-generator-core";
import "./main.tsp";
import "@typespec/versioning";

using Azure.ClientGenerator.Core;
using Microsoft.EventGrid;

@@access(Microsoft.EventGrid.publishCloudEvent, Access.internal, "python");
@@access(Microsoft.EventGrid.publishCloudEvents, Access.internal, "python");
@@access(Microsoft.EventGrid.receiveCloudEvents, Access.internal, "python");
@TypeSpec.Versioning.useDependency(ServiceApiVersions.v2024_06_01)
namespace Customizations {
@client(
{
name: "EventGridPublisherClient",
service: Microsoft.EventGrid,
},
"python"
)
interface Client1 {
send is publishCloudEvent;
sendEvents is publishCloudEvents;
}

@client(
{
name: "EventGridConsumerClient",
service: Microsoft.EventGrid,
},
"python"
)
interface Client2 {
receive is receiveCloudEvents;
acknowledge is acknowledgeCloudEvents;
release is releaseCloudEvents;
reject is rejectCloudEvents;
renewLocks is renewCloudEventLocks;
}

@client(
{
name: "EventGridSenderClient",
service: Microsoft.EventGrid,
},
"csharp"
)
interface ClientSender {
send is publishCloudEvent;
sendEvents is publishCloudEvents;
}

@client(
{
name: "EventGridReceiverClient",
service: Microsoft.EventGrid,
},
"csharp"
)
interface ClientReceiver {
receive is receiveCloudEvents;
acknowledge is acknowledgeCloudEvents;
release is releaseCloudEvents;
reject is rejectCloudEvents;
renewLocks is renewCloudEventLocks;
}

@client(
{
name: "EventGridSenderClient",
service: Microsoft.EventGrid,
},
"java"
)
interface ClientSender2 {
send is publishCloudEvent;
sendEvents is publishCloudEvents;
}

@client(
{
name: "EventGridReceiverClient",
service: Microsoft.EventGrid,
},
"java"
)
interface ClientReceiver2 {
receive is receiveCloudEvents;
acknowledge is acknowledgeCloudEvents;
release is releaseCloudEvents;
reject is rejectCloudEvents;
renewLocks is renewCloudEventLocks;
}

@client(
{
name: "SenderClient",
service: Microsoft.EventGrid,
},
"go"
)
interface ClientSenderGo {
sendEvent is publishCloudEvent;
sendEvents is publishCloudEvents;
}

@client(
{
name: "ReceiverClient",
service: Microsoft.EventGrid,
},
"go"
)
interface ClientReceiverGo {
receiveEvents is receiveCloudEvents;
acknowledgeEvents is acknowledgeCloudEvents;
releaseEvents is releaseCloudEvents;
rejectEvents is rejectCloudEvents;
renewEventLocks is renewCloudEventLocks;
}
}

// All Language customizations

// publishCloudEvent access level
@@access(publishCloudEvent, Access.internal, "python");

// publishCloudEvents access level
@@access(publishCloudEvents, Access.internal, "python");

@@access(receiveCloudEvents, Access.internal, "python");
@@access(acknowledgeCloudEvents, Access.internal, "python");
@@access(releaseCloudEvents, Access.internal, "python");
@@access(rejectCloudEvents, Access.internal, "python");
@@access(renewCloudEventLocks, Access.internal, "python");

@@access(AcknowledgeResult, Access.public);
@@access(ReleaseResult, Access.public);
@@access(RejectResult, Access.public);
@@access(RenewCloudEventLocksResult, Access.public);
@@access(ReleaseDelay, Access.public);
@@access(FailedLockToken, Access.public);

@@clientName(ReleaseDelay.By0Seconds, "NoDelay");
@@clientName(ReleaseDelay.By10Seconds, "TenSeconds");
@@clientName(ReleaseDelay.By3600Seconds, "OneHour");
@@clientName(ReleaseDelay.By600Seconds, "TenMinutes");
@@clientName(ReleaseDelay.By60Seconds, "OneMinute");

@@clientName(RenewCloudEventLocksResult, "RenewLocksResult");

@@clientName(ReceiveResult.value, "details");
36 changes: 12 additions & 24 deletions specification/eventgrid/Azure.Messaging.EventGrid/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,25 @@ namespace Microsoft.EventGrid {
succeededLockTokens: string[];
}

@doc("Array of lock tokens for the corresponding received Cloud Events to be released.")
model ReleaseOptions {
alias ReleaseOptions = {
@doc("Array of lock tokens.")
lockTokens: string[];
}
};

@doc("Array of lock tokens for the corresponding received Cloud Events to be acknowledged.")
model AcknowledgeOptions {
alias AcknowledgeOptions = {
@doc("Array of lock tokens.")
lockTokens: string[];
}
};

@doc("Array of lock tokens for the corresponding received Cloud Events to be rejected.")
model RejectOptions {
alias RejectOptions = {
@doc("Array of lock tokens.")
lockTokens: string[];
}
};

@doc("Array of lock tokens for the corresponding received Cloud Events to be renewed.")
model RenewLockOptions {
alias RenewLockOptions = {
@doc("Array of lock tokens.")
lockTokens: string[];
}
};

@doc("Topic Resource.")
@resource("topics")
Expand Down Expand Up @@ -304,9 +300,7 @@ namespace Microsoft.EventGrid {
op acknowledgeCloudEvents is StandardOperations.ResourceAction<
EventSubscription,
{
@doc("AcknowledgeOptions.")
@bodyRoot
acknowledgeOptions: AcknowledgeOptions;
...AcknowledgeOptions;
},
AcknowledgeResult
>;
Expand All @@ -319,9 +313,7 @@ namespace Microsoft.EventGrid {
op releaseCloudEvents is StandardOperations.ResourceAction<
EventSubscription,
{
@doc("ReleaseOptions")
@bodyRoot
releaseOptions: ReleaseOptions;
...ReleaseOptions;

@added(ServiceApiVersions.v2023_10_01_preview)
@removed(ServiceApiVersions.v2023_11_01)
Expand All @@ -341,9 +333,7 @@ namespace Microsoft.EventGrid {
op rejectCloudEvents is StandardOperations.ResourceAction<
EventSubscription,
{
@doc("RejectOptions")
@bodyRoot
rejectOptions: RejectOptions;
...RejectOptions;
},
RejectResult
>;
Expand All @@ -358,9 +348,7 @@ namespace Microsoft.EventGrid {
op renewCloudEventLocks is StandardOperations.ResourceAction<
EventSubscription,
{
@doc("RenewLockOptions")
@bodyRoot
renewLockOptions: RenewLockOptions;
...RenewLockOptions;
},
RenewCloudEventLocksResult
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,23 @@
"type": "string"
},
{
"name": "acknowledgeOptions",
"name": "body",
"in": "body",
"description": "AcknowledgeOptions.",
"required": true,
"schema": {
"$ref": "#/definitions/AcknowledgeOptions"
"type": "object",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
}
}
],
Expand Down Expand Up @@ -254,12 +265,23 @@
"type": "string"
},
{
"name": "releaseOptions",
"name": "body",
"in": "body",
"description": "ReleaseOptions",
"required": true,
"schema": {
"$ref": "#/definitions/ReleaseOptions"
"type": "object",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
}
}
],
Expand Down Expand Up @@ -313,12 +335,23 @@
"type": "string"
},
{
"name": "rejectOptions",
"name": "body",
"in": "body",
"description": "RejectOptions",
"required": true,
"schema": {
"$ref": "#/definitions/RejectOptions"
"type": "object",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
}
}
],
Expand Down Expand Up @@ -411,22 +444,6 @@
}
},
"definitions": {
"AcknowledgeOptions": {
"type": "object",
"description": "Array of lock tokens for the corresponding received Cloud Events to be acknowledged.",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
},
"AcknowledgeResult": {
"type": "object",
"description": "The result of the Acknowledge operation.",
Expand Down Expand Up @@ -642,22 +659,6 @@
"value"
]
},
"RejectOptions": {
"type": "object",
"description": "Array of lock tokens for the corresponding received Cloud Events to be rejected.",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
},
"RejectResult": {
"type": "object",
"description": "The result of the Reject operation.",
Expand All @@ -683,22 +684,6 @@
"succeededLockTokens"
]
},
"ReleaseOptions": {
"type": "object",
"description": "Array of lock tokens for the corresponding received Cloud Events to be released.",
"properties": {
"lockTokens": {
"type": "array",
"description": "Array of lock tokens.",
"items": {
"type": "string"
}
}
},
"required": [
"lockTokens"
]
},
"ReleaseResult": {
"type": "object",
"description": "The result of the Release operation.",
Expand Down
Loading

0 comments on commit 8713240

Please sign in to comment.