Esempio n. 1
0
        /// <summary>
        /// Detach a previously attached volume from a running instance.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonEC2 service</param>
        /// <param name="request">DetachVolumeRequest request</param>
        public static void InvokeDetachVolume(AmazonEC2 service, DetachVolumeRequest request)
        {
            try 
            {
                DetachVolumeResponse response = service.DetachVolume(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        DetachVolumeResponse");
                if (response.IsSetDetachVolumeResult())
                {
                    Console.WriteLine("            DetachVolumeResult");
                    DetachVolumeResult  detachVolumeResult = response.DetachVolumeResult;
                    if (detachVolumeResult.IsSetAttachment())
                    {
                        Console.WriteLine("                Attachment");
                        Attachment  attachment = detachVolumeResult.Attachment;
                        if (attachment.IsSetVolumeId())
                        {
                            Console.WriteLine("                    VolumeId");
                            Console.WriteLine("                        {0}", attachment.VolumeId);
                        }
                        if (attachment.IsSetInstanceId())
                        {
                            Console.WriteLine("                    InstanceId");
                            Console.WriteLine("                        {0}", attachment.InstanceId);
                        }
                        if (attachment.IsSetDevice())
                        {
                            Console.WriteLine("                    Device");
                            Console.WriteLine("                        {0}", attachment.Device);
                        }
                        if (attachment.IsSetStatus())
                        {
                            Console.WriteLine("                    Status");
                            Console.WriteLine("                        {0}", attachment.Status);
                        }
                        if (attachment.IsSetAttachTime())
                        {
                            Console.WriteLine("                    AttachTime");
                            Console.WriteLine("                        {0}", attachment.AttachTime);
                        }
                    }
                }
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

            } 
            catch (AmazonEC2Exception ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }