<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap:break-word;line-break:after-white-space"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">I’m trying to figure out the Google Cloud API, specifically the Python library.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">I have a shell script that works using `gcloud compute …` commands, but I’ve been asked to add some functionality. At this point, I’m going to move it to Python for the additional structure/objects/data types etc. (My options are shell or Python.)</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">With the `gcloud` shell command, specifying a zone is optional. This works great for the shell script. I don’t care about the zone, I just need to iterate over all the instances in a project. However, it seems that with the library/API approach, zone is _not_ optional[1]. This would leave me with the very bad position of having to get a list of all zones (that’s doable), iterating over each zone looking for instances.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">The python API so far looks to me like a bit of a second class pile of nonsense that probably (very) loosely wraps around something else. For example, you have to create the resource type objects from two strings, like so:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="margin:0px"><span class="Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre">        </span>crm = googleapiclient.discovery.build(&#39;cloudresourcemanager&#39;, ‘v1&#39;)</div><div id="bloop_customfont" style="margin:0px"><div id="bloop_customfont" style="margin:0px"><span class="Apple-tab-span" style="white-space:pre">        </span>compute = googleapiclient.discovery.build(&#39;compute&#39;, ‘v1’)</div><div id="bloop_customfont" style="margin:0px"><br></div></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Get the list of projects?</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="margin:0px"><span class="Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre">        </span>projects = crm.projects().list().execute()[&#39;projects&#39;]</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Get the project’s instances?</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="margin:0px"><span class="Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre">        </span>compute.instances().list(project=‘projectid&#39;, zone=&#39;us-central1-?&#39;).execute()</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Am I missing something, especially w/r/t the zone is optional vs required depending on your gcloud vs python lib? Is there a better Python library than the one that Google provides?</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Thanks!</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">[1] <a href="https://cloud.google.com/compute/docs/reference/rest/beta/instances/list">https://cloud.google.com/compute/docs/reference/rest/beta/instances/list</a></div><br><div id="bloop_sign_1527471515738625024" class="bloop_sign"></div></body></html>