(project, bucket, zone, instance_name, wait=True)
| 144 | |
| 145 | # [START compute_apiary_run] |
| 146 | def main(project, bucket, zone, instance_name, wait=True): |
| 147 | compute = googleapiclient.discovery.build("compute", "v1") |
| 148 | |
| 149 | print("Creating instance.") |
| 150 | |
| 151 | operation = create_instance(compute, project, zone, instance_name, bucket) |
| 152 | wait_for_operation(compute, project, zone, operation["name"]) |
| 153 | |
| 154 | instances = list_instances(compute, project, zone) |
| 155 | |
| 156 | print("Instances in project %s and zone %s:" % (project, zone)) |
| 157 | for instance in instances: |
| 158 | print(" - " + instance["name"]) |
| 159 | |
| 160 | print( |
| 161 | """ |
| 162 | Instance created. |
| 163 | It will take a minute or two for the instance to complete work. |
| 164 | Check this URL: http://storage.googleapis.com/{}/output.png |
| 165 | Once the image is uploaded press enter to delete the instance. |
| 166 | """.format( |
| 167 | bucket |
| 168 | ) |
| 169 | ) |
| 170 | |
| 171 | if wait: |
| 172 | input() |
| 173 | |
| 174 | print("Deleting instance.") |
| 175 | |
| 176 | operation = delete_instance(compute, project, zone, instance_name) |
| 177 | wait_for_operation(compute, project, zone, operation["name"]) |
| 178 | |
| 179 | |
| 180 | if __name__ == "__main__": |
searching dependent graphs…