// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.resourcehealth.implementation;

import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.resourcehealth.fluent.EventOperationsClient;
import com.azure.resourcemanager.resourcehealth.fluent.models.EventInner;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in EventOperationsClient. */
public final class EventOperationsClientImpl implements EventOperationsClient {
    /** The proxy service used to perform REST calls. */
    private final EventOperationsService service;

    /** The service client containing this operation class. */
    private final MicrosoftResourceHealthImpl client;

    /**
     * Initializes an instance of EventOperationsClientImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    EventOperationsClientImpl(MicrosoftResourceHealthImpl client) {
        this.service =
            RestProxy.create(EventOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for MicrosoftResourceHealthEventOperations to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "MicrosoftResourceHea")
    public interface EventOperationsService {
        @Headers({"Content-Type: application/json"})
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<EventInner>> getBySubscriptionIdAndTrackingId(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @QueryParam("$filter") String filter,
            @QueryParam("queryStartTime") String queryStartTime,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("eventTrackingId") String eventTrackingId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<EventInner>> fetchDetailsBySubscriptionIdAndTrackingId(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("eventTrackingId") String eventTrackingId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get("/providers/Microsoft.ResourceHealth/events/{eventTrackingId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<EventInner>> getByTenantIdAndTrackingId(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @QueryParam("$filter") String filter,
            @QueryParam("queryStartTime") String queryStartTime,
            @PathParam("eventTrackingId") String eventTrackingId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post("/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<EventInner>> fetchDetailsByTenantIdAndTrackingId(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("eventTrackingId") String eventTrackingId,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * Service health event in the subscription by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> getBySubscriptionIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, String filter, String queryStartTime) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getBySubscriptionIdAndTrackingId(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            filter,
                            queryStartTime,
                            this.client.getSubscriptionId(),
                            eventTrackingId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Service health event in the subscription by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> getBySubscriptionIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, String filter, String queryStartTime, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getBySubscriptionIdAndTrackingId(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                filter,
                queryStartTime,
                this.client.getSubscriptionId(),
                eventTrackingId,
                accept,
                context);
    }

    /**
     * Service health event in the subscription by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<EventInner> getBySubscriptionIdAndTrackingIdAsync(String eventTrackingId) {
        final String filter = null;
        final String queryStartTime = null;
        return getBySubscriptionIdAndTrackingIdWithResponseAsync(eventTrackingId, filter, queryStartTime)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Service health event in the subscription by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<EventInner> getBySubscriptionIdAndTrackingIdWithResponse(
        String eventTrackingId, String filter, String queryStartTime, Context context) {
        return getBySubscriptionIdAndTrackingIdWithResponseAsync(eventTrackingId, filter, queryStartTime, context)
            .block();
    }

    /**
     * Service health event in the subscription by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EventInner getBySubscriptionIdAndTrackingId(String eventTrackingId) {
        final String filter = null;
        final String queryStartTime = null;
        return getBySubscriptionIdAndTrackingIdWithResponse(eventTrackingId, filter, queryStartTime, Context.NONE)
            .getValue();
    }

    /**
     * Service health event details in the subscription by event tracking id. This can be used to fetch sensitive
     * properties for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> fetchDetailsBySubscriptionIdAndTrackingIdWithResponseAsync(
        String eventTrackingId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .fetchDetailsBySubscriptionIdAndTrackingId(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            eventTrackingId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Service health event details in the subscription by event tracking id. This can be used to fetch sensitive
     * properties for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> fetchDetailsBySubscriptionIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .fetchDetailsBySubscriptionIdAndTrackingId(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                eventTrackingId,
                accept,
                context);
    }

    /**
     * Service health event details in the subscription by event tracking id. This can be used to fetch sensitive
     * properties for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<EventInner> fetchDetailsBySubscriptionIdAndTrackingIdAsync(String eventTrackingId) {
        return fetchDetailsBySubscriptionIdAndTrackingIdWithResponseAsync(eventTrackingId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Service health event details in the subscription by event tracking id. This can be used to fetch sensitive
     * properties for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<EventInner> fetchDetailsBySubscriptionIdAndTrackingIdWithResponse(
        String eventTrackingId, Context context) {
        return fetchDetailsBySubscriptionIdAndTrackingIdWithResponseAsync(eventTrackingId, context).block();
    }

    /**
     * Service health event details in the subscription by event tracking id. This can be used to fetch sensitive
     * properties for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EventInner fetchDetailsBySubscriptionIdAndTrackingId(String eventTrackingId) {
        return fetchDetailsBySubscriptionIdAndTrackingIdWithResponse(eventTrackingId, Context.NONE).getValue();
    }

    /**
     * Service health event in the tenant by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> getByTenantIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, String filter, String queryStartTime) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByTenantIdAndTrackingId(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            filter,
                            queryStartTime,
                            eventTrackingId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Service health event in the tenant by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> getByTenantIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, String filter, String queryStartTime, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByTenantIdAndTrackingId(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                filter,
                queryStartTime,
                eventTrackingId,
                accept,
                context);
    }

    /**
     * Service health event in the tenant by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<EventInner> getByTenantIdAndTrackingIdAsync(String eventTrackingId) {
        final String filter = null;
        final String queryStartTime = null;
        return getByTenantIdAndTrackingIdWithResponseAsync(eventTrackingId, filter, queryStartTime)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Service health event in the tenant by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param filter The filter to apply on the operation. For more information please see
     *     https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN.
     * @param queryStartTime Specifies from when to return events, based on the lastUpdateTime property. For example,
     *     queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<EventInner> getByTenantIdAndTrackingIdWithResponse(
        String eventTrackingId, String filter, String queryStartTime, Context context) {
        return getByTenantIdAndTrackingIdWithResponseAsync(eventTrackingId, filter, queryStartTime, context).block();
    }

    /**
     * Service health event in the tenant by event tracking id.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EventInner getByTenantIdAndTrackingId(String eventTrackingId) {
        final String filter = null;
        final String queryStartTime = null;
        return getByTenantIdAndTrackingIdWithResponse(eventTrackingId, filter, queryStartTime, Context.NONE).getValue();
    }

    /**
     * Service health event details in the tenant by event tracking id. This can be used to fetch sensitive properties
     * for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> fetchDetailsByTenantIdAndTrackingIdWithResponseAsync(String eventTrackingId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .fetchDetailsByTenantIdAndTrackingId(
                            this.client.getEndpoint(), this.client.getApiVersion(), eventTrackingId, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Service health event details in the tenant by event tracking id. This can be used to fetch sensitive properties
     * for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<EventInner>> fetchDetailsByTenantIdAndTrackingIdWithResponseAsync(
        String eventTrackingId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (eventTrackingId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter eventTrackingId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .fetchDetailsByTenantIdAndTrackingId(
                this.client.getEndpoint(), this.client.getApiVersion(), eventTrackingId, accept, context);
    }

    /**
     * Service health event details in the tenant by event tracking id. This can be used to fetch sensitive properties
     * for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<EventInner> fetchDetailsByTenantIdAndTrackingIdAsync(String eventTrackingId) {
        return fetchDetailsByTenantIdAndTrackingIdWithResponseAsync(eventTrackingId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Service health event details in the tenant by event tracking id. This can be used to fetch sensitive properties
     * for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<EventInner> fetchDetailsByTenantIdAndTrackingIdWithResponse(
        String eventTrackingId, Context context) {
        return fetchDetailsByTenantIdAndTrackingIdWithResponseAsync(eventTrackingId, context).block();
    }

    /**
     * Service health event details in the tenant by event tracking id. This can be used to fetch sensitive properties
     * for Security Advisory events.
     *
     * @param eventTrackingId Event Id which uniquely identifies ServiceHealth event.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return service health event.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public EventInner fetchDetailsByTenantIdAndTrackingId(String eventTrackingId) {
        return fetchDetailsByTenantIdAndTrackingIdWithResponse(eventTrackingId, Context.NONE).getValue();
    }
}
