Class GroupServiceClient (0.34.0)

GroupServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

The Group API lets you inspect and manage your groups <#google.monitoring.v3.Group>__.

A group is a named filter that is used to identify a collection of monitored resources. Groups are typically used to mirror the physical and/or logical topology of the environment. Because group membership is computed dynamically, monitored resources that are started in the future are automatically placed in matching groups. By using a group to name monitored resources in, for example, an alert policy, the target of that alert policy is updated automatically as monitored resources are added and removed from the infrastructure.

Methods

GroupServiceClient

GroupServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

create_group

create_group(name, group, validate_only=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Creates a new group.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

name = client.project_path('[PROJECT]')

TODO: Initialize group:

group = {}

response = client.create_group(name, group)

Parameters
NameDescription
name str

The project in which to create the group. The format is "projects/{project_id_or_number}".

group Union[dict, Group]

A group definition. It is an error to define the name field because the system assigns the name. If a dict is provided, it must be of the same form as the protobuf message Group

validate_only bool

If true, validate this request but do not create the group.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_group

delete_group(name, recursive=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Deletes an existing group.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

name = client.group_path('[PROJECT]', '[GROUP]')

client.delete_group(name)

Parameters
NameDescription
name str

The group to delete. The format is "projects/{project_id_or_number}/groups/{group_id}".

recursive bool

If this field is true, then the request means to delete a group with all its descendants. Otherwise, the request means to delete a group only when it has no descendants. The default value is false.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
GroupServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
GroupServiceClientThe constructed client.

get_group

get_group(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets a single group.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

name = client.group_path('[PROJECT]', '[GROUP]')

response = client.get_group(name)

Parameters
NameDescription
name str

The group to retrieve. The format is "projects/{project_id_or_number}/groups/{group_id}".

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

group_path

group_path(project, group)

DEPRECATED. Return a fully-qualified group string.

list_group_members

list_group_members(name, page_size=None, filter_=None, interval=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Lists the monitored resources that are members of a group.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

name = client.group_path('[PROJECT]', '[GROUP]')

Iterate over all results

for element in client.list_group_members(name): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_group_members(name).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
name str

The group whose members are listed. The format is "projects/{project_id_or_number}/groups/{group_id}".

page_size int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

filter_ str

An optional list filter https://cloud.google.com/monitoring/api/learn_more#filtering__ describing the members to be returned. The filter may reference the type, labels, and metadata of monitored resources that comprise the group. For example, to return only resources representing Compute Engine VM instances, use this filter: :: resource.type = "gce_instance"

interval Union[dict, TimeInterval]

An optional time interval for which results should be returned. Only members that were part of the group during the specified interval are included in the response. If no interval is provided then the group membership over the last minute is returned. If a dict is provided, it must be of the same form as the protobuf message TimeInterval

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_groups

list_groups(name, children_of_group=None, ancestors_of_group=None, descendants_of_group=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Lists the existing groups.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

name = client.project_path('[PROJECT]')

Iterate over all results

for element in client.list_groups(name): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_groups(name).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
name str

The project whose groups are to be listed. The format is "projects/{project_id_or_number}".

children_of_group str

A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns groups whose parentName field contains the group name. If no groups have this parent, the results are empty.

ancestors_of_group str

A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns groups that are ancestors of the specified group. The groups are returned in order, starting with the immediate parent and ending with the most distant ancestor. If the specified group has no immediate parent, the results are empty.

descendants_of_group str

A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns the descendants of the specified group. This is a superset of the results returned by the childrenOfGroup filter, and includes children-of-children, and so forth.

page_size int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

project_path

project_path(project)

DEPRECATED. Return a fully-qualified project string.

update_group

update_group(group, validate_only=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Updates an existing group. You can change any group attributes except name.

.. rubric:: Example

from google.cloud import monitoring_v3

client = monitoring_v3.GroupServiceClient()

TODO: Initialize group:

group = {}

response = client.update_group(group)

Parameters
NameDescription
group Union[dict, Group]

The new definition of the group. All fields of the existing group, excepting name, are replaced with the corresponding fields of this group. If a dict is provided, it must be of the same form as the protobuf message Group

validate_only bool

If true, validate this request but do not update the existing group.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.