Skip to content

Commit 6d8c6f0

Browse files
Fix README examples (#364)
1 parent 3c4caa0 commit 6d8c6f0

1 file changed

Lines changed: 49 additions & 40 deletions

File tree

README.md

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ $ composer require "toin0u/digitalocean-v2:^5.1" "guzzlehttp/guzzle:^7.9.2"
3333
$ composer require "graham-campbell/digitalocean:^11.1"
3434
```
3535

36-
We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/), [PSR-18](https://www.php-fig.org/psr/psr-18/), and [HTTPlug](https://httplug.io/). You can visit [HTTPlug for library users](https://docs.php-http.org/en/latest/httplug/users.html) to get more information about installing HTTPlug related packages. The framework integration [graham-campbell/gitlab](https://github.com/GrahamCampbell/Laravel-GitLab) is by [Graham Campbell](https://github.com/GrahamCampbell) and [dunglas/digital-ocean-bundle](https://github.com/dunglas/DunglasDigitalOceanBundle) is by [Kévin Dunglas](https://github.com/dunglas).
36+
We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/), [PSR-18](https://www.php-fig.org/psr/psr-18/), and [HTTPlug](https://httplug.io/). You can visit [HTTPlug for library users](https://docs.php-http.org/en/latest/httplug/users.html) to get more information about installing HTTPlug related packages. The framework integration [graham-campbell/digitalocean](https://github.com/GrahamCampbell/Laravel-DigitalOcean) is by [Graham Campbell](https://github.com/GrahamCampbell) and [dunglas/digital-ocean-bundle](https://github.com/dunglas/DunglasDigitalOceanBundle) is by [Kévin Dunglas](https://github.com/dunglas).
3737

3838
## Upgrading
3939

40-
If you are upgrading from version 2.3 to 3.0, or from 3.2 to 4.0, you can check out our [upgrading guide](UPGRADING.md). We highly recommend upgrading as soon as possible.
40+
If you are upgrading from version 2.3 to 3.0, or from 3.3 to 4.0, you can check out our [upgrading guide](UPGRADING.md). We highly recommend upgrading as soon as possible.
4141

4242
## Examples
4343

44-
As of version 3.0, we will will automatically discover an HTTP client to use, from what you have available. Simply create a new DigitalOcean client, provide your access token, then you're good to go:
44+
As of version 3.0, we will automatically discover an HTTP client to use, from what you have available. Simply create a new DigitalOcean client, provide your access token, then you're good to go:
4545

4646
```php
4747
<?php
@@ -103,7 +103,7 @@ $app = $client->app();
103103
$apps = $app->getAll();
104104

105105
// return the App entity 123
106-
$app123 = $app->getById(123);
106+
$app123 = $app->getById('123');
107107

108108
// create a new App
109109
$spec = [
@@ -128,31 +128,31 @@ $spec = [
128128
],
129129
"region" => "ams"
130130
];
131-
$app = $app->create($spec);
131+
$createdApp = $app->create($spec);
132132

133133
// update an App with App entity 123
134-
$app = $app->update(123, $spec);
134+
$updatedApp = $app->update('123', $spec);
135135

136136
// delete an App with App entity 123
137-
$app->remove(123);
137+
$app->remove('123');
138138

139139
// retrieve App deployments with App entity 123
140-
$deployments = $app->getAppDeployments(123);
140+
$deployments = $app->getAppDeployments('123');
141141

142142
// return an App deployment with App entity 123, deployment ID of 456
143-
$deployment = $app->getAppDeployment(123,456);
143+
$deployment = $app->getAppDeployment('123', '456');
144144

145145
// create an App deployment with App entity 123
146-
$deployment = $app->createAppDeployment(123);
146+
$deployment = $app->createAppDeployment('123');
147147

148148
// cancel an App deployment
149-
$deployment = $app->cancelAppDeployment(123,456);
149+
$deployment = $app->cancelAppDeployment('123', '456');
150150

151151
// retrieve deployment logs by component for entity 123, deployment ID of 456, component name of "test_component"
152-
$logs = $app->getDeploymentLogs(123,456,"test_component");
152+
$logs = $app->getDeploymentLogs('123', '456', 'test_component');
153153

154154
// retrieve aggregate deployment logs for entity 123, deployment ID of 456
155-
$logs = $app->getAggregateDeploymentLogs(123,456);
155+
$logs = $app->getAggregateDeploymentLogs('123', '456');
156156

157157
// retrieve App regions
158158
$regions = $app->getRegions();
@@ -161,13 +161,13 @@ $regions = $app->getRegions();
161161
$tiers = $app->getTiers();
162162

163163
// return an App tier by slug with slug name of "test_slug"
164-
$tier = $app->getTierBySlug("test_slug");
164+
$tier = $app->getTierBySlug('test_slug');
165165

166166
// retrieve App instance sizes
167167
$instance_sizes = $app->getInstanceSizes();
168168

169169
// return App instance size by slug with slug name of "test_slug"
170-
$instance_size = $app->getInstanceSizeBySlug("test_slug");
170+
$instanceSize = $app->getInstanceSizeBySlug('test_slug');
171171
```
172172

173173
### Database
@@ -221,7 +221,7 @@ $restored = $database->createClusterFromBackup('cluster-from-backup', ["database
221221
// return a collection of DatabaseReplica entity for cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
222222
$replicas = $database->getAllReplicas('405427f6-393a-4744-817a-2ec6c1b2e2c2');
223223

224-
// return the DatabaseReplica enitity named 'my-replica' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
224+
// return the DatabaseReplica entity named 'my-replica' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
225225
$replica = $database->getReplicaByName('405427f6-393a-4744-817a-2ec6c1b2e2c2', 'my-replica');
226226

227227
// return the created DatabaseReplica entity of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
@@ -239,10 +239,10 @@ $user = $database->getUserByName('405427f6-393a-4744-817a-2ec6c1b2e2c2', 'my-use
239239
// return the created DatabaseUser entity named 'my-user' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
240240
$createdUser = $database->createUser('405427f6-393a-4744-817a-2ec6c1b2e2c2', 'my-user');
241241

242-
// return the created DatabaseUser entity named 'my-user' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2' with optional mysql auth plugin
242+
// return the created DatabaseUser entity named 'my-user-2' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2' with optional mysql auth plugin
243243
$createdUser2 = $database->createUser('405427f6-393a-4744-817a-2ec6c1b2e2c2', 'my-user-2', 'mysql_native_password');
244244

245-
// return the updated DatabaseUser entity named 'my-user' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
245+
// return the updated DatabaseUser entity named 'my-user-2' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
246246
$updatedUser = $database->updateUserMysqlAuthMethod('405427f6-393a-4744-817a-2ec6c1b2e2c2', 'my-user-2', 'caching_sha2_password');
247247

248248
// remove user named 'my-user' of cluster '405427f6-393a-4744-817a-2ec6c1b2e2c2'
@@ -273,7 +273,7 @@ $pool = $database->getConnectionPoolByName('cd2184a9-8f05-49f4-9700-293efb81c7fd
273273
$createdPool = $database->createConnectionPool('cd2184a9-8f05-49f4-9700-293efb81c7fd', 'my-pool', 'transaction', 1, 'defaultdb', 'doadmin');
274274

275275
// remove pool named 'my-pool' of cluster 'cd2184a9-8f05-49f4-9700-293efb81c7fd'
276-
$pools = $database->removeConnectionPool('cd2184a9-8f05-49f4-9700-293efb81c7fd', 'my-pool');
276+
$database->removeConnectionPool('cd2184a9-8f05-49f4-9700-293efb81c7fd', 'my-pool');
277277

278278

279279
// ** Only for Redis Database Clusters ** //
@@ -356,7 +356,7 @@ $domainRecord123 = $domainRecord->getById('foo.dk', 123);
356356
// return the created DomainRecord entity of the domain 'bar.dk'
357357
$created = $domainRecord->create('bar.dk', 'AAAA', 'bar-name', '2001:db8::ff00:42:8329');
358358

359-
// return the DomainRecord entity 123 of the domain 'baz.dk' updated with new-name, new-data, priority 1, port 2, weight 3, flags 0, tag issue (name, data, priority, port, weight, flags and tag are nullable)
359+
// return the DomainRecord entity 123 of the domain 'baz.dk' updated with new-name, new-data, priority 1, port 2, weight 3, flags 0, tag issue (name, data, priority, port, weight, flags, tag, and ttl are nullable)
360360
$updated = $domainRecord->update('baz.dk', 123, 'new-name', 'new-data', 1, 2, 3, 0, 'issue');
361361

362362
// remove domain record 123 of the domain 'qmx.dk'
@@ -372,6 +372,15 @@ $droplet = $client->droplet();
372372
// return a collection of Droplet entity
373373
$droplets = $droplet->getAll();
374374

375+
// return a collection of Droplet entity filtered by tag
376+
$droplets = $droplet->getAllByTag('awesome');
377+
378+
// return a collection of Droplet entity filtered by exact name
379+
$droplets = $droplet->getAllByName('example.com');
380+
381+
// return a collection of GPU Droplet entity
382+
$droplets = $droplet->getAllByType('gpus');
383+
375384
// return a collection of Droplet neighbor to Droplet entity 123
376385
$droplets = $droplet->getNeighborsById(123);
377386

@@ -406,7 +415,7 @@ $backups = $droplet->getBackups(123);
406415
$actions = $droplet->getActions(123);
407416

408417
// return the Action entity 456 of the droplet 123
409-
$action123 = $droplet->getActionById(123, 456);
418+
$action456 = $droplet->getActionById(123, 456);
410419

411420
// reboot droplet 123 and return the Action entity
412421
$rebooted = $droplet->reboot(123);
@@ -426,8 +435,8 @@ $powerOn = $droplet->powerOn(123);
426435
// reset password droplet 123 and return the Action entity
427436
$passwordReseted = $droplet->passwordReset(123);
428437

429-
// resize droplet 123 with the image 789 and return the Action entity
430-
$resized = $droplet->resize(123, 789);
438+
// resize droplet 123 to size s-1vcpu-2gb and return the Action entity
439+
$resized = $droplet->resize(123, 's-1vcpu-2gb');
431440

432441
// restore droplet 123 with the image 789 and return the Action entity
433442
$restored = $droplet->restore(123, 789);
@@ -438,7 +447,7 @@ $rebuilt = $droplet->rebuild(123, 789);
438447
// rename droplet 123 to 'new-name' and return the Action entity
439448
$renamed = $droplet->rename(123, 'new-name');
440449

441-
// take a snapshot of droplet 123 and name it 'my-snapshot'. Returns the an Action entity
450+
// take a snapshot of droplet 123 and name it 'my-snapshot'. Returns an Action entity
442451
$snapshot = $droplet->snapshot(123, 'my-snapshot');
443452

444453
// change kernel to droplet 123 with kernel 321 and return the Action entity
@@ -477,7 +486,7 @@ $outboundRules = [
477486
];
478487

479488
$dropletId = 123;
480-
$firewall = $firewall->create(
489+
$createdFirewall = $firewall->create(
481490
strval($dropletId) . '-firewall', $inboundRules, $outboundRules, [$dropletId]
482491
);
483492

@@ -559,16 +568,16 @@ $keys = $key->getAll();
559568
$key123 = $key->getById(123);
560569

561570
// return the Key entity with the given fingerprint
562-
$key = $key->getByFingerprint('f5:de:eb:64:2d:6a:b6:d5:bb:06:47:7f:04:4b:f8:e2');
571+
$keyByFingerprint = $key->getByFingerprint('f5:de:eb:64:2d:6a:b6:d5:bb:06:47:7f:04:4b:f8:e2');
563572

564573
// return the created Key entity
565574
$createdKey = $key->create('my-key', 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDPrtBjQaNBwDSV3ePC86zaEWu0....');
566575

567576
// return the updated Key entity
568-
$updatedKey = $key->update(123, 'new-key-name');
577+
$updatedKey = $key->update('123', 'new-key-name');
569578

570579
// return void if removed successfully
571-
$key->remove(123);
580+
$key->remove('123');
572581
```
573582

574583
### Load Balancer
@@ -584,15 +593,15 @@ $loadBalancers = $loadBalancer->getAll();
584593
$myLoadBalancer = $loadBalancer->getById('506f78a4-e098-11e5-ad9f-000f53306ae1');
585594

586595
/**
587-
* updates an existing load balancer, the method will except a LoadBalancer
588-
* entity or a load balancer representation in array form, the digitial
589-
* Ocean API requires a full representation of your load
596+
* updates an existing load balancer, the method will accept a LoadBalancer
597+
* entity or a load balancer representation in array form, the DigitalOcean
598+
* API requires a full representation of your load
590599
* balancer, any attribute that is missing will
591-
* be reset to it's default setting.
600+
* be reset to its default setting.
592601
*/
593602
$myUpdatedLoadBalancer = $loadBalancer->update('506f78a4-e098-11e5-ad9f-000f53306ae1', $myLoadBalancer);
594603

595-
//create a standard load balancer that listens on port 80 and 443 with ssl passthrough enabled
604+
//create a standard load balancer
596605
$myNewLoadBalancer = $loadBalancer->create('my-new-load-balancer', 'nyc1');
597606
```
598607

@@ -680,10 +689,10 @@ $tag = $client->tag();
680689
$tags = $tag->getAll();
681690

682691
// return a Tag entity by name
683-
$tag = $tag->getByName('awesome');
692+
$tagEntity = $tag->getByName('awesome');
684693

685694
// create a tag
686-
$tag = $tag->create('awesome');
695+
$createdTag = $tag->create('awesome');
687696

688697
// tag resources
689698
$tag->tagResources('awesome', [["resource_id" => "9569411", "resource_type" => "droplet"]]);
@@ -701,10 +710,10 @@ $tag->remove('awesome');
701710
// return the volume api
702711
$volume = $client->volume();
703712

704-
// returns the all volumes
713+
// returns all volumes
705714
$volumes = $volume->getAll();
706715

707-
// returns the all volumes by region
716+
// returns all volumes by region
708717
$volumes = $volume->getAll('nyc1');
709718

710719
// returns volumes by name and region
@@ -713,7 +722,7 @@ $volumes = $volume->getByNameAndRegion('example', 'nyc1');
713722
// returns a volume by id
714723
$myvolume = $volume->getById('506f78a4-e098-11e5-ad9f-000f53306ae1');
715724

716-
// returns a volumes snapshots by volume id
725+
// returns a volume's snapshots by volume id
717726
$mySnapshots = $volume->getSnapshots('506f78a4-e098-11e5-ad9f-000f53306ae1');
718727

719728
// creates a volume
@@ -738,7 +747,7 @@ $volume->resize('506f78a4-e098-11e5-ad9f-000f53306ae1', 20, 'nyc1');
738747
$snapshot = $volume->snapshot('506f78a4-e098-11e5-ad9f-000f53306ae1', 'my-snapshot');
739748

740749
// get a volume action by its id
741-
$volume->getActionById(123, '506f78a4-e098-11e5-ad9f-000f53306ae1');
750+
$volume->getActionById('506f78a4-e098-11e5-ad9f-000f53306ae1', 123);
742751

743752
// get all actions related to a volume
744753
$volume->getActions('506f78a4-e098-11e5-ad9f-000f53306ae1');
@@ -750,7 +759,7 @@ $volume->getActions('506f78a4-e098-11e5-ad9f-000f53306ae1');
750759
// return the VPC api
751760
$vpc = $client->vpc();
752761

753-
// returns the all VPCs
762+
// returns all VPCs
754763
$vpcs = $vpc->getAll();
755764
```
756765

0 commit comments

Comments
 (0)