-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MonitoredResource to interface #3386
Changes from 10 commits
c9c0733
bb8bf4a
5559ba9
46eff7a
02d5ff3
ce6f32f
cf0bd5c
1aec1e8
23f3c90
de04ce3
762983c
b0ce33a
040bd1c
bcf54f8
84ed6ac
8df8c83
4ba34a0
4d1ee71
6bb5ddd
a2a6be2
ef54bc1
09c4d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2017 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Monitored Resource for the Google Logging API V2.""" | ||
|
||
import collections | ||
|
||
|
||
class Resource(collections.namedtuple('Resource', 'type labels')): | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
"""A monitored resource identified by specifying values for all labels. | ||
|
||
:type type: str | ||
:param type: The resource type name. | ||
|
||
:type labels: dict | ||
:param labels: A mapping from label names to values for all labels | ||
enumerated in the associated :class:`ResourceDescriptor`. | ||
""" | ||
__slots__ = () | ||
|
||
@classmethod | ||
def _from_dict(cls, info): | ||
"""Construct a resource object from the parsed JSON representation. | ||
|
||
:type info: dict | ||
:param info: | ||
A ``dict`` parsed from the JSON wire-format representation. | ||
|
||
:rtype: :class:`Resource` | ||
:returns: A resource object. | ||
""" | ||
return cls( | ||
type=info['type'], | ||
labels=info.get('labels', {}), | ||
) | ||
|
||
def _to_dict(self): | ||
"""Build a dictionary ready to be serialized to the JSON format. | ||
|
||
:rtype: dict | ||
:returns: A dict representation of the object that can be written to | ||
the API. | ||
""" | ||
return { | ||
'type': self.type, | ||
'labels': self.labels, | ||
} |
This comment was marked as spam.
Sorry, something went wrong.