Skip to content

Commit

Permalink
[TypeSpec CI] Revert formatting check and changes to eventgrid (Azure…
Browse files Browse the repository at this point in the history
…#24430)

- Blocked until microsoft/typespec#2060 is fixed
  • Loading branch information
mikeharder authored and harryli0108 committed Jul 28, 2023
1 parent 740b641 commit d695ba3
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 155 deletions.
3 changes: 2 additions & 1 deletion eng/pipelines/templates/steps/typespec-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
282 changes: 128 additions & 154 deletions specification/eventgrid/Azure.Messaging.EventGrid/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";

@useAuth(ApiKeyAuth<ApiKeyLocation.header, "SharedAccessKey">)
@useAuth(
ApiKeyAuth<ApiKeyLocation.header, "SharedAccessKey">
)

@service({
title: "Azure.Messaging.EventGridClient",
})
Expand All @@ -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",
Expand All @@ -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;
Expand All @@ -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.")
Expand All @@ -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;

Expand Down Expand Up @@ -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")
Expand All @@ -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.")
Expand Down Expand Up @@ -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>;
}

0 comments on commit d695ba3

Please sign in to comment.