/* Code generated by Azure.Iot.Operations.ProtocolCompilerLib v1.0.0.0; DO NOT EDIT. */

#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Azure.Iot.Operations.Protocol.Models;
using Azure.Iot.Operations.Protocol;
using Azure.Iot.Operations.Protocol.RPC;
using Azure.Iot.Operations.Protocol.Telemetry;
using Azure.Iot.Operations.Services.EdgeRegistry.Host.Generated.Common;

namespace Azure.Iot.Operations.Services.EdgeRegistry.Host.Generated
{
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public static partial class EdgeRegistry
    {
        public abstract partial class Service : IAsyncDisposable
        {
            private ApplicationContext applicationContext;
            private IMqttPubSubClient mqttClient;
            private readonly CreateGroupActionExecutor createGroupActionExecutor;
            private readonly GetGroupActionExecutor getGroupActionExecutor;
            private readonly ListGroupsActionExecutor listGroupsActionExecutor;
            private readonly DeleteGroupActionExecutor deleteGroupActionExecutor;
            private readonly CreateResourceActionExecutor createResourceActionExecutor;
            private readonly GetResourceActionExecutor getResourceActionExecutor;
            private readonly ListResourcesActionExecutor listResourcesActionExecutor;
            private readonly DeleteResourceActionExecutor deleteResourceActionExecutor;
            private readonly CreateVersionActionExecutor createVersionActionExecutor;
            private readonly GetVersionActionExecutor getVersionActionExecutor;
            private readonly ListVersionsActionExecutor listVersionsActionExecutor;
            private readonly DeleteVersionActionExecutor deleteVersionActionExecutor;

            /// <summary>
            /// Construct a new instance of this service.
            /// </summary>
            /// <param name="applicationContext">The shared context for your application.</param>
            /// <param name="mqttClient">The MQTT client to use.</param>
            /// <param name="topicTokenMap">
            /// The topic token replacement map to use for all operations by default. Generally, this will include the token values
            /// for topic tokens that should be the same for the duration of this service's lifetime. Note that
            /// additional topic tokens can be specified per event message.
            /// </param>
            public Service(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, Dictionary<string, string>? topicTokenMap = null)
            {
                this.applicationContext = applicationContext;
                this.mqttClient = mqttClient;

                string? clientId = this.mqttClient.ClientId;
                if (string.IsNullOrEmpty(clientId))
                {
                    throw new InvalidOperationException("No MQTT client Id configured. Must connect to MQTT broker before invoking command.");
                }

                this.createGroupActionExecutor = new CreateGroupActionExecutor(applicationContext, mqttClient) { OnCommandReceived = CreateGroupInt };
                this.getGroupActionExecutor = new GetGroupActionExecutor(applicationContext, mqttClient) { OnCommandReceived = GetGroupInt };
                this.listGroupsActionExecutor = new ListGroupsActionExecutor(applicationContext, mqttClient) { OnCommandReceived = ListGroupsInt };
                this.deleteGroupActionExecutor = new DeleteGroupActionExecutor(applicationContext, mqttClient) { OnCommandReceived = DeleteGroupInt };
                this.createResourceActionExecutor = new CreateResourceActionExecutor(applicationContext, mqttClient) { OnCommandReceived = CreateResourceInt };
                this.getResourceActionExecutor = new GetResourceActionExecutor(applicationContext, mqttClient) { OnCommandReceived = GetResourceInt };
                this.listResourcesActionExecutor = new ListResourcesActionExecutor(applicationContext, mqttClient) { OnCommandReceived = ListResourcesInt };
                this.deleteResourceActionExecutor = new DeleteResourceActionExecutor(applicationContext, mqttClient) { OnCommandReceived = DeleteResourceInt };
                this.createVersionActionExecutor = new CreateVersionActionExecutor(applicationContext, mqttClient) { OnCommandReceived = CreateVersionInt };
                this.getVersionActionExecutor = new GetVersionActionExecutor(applicationContext, mqttClient) { OnCommandReceived = GetVersionInt };
                this.listVersionsActionExecutor = new ListVersionsActionExecutor(applicationContext, mqttClient) { OnCommandReceived = ListVersionsInt };
                this.deleteVersionActionExecutor = new DeleteVersionActionExecutor(applicationContext, mqttClient) { OnCommandReceived = DeleteVersionInt };

                if (topicTokenMap != null)
                {
                    foreach (string topicTokenKey in topicTokenMap.Keys)
                    {
                        this.createGroupActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.getGroupActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.listGroupsActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.deleteGroupActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.createResourceActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.getResourceActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.listResourcesActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.deleteResourceActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.createVersionActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.getVersionActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.listVersionsActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                        this.deleteVersionActionExecutor.TopicTokenMap.TryAdd("ex:" + topicTokenKey, topicTokenMap[topicTokenKey]);
                    }
                }

                this.createGroupActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.getGroupActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.listGroupsActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.deleteGroupActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.createResourceActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.getResourceActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.listResourcesActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.deleteResourceActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.createVersionActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.getVersionActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.listVersionsActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
                this.deleteVersionActionExecutor.TopicTokenMap.TryAdd("executorId", clientId);
            }

            public CreateGroupActionExecutor CreateGroupActionExecutor { get => this.createGroupActionExecutor; }

            public GetGroupActionExecutor GetGroupActionExecutor { get => this.getGroupActionExecutor; }

            public ListGroupsActionExecutor ListGroupsActionExecutor { get => this.listGroupsActionExecutor; }

            public DeleteGroupActionExecutor DeleteGroupActionExecutor { get => this.deleteGroupActionExecutor; }

            public CreateResourceActionExecutor CreateResourceActionExecutor { get => this.createResourceActionExecutor; }

            public GetResourceActionExecutor GetResourceActionExecutor { get => this.getResourceActionExecutor; }

            public ListResourcesActionExecutor ListResourcesActionExecutor { get => this.listResourcesActionExecutor; }

            public DeleteResourceActionExecutor DeleteResourceActionExecutor { get => this.deleteResourceActionExecutor; }

            public CreateVersionActionExecutor CreateVersionActionExecutor { get => this.createVersionActionExecutor; }

            public GetVersionActionExecutor GetVersionActionExecutor { get => this.getVersionActionExecutor; }

            public ListVersionsActionExecutor ListVersionsActionExecutor { get => this.listVersionsActionExecutor; }

            public DeleteVersionActionExecutor DeleteVersionActionExecutor { get => this.deleteVersionActionExecutor; }

            public abstract Task<ExtendedResponse<CreateGroupOutputArguments>> CreateGroupAsync(CreateGroupInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<GetGroupOutputArguments>> GetGroupAsync(GetGroupInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<ListGroupsOutputArguments>> ListGroupsAsync(CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<EmptyJson>> DeleteGroupAsync(DeleteGroupInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<CreateResourceOutputArguments>> CreateResourceAsync(CreateResourceInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<GetResourceOutputArguments>> GetResourceAsync(GetResourceInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<ListResourcesOutputArguments>> ListResourcesAsync(ListResourcesInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<EmptyJson>> DeleteResourceAsync(DeleteResourceInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<CreateVersionOutputArguments>> CreateVersionAsync(CreateVersionInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<GetVersionOutputArguments>> GetVersionAsync(GetVersionInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<ListVersionsOutputArguments>> ListVersionsAsync(ListVersionsInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            public abstract Task<ExtendedResponse<EmptyJson>> DeleteVersionAsync(DeleteVersionInputArguments request, CommandRequestMetadata requestMetadata, CancellationToken cancellationToken);

            /// <summary>
            /// Begin accepting command invocations for all command executors.
            /// </summary>
            /// <param name="preferredDispatchConcurrency">The dispatch concurrency count for the command response cache to use.</param>
            /// <param name="cancellationToken">Cancellation token.</param>
            public async Task StartAsync(int? preferredDispatchConcurrency = null, CancellationToken cancellationToken = default)
            {
                string? clientId = this.mqttClient.ClientId;
                if (string.IsNullOrEmpty(clientId))
                {
                    throw new InvalidOperationException("No MQTT client Id configured. Must connect to MQTT broker before starting service.");
                }

                await Task.WhenAll(
                    this.createGroupActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.getGroupActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.listGroupsActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.deleteGroupActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.createResourceActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.getResourceActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.listResourcesActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.deleteResourceActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.createVersionActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.getVersionActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.listVersionsActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken),
                    this.deleteVersionActionExecutor.StartAsync(preferredDispatchConcurrency, cancellationToken)).ConfigureAwait(false);
            }

            public async Task StopAsync(CancellationToken cancellationToken = default)
            {
                await Task.WhenAll(
                    this.createGroupActionExecutor.StopAsync(cancellationToken),
                    this.getGroupActionExecutor.StopAsync(cancellationToken),
                    this.listGroupsActionExecutor.StopAsync(cancellationToken),
                    this.deleteGroupActionExecutor.StopAsync(cancellationToken),
                    this.createResourceActionExecutor.StopAsync(cancellationToken),
                    this.getResourceActionExecutor.StopAsync(cancellationToken),
                    this.listResourcesActionExecutor.StopAsync(cancellationToken),
                    this.deleteResourceActionExecutor.StopAsync(cancellationToken),
                    this.createVersionActionExecutor.StopAsync(cancellationToken),
                    this.getVersionActionExecutor.StopAsync(cancellationToken),
                    this.listVersionsActionExecutor.StopAsync(cancellationToken),
                    this.deleteVersionActionExecutor.StopAsync(cancellationToken)).ConfigureAwait(false);
            }

            private async Task<ExtendedResponse<CreateGroupResponseSchema>> CreateGroupInt(ExtendedRequest<CreateGroupInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<CreateGroupOutputArguments> extended = await this.CreateGroupAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<CreateGroupResponseSchema>
                    {
                        Response = new CreateGroupResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<CreateGroupResponseSchema> extendedResponse = ExtendedResponse<CreateGroupResponseSchema>.CreateFromResponse(new CreateGroupResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<GetGroupResponseSchema>> GetGroupInt(ExtendedRequest<GetGroupInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<GetGroupOutputArguments> extended = await this.GetGroupAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<GetGroupResponseSchema>
                    {
                        Response = new GetGroupResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<GetGroupResponseSchema> extendedResponse = ExtendedResponse<GetGroupResponseSchema>.CreateFromResponse(new GetGroupResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<ListGroupsResponseSchema>> ListGroupsInt(ExtendedRequest<EmptyJson> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<ListGroupsOutputArguments> extended = await this.ListGroupsAsync(req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<ListGroupsResponseSchema>
                    {
                        Response = new ListGroupsResponseSchema
                        {
                            Ids = extended.Response.Ids,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<ListGroupsResponseSchema> extendedResponse = ExtendedResponse<ListGroupsResponseSchema>.CreateFromResponse(new ListGroupsResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<DeleteGroupResponseSchema>> DeleteGroupInt(ExtendedRequest<DeleteGroupInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<EmptyJson> extended = await this.DeleteGroupAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<DeleteGroupResponseSchema>
                    {
                        Response = new DeleteGroupResponseSchema
                        {
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<DeleteGroupResponseSchema> extendedResponse = ExtendedResponse<DeleteGroupResponseSchema>.CreateFromResponse(new DeleteGroupResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<CreateResourceResponseSchema>> CreateResourceInt(ExtendedRequest<CreateResourceInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<CreateResourceOutputArguments> extended = await this.CreateResourceAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<CreateResourceResponseSchema>
                    {
                        Response = new CreateResourceResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<CreateResourceResponseSchema> extendedResponse = ExtendedResponse<CreateResourceResponseSchema>.CreateFromResponse(new CreateResourceResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<GetResourceResponseSchema>> GetResourceInt(ExtendedRequest<GetResourceInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<GetResourceOutputArguments> extended = await this.GetResourceAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<GetResourceResponseSchema>
                    {
                        Response = new GetResourceResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<GetResourceResponseSchema> extendedResponse = ExtendedResponse<GetResourceResponseSchema>.CreateFromResponse(new GetResourceResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<ListResourcesResponseSchema>> ListResourcesInt(ExtendedRequest<ListResourcesInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<ListResourcesOutputArguments> extended = await this.ListResourcesAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<ListResourcesResponseSchema>
                    {
                        Response = new ListResourcesResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<ListResourcesResponseSchema> extendedResponse = ExtendedResponse<ListResourcesResponseSchema>.CreateFromResponse(new ListResourcesResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<DeleteResourceResponseSchema>> DeleteResourceInt(ExtendedRequest<DeleteResourceInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<EmptyJson> extended = await this.DeleteResourceAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<DeleteResourceResponseSchema>
                    {
                        Response = new DeleteResourceResponseSchema
                        {
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<DeleteResourceResponseSchema> extendedResponse = ExtendedResponse<DeleteResourceResponseSchema>.CreateFromResponse(new DeleteResourceResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<CreateVersionResponseSchema>> CreateVersionInt(ExtendedRequest<CreateVersionInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<CreateVersionOutputArguments> extended = await this.CreateVersionAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<CreateVersionResponseSchema>
                    {
                        Response = new CreateVersionResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<CreateVersionResponseSchema> extendedResponse = ExtendedResponse<CreateVersionResponseSchema>.CreateFromResponse(new CreateVersionResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<GetVersionResponseSchema>> GetVersionInt(ExtendedRequest<GetVersionInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<GetVersionOutputArguments> extended = await this.GetVersionAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<GetVersionResponseSchema>
                    {
                        Response = new GetVersionResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<GetVersionResponseSchema> extendedResponse = ExtendedResponse<GetVersionResponseSchema>.CreateFromResponse(new GetVersionResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<ListVersionsResponseSchema>> ListVersionsInt(ExtendedRequest<ListVersionsInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<ListVersionsOutputArguments> extended = await this.ListVersionsAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<ListVersionsResponseSchema>
                    {
                        Response = new ListVersionsResponseSchema
                        {
                            Output = extended.Response,
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<ListVersionsResponseSchema> extendedResponse = ExtendedResponse<ListVersionsResponseSchema>.CreateFromResponse(new ListVersionsResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            private async Task<ExtendedResponse<DeleteVersionResponseSchema>> DeleteVersionInt(ExtendedRequest<DeleteVersionInputArguments> req, CancellationToken cancellationToken)
            {
                try
                {
                    ExtendedResponse<EmptyJson> extended = await this.DeleteVersionAsync(req.Request!, req.RequestMetadata!, cancellationToken);

                    return new ExtendedResponse<DeleteVersionResponseSchema>
                    {
                        Response = new DeleteVersionResponseSchema
                        {
                        },
                        ResponseMetadata = extended.ResponseMetadata,
                    };
                }
                catch (EdgeRegistryErrorException intEx)
                {
                    ExtendedResponse<DeleteVersionResponseSchema> extendedResponse = ExtendedResponse<DeleteVersionResponseSchema>.CreateFromResponse(new DeleteVersionResponseSchema { Error = intEx.EdgeRegistryError });
                    return extendedResponse;
                }
            }

            public async ValueTask DisposeAsync()
            {
                await this.createGroupActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.getGroupActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.listGroupsActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.deleteGroupActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.createResourceActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.getResourceActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.listResourcesActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.deleteResourceActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.createVersionActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.getVersionActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.listVersionsActionExecutor.DisposeAsync().ConfigureAwait(false);
                await this.deleteVersionActionExecutor.DisposeAsync().ConfigureAwait(false);
            }

            public async ValueTask DisposeAsync(bool disposing, CancellationToken cancellationToken = default)
            {
                await this.createGroupActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.getGroupActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.listGroupsActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.deleteGroupActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.createResourceActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.getResourceActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.listResourcesActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.deleteResourceActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.createVersionActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.getVersionActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.listVersionsActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
                await this.deleteVersionActionExecutor.DisposeAsync(disposing, cancellationToken).ConfigureAwait(false);
            }
        }
    }
}
