Beispiel #1
0
        public DigitalOceanClient(string token)
        {
            var client = new RestClient(DigitalOceanApiUrl)
            {
                UserAgent = "digitalocean-api-dotnet"
            };

            client.AddDefaultHeader("Authorization", $"Bearer {token}");

            _connection = new Connection(client);

            Actions           = new ActionsClient(_connection);
            DomainRecords     = new DomainRecordsClient(_connection);
            Domains           = new DomainsClient(_connection);
            DropletActions    = new DropletActionsClient(_connection);
            Droplets          = new DropletsClient(_connection);
            FloatingIps       = new FloatingIpsClient(_connection);
            FloatingIpActions = new FloatingIpActionsClient(_connection);
            ImageActions      = new ImageActionsClient(_connection);
            Images            = new ImagesClient(_connection);
            Keys      = new KeysClient(_connection);
            Regions   = new RegionsClient(_connection);
            Sizes     = new SizesClient(_connection);
            Snapshots = new SnapshotsClient(_connection);
            Tags      = new TagsClient(_connection);
            Volumes   = new VolumesClient(_connection);
        }
        public void CorrectRequestForGetAll()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            volumesClient.GetAll();
            factory.Received().GetPaginated <Volume>("volumes", null, "volumes");
        }
        public void CorrectRequestForCreate()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            var data = new Models.Requests.Volume();

            volumesClient.Create(data);
            factory.Received().ExecuteRequest <Volume>("volumes", null, data, "volume", Method.POST);
        }
        public void CorrectRequestForDelete()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            volumesClient.Delete("id");

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id");

            factory.Received().ExecuteRaw("volumes/{id}", parameters, null, Method.DELETE);
        }
        public void CorrectRequestForGetSnapshots()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            volumesClient.GetSnapshots("id");

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id");

            factory.Received().GetPaginated <Snapshot>("volumes/{id}/snapshots", parameters, "snapshots");
        }
        public void CorrectRequestForGetByName()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            volumesClient.GetByName("name", "region");

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "name" && (string)list[1].Value == "region");

            factory.Received().GetPaginated <Volume>("volumes", parameters, "volumes");
        }
        public void CorrectRequestForCreateSnapshot()
        {
            var factory       = Substitute.For <IConnection>();
            var volumesClient = new VolumesClient(factory);

            var snapshot = new Models.Requests.VolumeSnapshot();

            volumesClient.CreateSnapshot("id", snapshot);

            var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id");

            factory.Received().ExecuteRequest <Snapshot>("volumes/{id}/snapshots", parameters, snapshot, "snapshot", Method.POST);
        }
Beispiel #8
0
        public DigitalOceanClient(string token)
        {
            var client = new RestClient(DigitalOceanApiUrl)
            {
                UserAgent = "digitalocean-api-dotnet"
            };

            client.AddDefaultHeader("Authorization", string.Format("Bearer {0}", token));

            _connection = new Connection(client);

            Account           = new AccountClient(_connection);
            Actions           = new ActionsClient(_connection);
            CdnEndpoints      = new CdnEndpointsClient(_connection);
            Certificates      = new CertificatesClient(_connection);
            ContainerRegistry = new ContainerRegistryClient(_connection);
            Databases         = new DatabasesClient(_connection);
            DomainRecords     = new DomainRecordsClient(_connection);
            Domains           = new DomainsClient(_connection);
            DropletActions    = new DropletActionsClient(_connection);
            Droplets          = new DropletsClient(_connection);
            Firewalls         = new FirewallsClient(_connection);
            FloatingIpActions = new FloatingIpActionsClient(_connection);
            FloatingIps       = new FloatingIpsClient(_connection);
            ImageActions      = new ImageActionsClient(_connection);
            Images            = new ImagesClient(_connection);
            LoadBalancers     = new LoadBalancerClient(_connection);
            Projects          = new ProjectsClient(_connection);
            ProjectResources  = new ProjectResourcesClient(_connection);
            Keys          = new KeysClient(_connection);
            Kubernetes    = new KubernetesClient(_connection);
            Regions       = new RegionsClient(_connection);
            Sizes         = new SizesClient(_connection);
            Snapshots     = new SnapshotsClient(_connection);
            Tags          = new TagsClient(_connection);
            Volumes       = new VolumesClient(_connection);
            VolumeActions = new VolumeActionsClient(_connection);
            BalanceClient = new BalanceClient(_connection);
            Vpc           = new VpcClient(_connection);
        }