public override async Task <DeleteVolumeResponse> DeleteVolume(
            DeleteVolumeRequest request,
            ServerCallContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();
            var id = request.VolumeId;

            using (var _s = logger.StepInformation("{0}, id: {1}", nameof(DeleteVolume), id))
            {
                try
                {
                    await azureFileCsiService.DeleteVolumeAsync(id, request.ControllerDeleteSecrets);
                }
                catch (StorageException ex)
                {
                    logger.LogWarning(ex, "Error from storage service");
                    _s.Commit();
                    throw new RpcException(new Status(StatusCode.InvalidArgument, ex.Message));
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "Exception in DeleteVolume");
                    throw new RpcException(new Status(StatusCode.Internal, ex.Message));
                }

                _s.Commit();
            }

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Lifecycle", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Lifecycle = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("OntapResponse", targetDepth))
                {
                    var unmarshaller = DeleteVolumeOntapResponseUnmarshaller.Instance;
                    response.OntapResponse = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("VolumeId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.VolumeId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Ejemplo n.º 3
0
        private static void DeleteVolume(EvsClient client)
        {
            DeleteVolumeRequest req = new DeleteVolumeRequest()
            {
                VolumeId = "0f17c246-914b-496b-953c-aeaab1fc205c"
            };

            try
            {
                DeleteVolumeResponse resp = client.DeleteVolume(req);
                Console.WriteLine(resp.JobId);
                Console.WriteLine(resp.HttpStatusCode);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
        public override async Task <DeleteVolumeResponse> DeleteVolume(
            DeleteVolumeRequest request,
            ServerCallContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();
            var id = request.VolumeId;

            using (logger.BeginKeyValueScope("volume_id", id))
                using (var _s = logger.StepInformation("{0}", nameof(DeleteVolume)))
                {
                    try
                    {
                        var ctx = new Helpers.Azure.DataProviderContext <ManagedDiskConfig>();
                        await contextConfig.Provide(ctx);

                        var actx = new AzureAuthConfigProviderContext {
                            Secrets = request.ControllerDeleteSecrets
                        };

                        var provisionService = provisionServiceFactory.Create(provider.Provide(actx), ctx.Result.SubscriptionId);
                        await provisionService.DeleteAsync(AzureResourceInnerHelper.CreateForDisk(
                                                               ctx.Result.SubscriptionId, ctx.Result.ResourceGroupName, id));
                    }
                    catch (Exception ex)
                    {
                        logger.LogError(ex, "Exception in DeleteVolume");
                        throw new RpcException(new Status(StatusCode.Internal, ex.Message));
                    }

                    _s.Commit();
                }

            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            context.Read();
            response.DeleteVolumeResult = DeleteVolumeResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
        public static DeleteVolumeResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteVolumeResponse deleteVolumeResponse = new DeleteVolumeResponse();

            deleteVolumeResponse.HttpResponse = context.HttpResponse;
            deleteVolumeResponse.RequestId    = context.StringValue("DeleteVolume.RequestId");

            return(deleteVolumeResponse);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
Ejemplo n.º 8
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            while (context.Read())
            {
            }


            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("VolumeARN", targetDepth))
                {
                    response.VolumeARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>  
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DeleteVolumeResponse response = new DeleteVolumeResponse();

            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            if (context.IsStartOfDocument) 
               targetDepth = 2;

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {

                } 
            }

            return response;
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, DeleteVolumeResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("VolumeARN", targetDepth))
                {
                    context.Read();
                    response.VolumeARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }