public void CorrectRequestForGetActions() { var factory = Substitute.For <IConnection>(); var volumeActionsClient = new VolumeActionsClient(factory); volumeActionsClient.GetActions("id"); var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id"); factory.Received().GetPaginated <Action>("volumes/{id}/actions", parameters, "action"); }
public void CorrectRequestForGetAction() { var factory = Substitute.For <IConnection>(); var volumeActionsClient = new VolumeActionsClient(factory); volumeActionsClient.GetAction("id", 0); var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id" && (long)list[1].Value == 0); factory.Received().ExecuteRequest <Action>("volumes/{id}/actions/{actionId}", parameters, null, "action"); }
public void CorrectRequestForResize() { var factory = Substitute.For <IConnection>(); var volumeActionsClient = new VolumeActionsClient(factory); volumeActionsClient.Resize("id", 0, "nyc3"); var parameters = Arg.Is <List <Parameter> >(list => (string)list[0].Value == "id"); var body = Arg.Is <Models.Requests.VolumeAction>(action => action.Type == "resize" && action.SizeGigabytes == 0 && action.Region == "nyc3"); factory.Received().ExecuteRequest <Action>("volumes/{id}/actions", parameters, body, "action", Method.POST); }
public void CorrectRequestForCreateDetachByName() { var factory = Substitute.For <IConnection>(); var volumeActionsClient = new VolumeActionsClient(factory); volumeActionsClient.DetachByName("name", 0, "nyc3"); var body = Arg.Is <Models.Requests.VolumeAction>(action => action.Type == "detach" && action.DropletId == 0 && action.VolumeName == "name" && action.Region == "nyc3"); factory.Received().ExecuteRequest <Action>("volumes/actions", null, body, "action", Method.POST); }
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); }