Search Client#

Client for interacting with the Google Cloud search API.

class gcloud.search.client.Client(project=None, credentials=None, http=None)[source]#

Bases: gcloud.client.JSONClient

Client to bundle configuration needed for API requests.

Parameters:
  • project (string) – the project which the client acts on behalf of. Will be passed when creating a index. If not passed, falls back to the default inferred from the environment.
  • credentials (oauth2client.client.OAuth2Credentials or NoneType) – The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if no http object is passed), falls back to the default inferred from the environment.
  • http (httplib2.Http or class that defines request().) – An optional HTTP object to make requests. If not passed, an http object is created that is bound to the credentials for the current object.
index(name)[source]#

Construct an index bound to this client.

Parameters:name (string) – Name of the index.
Return type:gcloud.search.index.Index
Returns:a new Index instance
list_indexes(max_results=None, page_token=None, view=None, prefix=None)[source]#

List indexes for the project associated with this client.

See: https://cloud.google.com/search/reference/rest/v1/indexes/list

Parameters:
  • max_results (int) – maximum number of indexes to return, If not passed, defaults to a value set by the API.
  • page_token (string) – opaque marker for the next “page” of indexes. If not passed, the API will return the first page of indexes.
  • view (string) – One of ‘ID_ONLY’ (return only the index ID; the default) or ‘FULL’ (return information on indexed fields).
  • prefix (string) – return only indexes whose ID starts with prefix.
Return type:

tuple, (list, str)

Returns:

list of gcloud.dns.index.Index, plus a “next page token” string: if the token is not None, indicates that more indexes can be retrieved with another call (pass that value as page_token).

Connection#

Create / interact with gcloud search connections.

class gcloud.search.connection.Connection(credentials=None, http=None)[source]#

Bases: gcloud.connection.JSONConnection

A connection to Google Cloud Search via the JSON REST API.

API_BASE_URL = 'https://cloudsearch.googleapis.com'#

The base of the API call URL.

API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'#

A template for the URL of a particular API call.

API_VERSION = 'v1'#

The version of the API, used in building the API call’s URL.

SCOPE = ('https://www.googleapis.com/auth/cloudsearch',)#

The scopes required for authenticating as a Cloud Search consumer.