Exemple #1
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);
            }
        }
        private static void ListSnapshotsDetails(EvsClient client)
        {
            ListSnapshotsDetailsRequest req = new ListSnapshotsDetailsRequest()
            {
                ServiceType = "EVS",
                Limit       = 2,
                Offset      = 0,
                Name        = "test"
            };

            try
            {
                ListSnapshotsDetailsResponse resp = client.ListSnapshotsDetails(req);
                Console.WriteLine(resp.Count);
                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);
            }
        }
Exemple #3
0
        static void Main1(string[] args)
        {
            const string ak        = "{your ak string}";
            const string sk        = "{your sk string}";
            const string endpoint  = "{your endpoint}";
            const string projectId = "{your project id}";

            var config = HttpConfig.GetDefaultConfig();

            config.IgnoreSslVerification = true;
            var auth      = new BasicCredentials(ak, sk, projectId);
            var evsClient = EvsClient.NewBuilder()
                            .WithCredential(auth)
                            .WithEndPoint(endpoint)
                            .WithHttpConfig(config).Build();

            ShowVolume(evsClient);
            CreateVolume(evsClient);
            ResizeVolume(evsClient);
            ListVolumesDetails(evsClient);
            UpdateVolume(evsClient);
            DeleteVolume(evsClient);
            CinderListVolumeTypes(evsClient);
            CinderExportToImage(evsClient);
            CinderListQuotas(evsClient);
            CinderListAvailabilityZones(evsClient);
        }
        private static void ListVolumeTags(EvsClient client)
        {
            var req = new ListVolumeTagsRequest();

            try
            {
                var resp = client.ListVolumeTags(req);
                Console.WriteLine(resp.Tags);
                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);
            }
        }
Exemple #5
0
        private static void CinderListQuotas(EvsClient client)
        {
            CinderListQuotasRequest req = new CinderListQuotasRequest()
            {
                TargetProjectId = "0605767c2e80d5762fd0c0146a10aaf2",
                Usage           = CinderListQuotasRequest.UsageEnum.TRUE
            };

            try
            {
                CinderListQuotasResponse resp = client.CinderListQuotas(req);
                Console.WriteLine(resp.QuotaSet);
                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);
            }
        }
        private static void ShowVolumeTags(EvsClient client)
        {
            var req = new ShowVolumeTagsRequest()
            {
                VolumeId = "04495fb2-f1e8-40aa-8725-c197a246376d"
            };

            try
            {
                var resp = client.ShowVolumeTags(req);
                Console.WriteLine(resp.Tags);
                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);
            }
        }
        private static void ShowSnapshot(EvsClient client)
        {
            ShowSnapshotRequest req = new ShowSnapshotRequest()
            {
                SnapshotId = "fc5281ca-5a1b-4193-814f-514cb5d303e7"
            };

            try
            {
                ShowSnapshotResponse resp = client.ShowSnapshot(req);
                Console.WriteLine(resp.Snapshot);
                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);
            }
        }
Exemple #8
0
        private static void ShowVolume(EvsClient client)
        {
            ShowVolumeRequest req = new ShowVolumeRequest()
            {
                VolumeId = "8da11134-0614-40e2-8792-3437c66cc90d"
            };

            try
            {
                ShowVolumeResponse resp = client.ShowVolume(req);
                Console.WriteLine(resp.Volume);
                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);
            }
        }
Exemple #9
0
        private static void ListVolumesDetails(EvsClient client)
        {
            ListVolumesDetailsRequest req = new ListVolumesDetailsRequest()
            {
                AvailabilityZone = "br-iaas-odin1a",
                ServiceType      = "EVS",
                Limit            = 2,
                Offset           = 0,
                Name             = "test"
            };

            try
            {
                var resp = client.ListVolumesDetails(req);
                Console.WriteLine(resp.Count);
                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);
            }
        }
Exemple #10
0
        private static void ResizeVolume(EvsClient client)
        {
            var req = new ResizeVolumeRequest()
            {
                VolumeId = "3c759440-0552-4a5f-9c40-782ace254314",
                Body     = new ResizeVolumeRequestBody()
                {
                    OsExtend = new OsExtend()
                    {
                        NewSize = 50
                    }
                }
            };

            try
            {
                var resp = client.ResizeVolume(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);
            }
        }
Exemple #11
0
        private static void CinderListAvailabilityZones(EvsClient client)
        {
            CinderListAvailabilityZonesRequest req = new CinderListAvailabilityZonesRequest()
            {
            };

            try
            {
                CinderListAvailabilityZonesResponse resp = client.CinderListAvailabilityZones(req);
                Console.WriteLine(resp.AvailabilityZoneInfo);
                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);
            }
        }
Exemple #12
0
        private static void ShowJob(EvsClient client)
        {
            ShowJobRequest req = new ShowJobRequest()
            {
                JobId = "ff80808170a8a1370170aa1e21eb349a"
            };

            try
            {
                ShowJobResponse resp = client.ShowJob(req);
                Console.WriteLine(resp.Status);
                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);
            }
        }
        private static void RollbackSnapshot(EvsClient client)
        {
            RollbackSnapshotRequest req = new RollbackSnapshotRequest()
            {
                SnapshotId = "fc5281ca-5a1b-4193-814f-514cb5d303e7",
                Body       = new RollbackSnapshotRequestBody()
                {
                    Rollback = new RollbackSnapshotOption()
                    {
                        VolumeId = "1bebb541-5601-450f-a87a-55f9a3c8327b"
                    }
                }
            };

            try
            {
                RollbackSnapshotResponse resp = client.RollbackSnapshot(req);
                Console.WriteLine(resp.Rollback);
                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);
            }
        }
Exemple #14
0
        static void Main1(string[] args)
        {
            const string ak        = "{your ak string}";
            const string sk        = "{your sk string}";
            const string endpoint  = "{your endpoint}";
            const string projectId = "{your project id}";

            var config = HttpConfig.GetDefaultConfig();

            config.IgnoreSslVerification = true;
            var auth      = new BasicCredentials(ak, sk, projectId);
            var evsClient = EvsClient.NewBuilder()
                            .WithCredential(auth)
                            .WithEndPoint(endpoint)
                            .WithHttpConfig(config).Build();

            ShowJob(evsClient);
        }
        private static void ListVolumesByTags(EvsClient client)
        {
            ListVolumesByTagsRequest req = new ListVolumesByTagsRequest()
            {
                Body = new ListVolumesByTagsRequestBody()
                {
                    Action = ListVolumesByTagsRequestBody.ActionEnum.FILTER,
                    Limit  = 10,
                    Offset = 0,
                    Tags   = new List <TagsForListVolumes>
                    {
                        new TagsForListVolumes
                        {
                            Key    = "123",
                            Values = new List <string>()
                            {
                                "456"
                            }
                        }
                    }
                }
            };

            try
            {
                ListVolumesByTagsResponse resp = client.ListVolumesByTags(req);
                Console.WriteLine(resp.TotalCount);
                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);
            }
        }
Exemple #16
0
        private static void CreateVolume(EvsClient client)
        {
            CreateVolumeRequest req = new CreateVolumeRequest()
            {
                Body = new CreateVolumeRequestBody
                {
                    Volume = new CreateVolumeOption()
                    {
                        AvailabilityZone = "br-iaas-odin1a",
                        Count            = 1,
                        Size             = 40,
                        VolumeType       = "SATA",
                        Description      = "csharp",
                        Name             = "test"
                    }
                }
            };

            try
            {
                CreateVolumeResponse resp = client.CreateVolume(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);
            }
        }
Exemple #17
0
        private static void CinderExportToImage(EvsClient client)
        {
            CinderExportToImageRequest req = new CinderExportToImageRequest()
            {
                VolumeId = "1bebb541-5601-450f-a87a-55f9a3c8327b",
                Body     = new CinderExportToImageRequestBody
                {
                    OsVolumeUploadImage = new CinderExportToImageOption
                    {
                        DiskFormat      = CinderExportToImageOption.DiskFormatEnum.VHD,
                        Force           = false,
                        ImageName       = "test",
                        OsType          = CinderExportToImageOption.OsTypeEnum.LINUX,
                        ContainerFormat = CinderExportToImageOption.ContainerFormatEnum.BARE
                    }
                }
            };

            try
            {
                CinderExportToImageResponse resp = client.CinderExportToImage(req);
                Console.WriteLine(resp.OsVolumeUploadImage);
                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);
            }
        }
        private static void BatchCreateVolumeTags(EvsClient client)
        {
            var req = new BatchCreateVolumeTagsRequest()
            {
                VolumeId = "04495fb2-f1e8-40aa-8725-c197a246376d",
                Body     = new BatchCreateVolumeTagsRequestBody()
                {
                    Action = BatchCreateVolumeTagsRequestBody.ActionEnum.CREATE,
                    Tags   = new List <HuaweiCloud.SDK.Evs.V2.Model.Tag>
                    {
                        new HuaweiCloud.SDK.Evs.V2.Model.Tag()
                        {
                            Key   = "123",
                            Value = "456"
                        }
                    }
                }
            };

            try
            {
                var resp = client.BatchCreateVolumeTags(req);
                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);
            }
        }
        private static void BatchDeleteVolumeTags(EvsClient client)
        {
            var req = new BatchDeleteVolumeTagsRequest()
            {
                VolumeId = "04495fb2-f1e8-40aa-8725-c197a246376d",
                Body     = new BatchDeleteVolumeTagsRequestBody()
                {
                    Action = BatchDeleteVolumeTagsRequestBody.ActionEnum.DELETE,
                    Tags   = new List <DeleteTagsOption>()
                    {
                        new DeleteTagsOption()
                        {
                            Key = "123"
                        }
                    }
                }
            };

            try
            {
                var resp = client.BatchDeleteVolumeTags(req);
                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);
            }
        }
        private static void CreateSnapshot(EvsClient client)
        {
            CreateSnapshotRequest req = new CreateSnapshotRequest()
            {
                Body = new CreateSnapshotRequestBody()
                {
                    Snapshot = new CreateSnapshotOption()
                    {
                        VolumeId    = "1bebb541-5601-450f-a87a-55f9a3c8327b",
                        Description = "test",
                        Name        = "test",
                        Force       = false
                    }
                }
            };

            try
            {
                CreateSnapshotResponse resp = client.CreateSnapshot(req);
                Console.WriteLine(resp.Snapshot);
                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);
            }
        }
Exemple #21
0
        private static void UpdateVolume(EvsClient client)
        {
            UpdateVolumeRequest req = new UpdateVolumeRequest()
            {
                VolumeId = "3c759440-0552-4a5f-9c40-782ace254314",
                Body     = new UpdateVolumeRequestBody
                {
                    Volume = new UpdateVolumeOption()
                    {
                        Name        = "update",
                        Description = "update"
                    }
                }
            };

            try
            {
                UpdateVolumeResponse resp = client.UpdateVolume(req);
                Console.WriteLine(resp.Id);
                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);
            }
        }
        private static void UpdateSnapshot(EvsClient client)
        {
            UpdateSnapshotRequest req = new UpdateSnapshotRequest()
            {
                SnapshotId = "fc5281ca-5a1b-4193-814f-514cb5d303e7",
                Body       = new UpdateSnapshotRequestBody()
                {
                    Snapshot = new UpdateSnapshotOption()
                    {
                        Name        = "test_update",
                        Description = "test_update"
                    }
                }
            };

            try
            {
                UpdateSnapshotResponse resp = client.UpdateSnapshot(req);
                Console.WriteLine(resp.Snapshot);
                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);
            }
        }