File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
compute/cloud-client/instances/src Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 28
28
use Google \Cloud \Compute \V1 \AttachedDiskInitializeParams ;
29
29
use Google \Cloud \Compute \V1 \Instance ;
30
30
use Google \Cloud \Compute \V1 \NetworkInterface ;
31
+ use Google \Cloud \Compute \V1 \ZoneOperationsClient ;
31
32
32
33
/**
33
34
* Creates an instance.
@@ -76,7 +77,11 @@ function create_instance(
76
77
$ instancesClient = new InstancesClient ();
77
78
$ operation = $ instancesClient ->insert ($ instance , $ projectId , $ zone );
78
79
79
- /** TODO: wait until operation completes */
80
+ if ($ operation ->getStatus () === 'RUNNING ' ) {
81
+ // Wait until operation completes
82
+ $ operationClient = new ZoneOperationsClient ();
83
+ $ operationClient ->wait ($ operation ->getName (), $ projectId , $ zone );
84
+ }
80
85
81
86
printf ('Created instance %s ' . PHP_EOL , $ instanceName );
82
87
}
Original file line number Diff line number Diff line change 24
24
namespace Google \Cloud \Samples \Compute ;
25
25
26
26
use Google \Cloud \Compute \V1 \InstancesClient ;
27
+ use Google \Cloud \Compute \V1 \ZoneOperationsClient ;
27
28
28
29
/**
29
30
* Creates an instance.
@@ -45,7 +46,11 @@ function delete_instance(
45
46
$ instancesClient = new InstancesClient ();
46
47
$ operation = $ instancesClient ->delete ($ instanceName , $ projectId , $ zone );
47
48
48
- /** TODO: wait until operation completes */
49
+ if ($ operation ->getStatus () === 'RUNNING ' ) {
50
+ // Wait until operation completes
51
+ $ operationClient = new ZoneOperationsClient ();
52
+ $ operationClient ->wait ($ operation ->getName (), $ projectId , $ zone );
53
+ }
49
54
50
55
printf ('Deleted instance %s ' . PHP_EOL , $ instanceName );
51
56
}
You can’t perform that action at this time.
0 commit comments