diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs index 09243e3087b1..0886537e42a4 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridModelFactory.cs @@ -1860,5 +1860,16 @@ public static ApiManagementApiReleaseDeletedEventData ApiManagementApiReleaseDel { return new ApiManagementApiReleaseDeletedEventData(resourceUri); } + + /// Initializes a new instance of FhirResourceEventBaseProperties. + /// Type of HL7 FHIR resource. + /// Domain name of FHIR account for this resource. + /// Id of HL7 FHIR resource. + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + /// A new instance for mocking. + public static FhirResourceEventBaseProperties FhirResourceEventBaseProperties(string resourceType = null, string resourceFhirAccount = null, string resourceFhirId = null, long? resourceVersionId = null) + { + return new FhirResourceEventBaseProperties(resourceType, resourceFhirAccount, resourceFhirId, resourceVersionId); + } } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridRestClient.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridRestClient.cs index 1d0527215cb2..4f4c87154945 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridRestClient.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/EventGridRestClient.cs @@ -36,7 +36,7 @@ public EventGridRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pip _apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion)); } - internal HttpMessage CreatePublishEventsRequest(string topicHostname, IEnumerable events) + internal HttpMessage CreatePublishEventGridEventsRequest(string topicHostname, IEnumerable events) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -44,7 +44,6 @@ internal HttpMessage CreatePublishEventsRequest(string topicHostname, IEnumerabl var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); uri.AppendRaw(topicHostname, false); - uri.AppendPath("/api/events", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); @@ -64,7 +63,7 @@ internal HttpMessage CreatePublishEventsRequest(string topicHostname, IEnumerabl /// An array of events to be published to Event Grid. /// The cancellation token to use. /// or is null. - public async Task PublishEventsAsync(string topicHostname, IEnumerable events, CancellationToken cancellationToken = default) + public async Task PublishEventGridEventsAsync(string topicHostname, IEnumerable events, CancellationToken cancellationToken = default) { if (topicHostname == null) { @@ -75,7 +74,7 @@ public async Task PublishEventsAsync(string topicHostname, IEnumerable throw new ArgumentNullException(nameof(events)); } - using var message = CreatePublishEventsRequest(topicHostname, events); + using var message = CreatePublishEventGridEventsRequest(topicHostname, events); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -91,7 +90,7 @@ public async Task PublishEventsAsync(string topicHostname, IEnumerable /// An array of events to be published to Event Grid. /// The cancellation token to use. /// or is null. - public Response PublishEvents(string topicHostname, IEnumerable events, CancellationToken cancellationToken = default) + public Response PublishEventGridEvents(string topicHostname, IEnumerable events, CancellationToken cancellationToken = default) { if (topicHostname == null) { @@ -102,7 +101,7 @@ public Response PublishEvents(string topicHostname, IEnumerable + +#nullable disable + +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Azure.Core; + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + [JsonConverter(typeof(FhirResourceCreatedEventDataConverter))] + public partial class FhirResourceCreatedEventData + { + internal static FhirResourceCreatedEventData DeserializeFhirResourceCreatedEventData(JsonElement element) + { + Optional resourceType = default; + Optional resourceFhirAccount = default; + Optional resourceFhirId = default; + Optional resourceVersionId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceType")) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirAccount")) + { + resourceFhirAccount = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirId")) + { + resourceFhirId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceVersionId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + resourceVersionId = property.Value.GetInt64(); + continue; + } + } + return new FhirResourceCreatedEventData(resourceType.Value, resourceFhirAccount.Value, resourceFhirId.Value, Optional.ToNullable(resourceVersionId)); + } + + internal partial class FhirResourceCreatedEventDataConverter : JsonConverter + { + public override void Write(Utf8JsonWriter writer, FhirResourceCreatedEventData model, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + public override FhirResourceCreatedEventData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + using var document = JsonDocument.ParseValue(ref reader); + return DeserializeFhirResourceCreatedEventData(document.RootElement); + } + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceCreatedEventData.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceCreatedEventData.cs new file mode 100644 index 000000000000..5376cb6da13f --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceCreatedEventData.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + /// Schema of the Data property of an EventGridEvent for a Microsoft.HealthcareApis.FhirResourceCreated event. + public partial class FhirResourceCreatedEventData : FhirResourceEventBaseProperties + { + /// Initializes a new instance of FhirResourceCreatedEventData. + internal FhirResourceCreatedEventData() + { + } + + /// Initializes a new instance of FhirResourceCreatedEventData. + /// Type of HL7 FHIR resource. + /// Domain name of FHIR account for this resource. + /// Id of HL7 FHIR resource. + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + internal FhirResourceCreatedEventData(string resourceType, string resourceFhirAccount, string resourceFhirId, long? resourceVersionId) : base(resourceType, resourceFhirAccount, resourceFhirId, resourceVersionId) + { + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.Serialization.cs new file mode 100644 index 000000000000..f1781fe13662 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.Serialization.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Azure.Core; + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + [JsonConverter(typeof(FhirResourceDeletedEventDataConverter))] + public partial class FhirResourceDeletedEventData + { + internal static FhirResourceDeletedEventData DeserializeFhirResourceDeletedEventData(JsonElement element) + { + Optional resourceType = default; + Optional resourceFhirAccount = default; + Optional resourceFhirId = default; + Optional resourceVersionId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceType")) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirAccount")) + { + resourceFhirAccount = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirId")) + { + resourceFhirId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceVersionId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + resourceVersionId = property.Value.GetInt64(); + continue; + } + } + return new FhirResourceDeletedEventData(resourceType.Value, resourceFhirAccount.Value, resourceFhirId.Value, Optional.ToNullable(resourceVersionId)); + } + + internal partial class FhirResourceDeletedEventDataConverter : JsonConverter + { + public override void Write(Utf8JsonWriter writer, FhirResourceDeletedEventData model, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + public override FhirResourceDeletedEventData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + using var document = JsonDocument.ParseValue(ref reader); + return DeserializeFhirResourceDeletedEventData(document.RootElement); + } + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.cs new file mode 100644 index 000000000000..031d2a0da6c6 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceDeletedEventData.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + /// Schema of the Data property of an EventGridEvent for a Microsoft.HealthcareApis.FhirResourceDeleted event. + public partial class FhirResourceDeletedEventData : FhirResourceEventBaseProperties + { + /// Initializes a new instance of FhirResourceDeletedEventData. + internal FhirResourceDeletedEventData() + { + } + + /// Initializes a new instance of FhirResourceDeletedEventData. + /// Type of HL7 FHIR resource. + /// Domain name of FHIR account for this resource. + /// Id of HL7 FHIR resource. + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + internal FhirResourceDeletedEventData(string resourceType, string resourceFhirAccount, string resourceFhirId, long? resourceVersionId) : base(resourceType, resourceFhirAccount, resourceFhirId, resourceVersionId) + { + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.Serialization.cs new file mode 100644 index 000000000000..9e00f38ee07f --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.Serialization.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + public partial class FhirResourceEventBaseProperties + { + internal static FhirResourceEventBaseProperties DeserializeFhirResourceEventBaseProperties(JsonElement element) + { + Optional resourceType = default; + Optional resourceFhirAccount = default; + Optional resourceFhirId = default; + Optional resourceVersionId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceType")) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirAccount")) + { + resourceFhirAccount = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirId")) + { + resourceFhirId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceVersionId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + resourceVersionId = property.Value.GetInt64(); + continue; + } + } + return new FhirResourceEventBaseProperties(resourceType.Value, resourceFhirAccount.Value, resourceFhirId.Value, Optional.ToNullable(resourceVersionId)); + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.cs new file mode 100644 index 000000000000..692ef5c0d948 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceEventBaseProperties.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + /// Schema of common properties of all FhirResource events. + public partial class FhirResourceEventBaseProperties + { + /// Initializes a new instance of FhirResourceEventBaseProperties. + internal FhirResourceEventBaseProperties() + { + } + + /// Initializes a new instance of FhirResourceEventBaseProperties. + /// Type of HL7 FHIR resource. + /// Domain name of FHIR account for this resource. + /// Id of HL7 FHIR resource. + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + internal FhirResourceEventBaseProperties(string resourceType, string resourceFhirAccount, string resourceFhirId, long? resourceVersionId) + { + ResourceType = resourceType; + ResourceFhirAccount = resourceFhirAccount; + ResourceFhirId = resourceFhirId; + ResourceVersionId = resourceVersionId; + } + + /// Type of HL7 FHIR resource. + public string ResourceType { get; } + /// Domain name of FHIR account for this resource. + public string ResourceFhirAccount { get; } + /// Id of HL7 FHIR resource. + public string ResourceFhirId { get; } + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + public long? ResourceVersionId { get; } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.Serialization.cs new file mode 100644 index 000000000000..e6f0e073929e --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.Serialization.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Azure.Core; + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + [JsonConverter(typeof(FhirResourceUpdatedEventDataConverter))] + public partial class FhirResourceUpdatedEventData + { + internal static FhirResourceUpdatedEventData DeserializeFhirResourceUpdatedEventData(JsonElement element) + { + Optional resourceType = default; + Optional resourceFhirAccount = default; + Optional resourceFhirId = default; + Optional resourceVersionId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceType")) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirAccount")) + { + resourceFhirAccount = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceFhirId")) + { + resourceFhirId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceVersionId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + resourceVersionId = property.Value.GetInt64(); + continue; + } + } + return new FhirResourceUpdatedEventData(resourceType.Value, resourceFhirAccount.Value, resourceFhirId.Value, Optional.ToNullable(resourceVersionId)); + } + + internal partial class FhirResourceUpdatedEventDataConverter : JsonConverter + { + public override void Write(Utf8JsonWriter writer, FhirResourceUpdatedEventData model, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + public override FhirResourceUpdatedEventData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + using var document = JsonDocument.ParseValue(ref reader); + return DeserializeFhirResourceUpdatedEventData(document.RootElement); + } + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.cs new file mode 100644 index 000000000000..e0b038963eab --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Generated/Models/FhirResourceUpdatedEventData.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Messaging.EventGrid.SystemEvents +{ + /// Schema of the Data property of an EventGridEvent for a Microsoft.HealthcareApis.FhirResourceUpdated event. + public partial class FhirResourceUpdatedEventData : FhirResourceEventBaseProperties + { + /// Initializes a new instance of FhirResourceUpdatedEventData. + internal FhirResourceUpdatedEventData() + { + } + + /// Initializes a new instance of FhirResourceUpdatedEventData. + /// Type of HL7 FHIR resource. + /// Domain name of FHIR account for this resource. + /// Id of HL7 FHIR resource. + /// VersionId of HL7 FHIR resource. It changes when the resource is created, updated, or deleted(soft-deletion). + internal FhirResourceUpdatedEventData(string resourceType, string resourceFhirAccount, string resourceFhirId, long? resourceVersionId) : base(resourceType, resourceFhirAccount, resourceFhirId, resourceVersionId) + { + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md index 751cccfd2b6b..2bc8ac59e49b 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/autorest.md @@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code. ``` yaml title: EventGridClient -require: https://github.com/Azure/azure-rest-api-specs/blob/6b29b8552671eded065f51ee1b291582ab8cc149/specification/eventgrid/data-plane/readme.md +require: https://github.com/Azure/azure-rest-api-specs/blob/6328c50d37143d107bca4a0c7c3bc2ca1458dd5a/specification/eventgrid/data-plane/readme.md ``` ## Swagger workarounds