/// <summary> /// Initializes an empty volume of a given size /// /// </summary> /// <param name="service">Instance of AmazonEC2 service</param> /// <param name="request">CreateVolumeRequest request</param> public static void InvokeCreateVolume(AmazonEC2 service, CreateVolumeRequest request) { try { CreateVolumeResponse response = service.CreateVolume(request); Console.WriteLine ("Service Response"); Console.WriteLine ("============================================================================="); Console.WriteLine (); Console.WriteLine(" CreateVolumeResponse"); if (response.IsSetCreateVolumeResult()) { Console.WriteLine(" CreateVolumeResult"); CreateVolumeResult createVolumeResult = response.CreateVolumeResult; if (createVolumeResult.IsSetVolume()) { Console.WriteLine(" Volume"); Volume volume = createVolumeResult.Volume; if (volume.IsSetVolumeId()) { Console.WriteLine(" VolumeId"); Console.WriteLine(" {0}", volume.VolumeId); } if (volume.IsSetSize()) { Console.WriteLine(" Size"); Console.WriteLine(" {0}", volume.Size); } if (volume.IsSetSnapshotId()) { Console.WriteLine(" SnapshotId"); Console.WriteLine(" {0}", volume.SnapshotId); } if (volume.IsSetAvailabilityZone()) { Console.WriteLine(" AvailabilityZone"); Console.WriteLine(" {0}", volume.AvailabilityZone); } if (volume.IsSetStatus()) { Console.WriteLine(" Status"); Console.WriteLine(" {0}", volume.Status); } if (volume.IsSetCreateTime()) { Console.WriteLine(" CreateTime"); Console.WriteLine(" {0}", volume.CreateTime); } List<Attachment> attachmentList = volume.Attachment; foreach (Attachment attachment in attachmentList) { Console.WriteLine(" 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); } }