简体   繁体   中英

Google Cloud Php SDK - Access instances list

I recently started using google cloud sdk: https://github.com/googleapis/google-cloud-php

But i'm having a lot of issues to access some items. One of the things i can't fnd any docs is accessing the list of instances for my account. I used the service account verification method.

$metricServiceClient = new MetricServiceClient([
                'credentials' => $json_arr
            ]);

I'm looking for this functionality within the sdk:

https://cloud.google.com/compute/docs/reference/rest/v1/instances/list

There is actually an example on how to use this method at the bottom of the document you shared, just under the IAM permissions. You can easily find it here .

However, you will not find any method that lists all the instances for your account, as these methods run based on a project. You would actually need to create an array with all the projects tied to your account and use it to check for all the instances across the projects you are part of.

Hope you find this useful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM