<div dir="ltr">Why wouldn't it be by zone? Surely production and preproduction are separated, among other things, by a zone tag<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 27, 2018 at 10:01 PM, Rick Hornsby <span dir="ltr"><<a href="mailto:richardjhornsby@gmail.com" target="_blank">richardjhornsby@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div id="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_customfont" style="margin:0px"><span class="m_-3405265412886266397Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre-wrap">        </span>crm = googleapiclient.discovery.<wbr>build('cloudresourcemanager', ‘v1')</div><div id="m_-3405265412886266397bloop_customfont" style="margin:0px"><div id="m_-3405265412886266397bloop_customfont" style="margin:0px"><span class="m_-3405265412886266397Apple-tab-span" style="white-space:pre-wrap">        </span>compute = googleapiclient.discovery.<wbr>build('compute', ‘v1’)</div><div id="m_-3405265412886266397bloop_customfont" style="margin:0px"><br></div></div><div id="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_customfont" style="margin:0px"><span class="m_-3405265412886266397Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre-wrap">        </span>projects = crm.projects().list().execute(<wbr>)['projects']</div><div id="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_customfont" style="margin:0px"><span class="m_-3405265412886266397Apple-tab-span" style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:13px;white-space:pre-wrap">        </span>compute.instances().list(<wbr>project=‘projectid', zone='us-central1-?').execute(<wbr>)</div><div id="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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="m_-3405265412886266397bloop_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" target="_blank">https://cloud.google.com/<wbr>compute/docs/reference/rest/<wbr>beta/instances/list</a></div><br><div id="m_-3405265412886266397bloop_sign_1527471515738625024" class="m_-3405265412886266397bloop_sign"></div></div>
<br>______________________________<wbr>_________________<br>
colug-432 mailing list<br>
<a href="mailto:colug-432@colug.net">colug-432@colug.net</a><br>
<a href="http://lists.colug.net/mailman/listinfo/colug-432" rel="noreferrer" target="_blank">http://lists.colug.net/<wbr>mailman/listinfo/colug-432</a><br>
<br></blockquote></div><br></div>