public async Task <Response <MsixPackageData> > GetAsync(string subscriptionId, string resourceGroupName, string hostPoolName, string msixPackageFullName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (hostPoolName == null)
            {
                throw new ArgumentNullException(nameof(hostPoolName));
            }
            if (msixPackageFullName == null)
            {
                throw new ArgumentNullException(nameof(msixPackageFullName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, hostPoolName, msixPackageFullName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                MsixPackageData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = MsixPackageData.DeserializeMsixPackageData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal MsixPackageResource(ArmClient client, MsixPackageData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual async Task <ArmOperation <MsixPackageResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string msixPackageFullName, MsixPackageData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(msixPackageFullName, nameof(msixPackageFullName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _msixPackageMSIXPackagesClientDiagnostics.CreateScope("MsixPackageCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _msixPackageMSIXPackagesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, msixPackageFullName, data, cancellationToken).ConfigureAwait(false);

                var operation = new DesktopVirtualizationArmOperation <MsixPackageResource>(Response.FromValue(new MsixPackageResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #4
0
        public virtual ArmOperation <MsixPackage> CreateOrUpdate(bool waitForCompletion, string msixPackageFullName, MsixPackageData msixPackage, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(msixPackageFullName, nameof(msixPackageFullName));
            Argument.AssertNotNull(msixPackage, nameof(msixPackage));

            using var scope = _msixPackageMSIXPackagesClientDiagnostics.CreateScope("MsixPackageCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _msixPackageMSIXPackagesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, msixPackageFullName, msixPackage, cancellationToken);
                var operation = new DesktopVirtualizationArmOperation <MsixPackage>(Response.FromValue(new MsixPackage(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }