google-cloud-logging 1.10.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/TROUBLESHOOTING.md +2 -8
  5. data/lib/google-cloud-logging.rb +14 -15
  6. data/lib/google/cloud/logging.rb +12 -13
  7. data/lib/google/cloud/logging/credentials.rb +2 -2
  8. data/lib/google/cloud/logging/entry.rb +5 -5
  9. data/lib/google/cloud/logging/entry/http_request.rb +3 -3
  10. data/lib/google/cloud/logging/entry/list.rb +1 -1
  11. data/lib/google/cloud/logging/entry/operation.rb +3 -3
  12. data/lib/google/cloud/logging/entry/source_location.rb +3 -3
  13. data/lib/google/cloud/logging/log/list.rb +1 -1
  14. data/lib/google/cloud/logging/metric.rb +2 -2
  15. data/lib/google/cloud/logging/metric/list.rb +1 -1
  16. data/lib/google/cloud/logging/resource_descriptor/list.rb +1 -1
  17. data/lib/google/cloud/logging/service.rb +70 -173
  18. data/lib/google/cloud/logging/sink.rb +2 -2
  19. data/lib/google/cloud/logging/sink/list.rb +1 -1
  20. data/lib/google/cloud/logging/version.rb +1 -1
  21. metadata +11 -81
  22. data/lib/google/cloud/logging/v2.rb +0 -18
  23. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +0 -1368
  24. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +0 -101
  25. data/lib/google/cloud/logging/v2/credentials.rb +0 -39
  26. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +0 -164
  27. data/lib/google/cloud/logging/v2/doc/google/api/label.rb +0 -42
  28. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +0 -233
  29. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +0 -85
  30. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +0 -86
  31. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +0 -179
  32. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +0 -238
  33. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +0 -660
  34. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +0 -220
  35. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +0 -131
  36. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +0 -91
  37. data/lib/google/cloud/logging/v2/doc/google/protobuf/empty.rb +0 -29
  38. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +0 -222
  39. data/lib/google/cloud/logging/v2/doc/google/protobuf/struct.rb +0 -74
  40. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +0 -113
  41. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +0 -680
  42. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +0 -56
  43. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +0 -475
  44. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +0 -51
  45. data/lib/google/logging/v2/log_entry_pb.rb +0 -59
  46. data/lib/google/logging/v2/logging_config_pb.rb +0 -173
  47. data/lib/google/logging/v2/logging_config_services_pb.rb +0 -112
  48. data/lib/google/logging/v2/logging_metrics_pb.rb +0 -72
  49. data/lib/google/logging/v2/logging_metrics_services_pb.rb +0 -52
  50. data/lib/google/logging/v2/logging_pb.rb +0 -80
  51. data/lib/google/logging/v2/logging_services_pb.rb +0 -64
@@ -1,222 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # `FieldMask` represents a set of symbolic field paths, for example:
19
- #
20
- # paths: "f.a"
21
- # paths: "f.b.d"
22
- #
23
- # Here `f` represents a field in some root message, `a` and `b`
24
- # fields in the message found in `f`, and `d` a field found in the
25
- # message in `f.b`.
26
- #
27
- # Field masks are used to specify a subset of fields that should be
28
- # returned by a get operation or modified by an update operation.
29
- # Field masks also have a custom JSON encoding (see below).
30
- #
31
- # = Field Masks in Projections
32
- #
33
- # When used in the context of a projection, a response message or
34
- # sub-message is filtered by the API to only contain those fields as
35
- # specified in the mask. For example, if the mask in the previous
36
- # example is applied to a response message as follows:
37
- #
38
- # f {
39
- # a : 22
40
- # b {
41
- # d : 1
42
- # x : 2
43
- # }
44
- # y : 13
45
- # }
46
- # z: 8
47
- #
48
- # The result will not contain specific values for fields x,y and z
49
- # (their value will be set to the default, and omitted in proto text
50
- # output):
51
- #
52
- #
53
- # f {
54
- # a : 22
55
- # b {
56
- # d : 1
57
- # }
58
- # }
59
- #
60
- # A repeated field is not allowed except at the last position of a
61
- # paths string.
62
- #
63
- # If a FieldMask object is not present in a get operation, the
64
- # operation applies to all fields (as if a FieldMask of all fields
65
- # had been specified).
66
- #
67
- # Note that a field mask does not necessarily apply to the
68
- # top-level response message. In case of a REST get operation, the
69
- # field mask applies directly to the response, but in case of a REST
70
- # list operation, the mask instead applies to each individual message
71
- # in the returned resource list. In case of a REST custom method,
72
- # other definitions may be used. Where the mask applies will be
73
- # clearly documented together with its declaration in the API. In
74
- # any case, the effect on the returned resource/resources is required
75
- # behavior for APIs.
76
- #
77
- # = Field Masks in Update Operations
78
- #
79
- # A field mask in update operations specifies which fields of the
80
- # targeted resource are going to be updated. The API is required
81
- # to only change the values of the fields as specified in the mask
82
- # and leave the others untouched. If a resource is passed in to
83
- # describe the updated values, the API ignores the values of all
84
- # fields not covered by the mask.
85
- #
86
- # If a repeated field is specified for an update operation, new values will
87
- # be appended to the existing repeated field in the target resource. Note that
88
- # a repeated field is only allowed in the last position of a `paths` string.
89
- #
90
- # If a sub-message is specified in the last position of the field mask for an
91
- # update operation, then new value will be merged into the existing sub-message
92
- # in the target resource.
93
- #
94
- # For example, given the target message:
95
- #
96
- # f {
97
- # b {
98
- # d: 1
99
- # x: 2
100
- # }
101
- # c: [1]
102
- # }
103
- #
104
- # And an update message:
105
- #
106
- # f {
107
- # b {
108
- # d: 10
109
- # }
110
- # c: [2]
111
- # }
112
- #
113
- # then if the field mask is:
114
- #
115
- # paths: ["f.b", "f.c"]
116
- #
117
- # then the result will be:
118
- #
119
- # f {
120
- # b {
121
- # d: 10
122
- # x: 2
123
- # }
124
- # c: [1, 2]
125
- # }
126
- #
127
- # An implementation may provide options to override this default behavior for
128
- # repeated and message fields.
129
- #
130
- # In order to reset a field's value to the default, the field must
131
- # be in the mask and set to the default value in the provided resource.
132
- # Hence, in order to reset all fields of a resource, provide a default
133
- # instance of the resource and set all fields in the mask, or do
134
- # not provide a mask as described below.
135
- #
136
- # If a field mask is not present on update, the operation applies to
137
- # all fields (as if a field mask of all fields has been specified).
138
- # Note that in the presence of schema evolution, this may mean that
139
- # fields the client does not know and has therefore not filled into
140
- # the request will be reset to their default. If this is unwanted
141
- # behavior, a specific service may require a client to always specify
142
- # a field mask, producing an error if not.
143
- #
144
- # As with get operations, the location of the resource which
145
- # describes the updated values in the request message depends on the
146
- # operation kind. In any case, the effect of the field mask is
147
- # required to be honored by the API.
148
- #
149
- # == Considerations for HTTP REST
150
- #
151
- # The HTTP kind of an update operation which uses a field mask must
152
- # be set to PATCH instead of PUT in order to satisfy HTTP semantics
153
- # (PUT must only be used for full updates).
154
- #
155
- # = JSON Encoding of Field Masks
156
- #
157
- # In JSON, a field mask is encoded as a single string where paths are
158
- # separated by a comma. Fields name in each path are converted
159
- # to/from lower-camel naming conventions.
160
- #
161
- # As an example, consider the following message declarations:
162
- #
163
- # message Profile {
164
- # User user = 1;
165
- # Photo photo = 2;
166
- # }
167
- # message User {
168
- # string display_name = 1;
169
- # string address = 2;
170
- # }
171
- #
172
- # In proto a field mask for `Profile` may look as such:
173
- #
174
- # mask {
175
- # paths: "user.display_name"
176
- # paths: "photo"
177
- # }
178
- #
179
- # In JSON, the same mask is represented as below:
180
- #
181
- # {
182
- # mask: "user.displayName,photo"
183
- # }
184
- #
185
- # = Field Masks and Oneof Fields
186
- #
187
- # Field masks treat fields in oneofs just as regular fields. Consider the
188
- # following message:
189
- #
190
- # message SampleMessage {
191
- # oneof test_oneof {
192
- # string name = 4;
193
- # SubMessage sub_message = 9;
194
- # }
195
- # }
196
- #
197
- # The field mask can be:
198
- #
199
- # mask {
200
- # paths: "name"
201
- # }
202
- #
203
- # Or:
204
- #
205
- # mask {
206
- # paths: "sub_message"
207
- # }
208
- #
209
- # Note that oneof type names ("test_oneof" in this case) cannot be used in
210
- # paths.
211
- #
212
- # == Field Mask Verification
213
- #
214
- # The implementation of any API method which has a FieldMask type field in the
215
- # request should verify the included field paths, and return an
216
- # `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
217
- # @!attribute [rw] paths
218
- # @return [Array<String>]
219
- # The set of field mask paths.
220
- class FieldMask; end
221
- end
222
- end
@@ -1,74 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # `Struct` represents a structured data value, consisting of fields
19
- # which map to dynamically typed values. In some languages, `Struct`
20
- # might be supported by a native representation. For example, in
21
- # scripting languages like JS a struct is represented as an
22
- # object. The details of that representation are described together
23
- # with the proto support for the language.
24
- #
25
- # The JSON representation for `Struct` is JSON object.
26
- # @!attribute [rw] fields
27
- # @return [Hash{String => Google::Protobuf::Value}]
28
- # Unordered map of dynamically typed values.
29
- class Struct; end
30
-
31
- # `Value` represents a dynamically typed value which can be either
32
- # null, a number, a string, a boolean, a recursive struct value, or a
33
- # list of values. A producer of value is expected to set one of that
34
- # variants, absence of any variant indicates an error.
35
- #
36
- # The JSON representation for `Value` is JSON value.
37
- # @!attribute [rw] null_value
38
- # @return [Google::Protobuf::NullValue]
39
- # Represents a null value.
40
- # @!attribute [rw] number_value
41
- # @return [Float]
42
- # Represents a double value.
43
- # @!attribute [rw] string_value
44
- # @return [String]
45
- # Represents a string value.
46
- # @!attribute [rw] bool_value
47
- # @return [true, false]
48
- # Represents a boolean value.
49
- # @!attribute [rw] struct_value
50
- # @return [Google::Protobuf::Struct]
51
- # Represents a structured value.
52
- # @!attribute [rw] list_value
53
- # @return [Google::Protobuf::ListValue]
54
- # Represents a repeated `Value`.
55
- class Value; end
56
-
57
- # `ListValue` is a wrapper around a repeated field of values.
58
- #
59
- # The JSON representation for `ListValue` is JSON array.
60
- # @!attribute [rw] values
61
- # @return [Array<Google::Protobuf::Value>]
62
- # Repeated field of dynamically typed values.
63
- class ListValue; end
64
-
65
- # `NullValue` is a singleton enumeration to represent the null value for the
66
- # `Value` type union.
67
- #
68
- # The JSON representation for `NullValue` is JSON `null`.
69
- module NullValue
70
- # Null value.
71
- NULL_VALUE = 0
72
- end
73
- end
74
- end
@@ -1,113 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A Timestamp represents a point in time independent of any time zone or local
19
- # calendar, encoded as a count of seconds and fractions of seconds at
20
- # nanosecond resolution. The count is relative to an epoch at UTC midnight on
21
- # January 1, 1970, in the proleptic Gregorian calendar which extends the
22
- # Gregorian calendar backwards to year one.
23
- #
24
- # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
25
- # second table is needed for interpretation, using a [24-hour linear
26
- # smear](https://developers.google.com/time/smear).
27
- #
28
- # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
29
- # restricting to that range, we ensure that we can convert to and from [RFC
30
- # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
31
- #
32
- # = Examples
33
- #
34
- # Example 1: Compute Timestamp from POSIX `time()`.
35
- #
36
- # Timestamp timestamp;
37
- # timestamp.set_seconds(time(NULL));
38
- # timestamp.set_nanos(0);
39
- #
40
- # Example 2: Compute Timestamp from POSIX `gettimeofday()`.
41
- #
42
- # struct timeval tv;
43
- # gettimeofday(&tv, NULL);
44
- #
45
- # Timestamp timestamp;
46
- # timestamp.set_seconds(tv.tv_sec);
47
- # timestamp.set_nanos(tv.tv_usec * 1000);
48
- #
49
- # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
50
- #
51
- # FILETIME ft;
52
- # GetSystemTimeAsFileTime(&ft);
53
- # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
54
- #
55
- # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
56
- # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
57
- # Timestamp timestamp;
58
- # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
59
- # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
60
- #
61
- # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
62
- #
63
- # long millis = System.currentTimeMillis();
64
- #
65
- # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
66
- # .setNanos((int) ((millis % 1000) * 1000000)).build();
67
- #
68
- #
69
- # Example 5: Compute Timestamp from current time in Python.
70
- #
71
- # timestamp = Timestamp()
72
- # timestamp.GetCurrentTime()
73
- #
74
- # = JSON Mapping
75
- #
76
- # In JSON format, the Timestamp type is encoded as a string in the
77
- # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
78
- # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
79
- # where \\{year} is always expressed using four digits while \\{month}, \\{day},
80
- # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
81
- # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
82
- # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
83
- # is required. A proto3 JSON serializer should always use UTC (as indicated by
84
- # "Z") when printing the Timestamp type and a proto3 JSON parser should be
85
- # able to accept both UTC and other timezones (as indicated by an offset).
86
- #
87
- # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
88
- # 01:30 UTC on January 15, 2017.
89
- #
90
- # In JavaScript, one can convert a Date object to this format using the
91
- # standard
92
- # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
93
- # method. In Python, a standard `datetime.datetime` object can be converted
94
- # to this format using
95
- # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
96
- # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
97
- # the Joda Time's [`ISODateTimeFormat.dateTime()`](
98
- # http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
99
- # ) to obtain a formatter capable of generating timestamps in this format.
100
- # @!attribute [rw] seconds
101
- # @return [Integer]
102
- # Represents seconds of UTC time since Unix epoch
103
- # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
- # 9999-12-31T23:59:59Z inclusive.
105
- # @!attribute [rw] nanos
106
- # @return [Integer]
107
- # Non-negative fractions of a second at nanosecond resolution. Negative
108
- # second values with fractions must still have non-negative nanos values
109
- # that count forward in time. Must be from 0 to 999,999,999
110
- # inclusive.
111
- class Timestamp; end
112
- end
113
- end
@@ -1,680 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/logging/v2/logging_pb"
29
- require "google/cloud/logging/v2/credentials"
30
- require "google/cloud/logging/version"
31
-
32
- module Google
33
- module Cloud
34
- module Logging
35
- module V2
36
- # Service for ingesting and querying logs.
37
- #
38
- # @!attribute [r] logging_service_v2_stub
39
- # @return [Google::Logging::V2::LoggingServiceV2::Stub]
40
- class LoggingServiceV2Client
41
- # @private
42
- attr_reader :logging_service_v2_stub
43
-
44
- # The default address of the service.
45
- SERVICE_ADDRESS = "logging.googleapis.com".freeze
46
-
47
- # The default port of the service.
48
- DEFAULT_SERVICE_PORT = 443
49
-
50
- # The default set of gRPC interceptors.
51
- GRPC_INTERCEPTORS = []
52
-
53
- DEFAULT_TIMEOUT = 30
54
-
55
- PAGE_DESCRIPTORS = {
56
- "list_log_entries" => Google::Gax::PageDescriptor.new(
57
- "page_token",
58
- "next_page_token",
59
- "entries"),
60
- "list_monitored_resource_descriptors" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "resource_descriptors"),
64
- "list_logs" => Google::Gax::PageDescriptor.new(
65
- "page_token",
66
- "next_page_token",
67
- "log_names")
68
- }.freeze
69
-
70
- private_constant :PAGE_DESCRIPTORS
71
-
72
- BUNDLE_DESCRIPTORS = {
73
- "write_log_entries" => Google::Gax::BundleDescriptor.new(
74
- "entries",
75
- [
76
- "logName",
77
- "resource",
78
- "labels"
79
- ])
80
- }.freeze
81
-
82
- private_constant :BUNDLE_DESCRIPTORS
83
-
84
- # The scopes needed to make gRPC calls to all of the methods defined in
85
- # this service.
86
- ALL_SCOPES = [
87
- "https://www.googleapis.com/auth/cloud-platform",
88
- "https://www.googleapis.com/auth/cloud-platform.read-only",
89
- "https://www.googleapis.com/auth/logging.admin",
90
- "https://www.googleapis.com/auth/logging.read",
91
- "https://www.googleapis.com/auth/logging.write"
92
- ].freeze
93
-
94
-
95
- BILLING_ACCOUNT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
96
- "billingAccounts/{billing_account}"
97
- )
98
-
99
- private_constant :BILLING_ACCOUNT_PATH_TEMPLATE
100
-
101
- FOLDER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
102
- "folders/{folder}"
103
- )
104
-
105
- private_constant :FOLDER_PATH_TEMPLATE
106
-
107
- LOG_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
108
- "projects/{project}/logs/{log}"
109
- )
110
-
111
- private_constant :LOG_PATH_TEMPLATE
112
-
113
- ORGANIZATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
114
- "organizations/{organization}"
115
- )
116
-
117
- private_constant :ORGANIZATION_PATH_TEMPLATE
118
-
119
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
120
- "projects/{project}"
121
- )
122
-
123
- private_constant :PROJECT_PATH_TEMPLATE
124
-
125
- # Returns a fully-qualified billing_account resource name string.
126
- # @param billing_account [String]
127
- # @return [String]
128
- def self.billing_account_path billing_account
129
- BILLING_ACCOUNT_PATH_TEMPLATE.render(
130
- :"billing_account" => billing_account
131
- )
132
- end
133
-
134
- # Returns a fully-qualified folder resource name string.
135
- # @param folder [String]
136
- # @return [String]
137
- def self.folder_path folder
138
- FOLDER_PATH_TEMPLATE.render(
139
- :"folder" => folder
140
- )
141
- end
142
-
143
- # Returns a fully-qualified log resource name string.
144
- # @param project [String]
145
- # @param log [String]
146
- # @return [String]
147
- def self.log_path project, log
148
- LOG_PATH_TEMPLATE.render(
149
- :"project" => project,
150
- :"log" => log
151
- )
152
- end
153
-
154
- # Returns a fully-qualified organization resource name string.
155
- # @param organization [String]
156
- # @return [String]
157
- def self.organization_path organization
158
- ORGANIZATION_PATH_TEMPLATE.render(
159
- :"organization" => organization
160
- )
161
- end
162
-
163
- # Returns a fully-qualified project resource name string.
164
- # @param project [String]
165
- # @return [String]
166
- def self.project_path project
167
- PROJECT_PATH_TEMPLATE.render(
168
- :"project" => project
169
- )
170
- end
171
-
172
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
173
- # Provides the means for authenticating requests made by the client. This parameter can
174
- # be many types.
175
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
176
- # authenticating requests made by this client.
177
- # A `String` will be treated as the path to the keyfile to be used for the construction of
178
- # credentials for this client.
179
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
180
- # credentials for this client.
181
- # A `GRPC::Core::Channel` will be used to make calls through.
182
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
183
- # should already be composed with a `GRPC::Core::CallCredentials` object.
184
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
185
- # metadata for requests, generally, to give OAuth credentials.
186
- # @param scopes [Array<String>]
187
- # The OAuth scopes for this service. This parameter is ignored if
188
- # an updater_proc is supplied.
189
- # @param client_config [Hash]
190
- # A Hash for call options for each method. See
191
- # Google::Gax#construct_settings for the structure of
192
- # this data. Falls back to the default config if not specified
193
- # or the specified config is missing data points.
194
- # @param timeout [Numeric]
195
- # The default timeout, in seconds, for calls made through this client.
196
- # @param metadata [Hash]
197
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
198
- # @param service_address [String]
199
- # Override for the service hostname, or `nil` to leave as the default.
200
- # @param service_port [Integer]
201
- # Override for the service port, or `nil` to leave as the default.
202
- # @param exception_transformer [Proc]
203
- # An optional proc that intercepts any exceptions raised during an API call to inject
204
- # custom error handling.
205
- def initialize \
206
- credentials: nil,
207
- scopes: ALL_SCOPES,
208
- client_config: {},
209
- timeout: DEFAULT_TIMEOUT,
210
- metadata: nil,
211
- service_address: nil,
212
- service_port: nil,
213
- exception_transformer: nil,
214
- lib_name: nil,
215
- lib_version: ""
216
- # These require statements are intentionally placed here to initialize
217
- # the gRPC module only when it's required.
218
- # See https://github.com/googleapis/toolkit/issues/446
219
- require "google/gax/grpc"
220
- require "google/logging/v2/logging_services_pb"
221
-
222
- credentials ||= Google::Cloud::Logging::V2::Credentials.default
223
-
224
- if credentials.is_a?(String) || credentials.is_a?(Hash)
225
- updater_proc = Google::Cloud::Logging::V2::Credentials.new(credentials).updater_proc
226
- end
227
- if credentials.is_a?(GRPC::Core::Channel)
228
- channel = credentials
229
- end
230
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
231
- chan_creds = credentials
232
- end
233
- if credentials.is_a?(Proc)
234
- updater_proc = credentials
235
- end
236
- if credentials.is_a?(Google::Auth::Credentials)
237
- updater_proc = credentials.updater_proc
238
- end
239
-
240
- package_version = Google::Cloud::Logging::VERSION
241
-
242
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
243
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
244
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
245
- google_api_client << " grpc/#{GRPC::VERSION}"
246
- google_api_client.freeze
247
-
248
- headers = { :"x-goog-api-client" => google_api_client }
249
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
250
- headers[:"x-goog-user-project"] = credentials.quota_project_id
251
- end
252
- headers.merge!(metadata) unless metadata.nil?
253
- client_config_file = Pathname.new(__dir__).join(
254
- "logging_service_v2_client_config.json"
255
- )
256
- defaults = client_config_file.open do |f|
257
- Google::Gax.construct_settings(
258
- "google.logging.v2.LoggingServiceV2",
259
- JSON.parse(f.read),
260
- client_config,
261
- Google::Gax::Grpc::STATUS_CODE_NAMES,
262
- timeout,
263
- bundle_descriptors: BUNDLE_DESCRIPTORS,
264
- page_descriptors: PAGE_DESCRIPTORS,
265
- errors: Google::Gax::Grpc::API_ERRORS,
266
- metadata: headers
267
- )
268
- end
269
-
270
- # Allow overriding the service path/port in subclasses.
271
- service_path = service_address || self.class::SERVICE_ADDRESS
272
- port = service_port || self.class::DEFAULT_SERVICE_PORT
273
- interceptors = self.class::GRPC_INTERCEPTORS
274
- @logging_service_v2_stub = Google::Gax::Grpc.create_stub(
275
- service_path,
276
- port,
277
- chan_creds: chan_creds,
278
- channel: channel,
279
- updater_proc: updater_proc,
280
- scopes: scopes,
281
- interceptors: interceptors,
282
- &Google::Logging::V2::LoggingServiceV2::Stub.method(:new)
283
- )
284
-
285
- @write_log_entries = Google::Gax.create_api_call(
286
- @logging_service_v2_stub.method(:write_log_entries),
287
- defaults["write_log_entries"],
288
- exception_transformer: exception_transformer
289
- )
290
- @delete_log = Google::Gax.create_api_call(
291
- @logging_service_v2_stub.method(:delete_log),
292
- defaults["delete_log"],
293
- exception_transformer: exception_transformer,
294
- params_extractor: proc do |request|
295
- {'log_name' => request.log_name}
296
- end
297
- )
298
- @list_log_entries = Google::Gax.create_api_call(
299
- @logging_service_v2_stub.method(:list_log_entries),
300
- defaults["list_log_entries"],
301
- exception_transformer: exception_transformer
302
- )
303
- @list_monitored_resource_descriptors = Google::Gax.create_api_call(
304
- @logging_service_v2_stub.method(:list_monitored_resource_descriptors),
305
- defaults["list_monitored_resource_descriptors"],
306
- exception_transformer: exception_transformer
307
- )
308
- @list_logs = Google::Gax.create_api_call(
309
- @logging_service_v2_stub.method(:list_logs),
310
- defaults["list_logs"],
311
- exception_transformer: exception_transformer,
312
- params_extractor: proc do |request|
313
- {'parent' => request.parent}
314
- end
315
- )
316
- end
317
-
318
- # Service calls
319
-
320
- # Writes log entries to Logging. This API method is the
321
- # only way to send log entries to Logging. This method
322
- # is used, directly or indirectly, by the Logging agent
323
- # (fluentd) and all logging libraries configured to use Logging.
324
- # A single request may contain log entries for a maximum of 1000
325
- # different resources (projects, organizations, billing accounts or
326
- # folders)
327
- #
328
- # @param entries [Array<Google::Logging::V2::LogEntry | Hash>]
329
- # Required. The log entries to send to Logging. The order of log
330
- # entries in this list does not matter. Values supplied in this method's
331
- # `log_name`, `resource`, and `labels` fields are copied into those log
332
- # entries in this list that do not include values for their corresponding
333
- # fields. For more information, see the
334
- # {Google::Logging::V2::LogEntry LogEntry} type.
335
- #
336
- # If the `timestamp` or `insert_id` fields are missing in log entries, then
337
- # this method supplies the current time or a unique identifier, respectively.
338
- # The supplied values are chosen so that, among the log entries that did not
339
- # supply their own values, the entries earlier in the list will sort before
340
- # the entries later in the list. See the `entries.list` method.
341
- #
342
- # Log entries with timestamps that are more than the
343
- # [logs retention period](https://cloud.google.com/logging/quota-policy) in the past or more than
344
- # 24 hours in the future will not be available when calling `entries.list`.
345
- # However, those log entries can still be
346
- # [exported with LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs).
347
- #
348
- # To improve throughput and to avoid exceeding the
349
- # [quota limit](https://cloud.google.com/logging/quota-policy) for calls to `entries.write`,
350
- # you should try to include several log entries in this list,
351
- # rather than calling this method for each individual log entry.
352
- # A hash of the same form as `Google::Logging::V2::LogEntry`
353
- # can also be provided.
354
- # @param log_name [String]
355
- # Optional. A default log resource name that is assigned to all log entries
356
- # in `entries` that do not specify a value for `log_name`:
357
- #
358
- # "projects/[PROJECT_ID]/logs/[LOG_ID]"
359
- # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
360
- # "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
361
- # "folders/[FOLDER_ID]/logs/[LOG_ID]"
362
- #
363
- # `[LOG_ID]` must be URL-encoded. For example:
364
- #
365
- # "projects/my-project-id/logs/syslog"
366
- # "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"
367
- #
368
- # The permission `logging.logEntries.create` is needed on each project,
369
- # organization, billing account, or folder that is receiving new log
370
- # entries, whether the resource is specified in `logName` or in an
371
- # individual log entry.
372
- # @param resource [Google::Api::MonitoredResource | Hash]
373
- # Optional. A default monitored resource object that is assigned to all log
374
- # entries in `entries` that do not specify a value for `resource`. Example:
375
- #
376
- # { "type": "gce_instance",
377
- # "labels": {
378
- # "zone": "us-central1-a", "instance_id": "00000000000000000000" }}
379
- #
380
- # See {Google::Logging::V2::LogEntry LogEntry}.
381
- # A hash of the same form as `Google::Api::MonitoredResource`
382
- # can also be provided.
383
- # @param labels [Hash{String => String}]
384
- # Optional. Default labels that are added to the `labels` field of all log
385
- # entries in `entries`. If a log entry already has a label with the same key
386
- # as a label in this parameter, then the log entry's label is not changed.
387
- # See {Google::Logging::V2::LogEntry LogEntry}.
388
- # @param partial_success [true, false]
389
- # Optional. Whether valid entries should be written even if some other
390
- # entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any
391
- # entry is not written, then the response status is the error associated
392
- # with one of the failed entries and the response includes error details
393
- # keyed by the entries' zero-based index in the `entries.write` method.
394
- # @param dry_run [true, false]
395
- # Optional. If true, the request should expect normal response, but the
396
- # entries won't be persisted nor exported. Useful for checking whether the
397
- # logging API endpoints are working properly before sending valuable data.
398
- # @param options [Google::Gax::CallOptions]
399
- # Overrides the default settings for this call, e.g, timeout,
400
- # retries, etc.
401
- # @yield [result, operation] Access the result along with the RPC operation
402
- # @yieldparam result [Google::Logging::V2::WriteLogEntriesResponse]
403
- # @yieldparam operation [GRPC::ActiveCall::Operation]
404
- # @return [Google::Logging::V2::WriteLogEntriesResponse]
405
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
406
- # @example
407
- # require "google/cloud/logging/v2"
408
- #
409
- # logging_client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new
410
- #
411
- # # TODO: Initialize `entries`:
412
- # entries = []
413
- # response = logging_client.write_log_entries(entries)
414
-
415
- def write_log_entries \
416
- entries,
417
- log_name: nil,
418
- resource: nil,
419
- labels: nil,
420
- partial_success: nil,
421
- dry_run: nil,
422
- options: nil,
423
- &block
424
- req = {
425
- entries: entries,
426
- log_name: log_name,
427
- resource: resource,
428
- labels: labels,
429
- partial_success: partial_success,
430
- dry_run: dry_run
431
- }.delete_if { |_, v| v.nil? }
432
- req = Google::Gax::to_proto(req, Google::Logging::V2::WriteLogEntriesRequest)
433
- @write_log_entries.call(req, options, &block)
434
- end
435
-
436
- # Deletes all the log entries in a log. The log reappears if it receives new
437
- # entries. Log entries written shortly before the delete operation might not
438
- # be deleted. Entries received after the delete operation with a timestamp
439
- # before the operation will be deleted.
440
- #
441
- # @param log_name [String]
442
- # Required. The resource name of the log to delete:
443
- #
444
- # "projects/[PROJECT_ID]/logs/[LOG_ID]"
445
- # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
446
- # "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
447
- # "folders/[FOLDER_ID]/logs/[LOG_ID]"
448
- #
449
- # `[LOG_ID]` must be URL-encoded. For example,
450
- # `"projects/my-project-id/logs/syslog"`,
451
- # `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`.
452
- # For more information about log names, see
453
- # {Google::Logging::V2::LogEntry LogEntry}.
454
- # @param options [Google::Gax::CallOptions]
455
- # Overrides the default settings for this call, e.g, timeout,
456
- # retries, etc.
457
- # @yield [result, operation] Access the result along with the RPC operation
458
- # @yieldparam result []
459
- # @yieldparam operation [GRPC::ActiveCall::Operation]
460
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
461
- # @example
462
- # require "google/cloud/logging/v2"
463
- #
464
- # logging_client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new
465
- #
466
- # # TODO: Initialize `log_name`:
467
- # log_name = ''
468
- # logging_client.delete_log(log_name)
469
-
470
- def delete_log \
471
- log_name,
472
- options: nil,
473
- &block
474
- req = {
475
- log_name: log_name
476
- }.delete_if { |_, v| v.nil? }
477
- req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteLogRequest)
478
- @delete_log.call(req, options, &block)
479
- nil
480
- end
481
-
482
- # Lists log entries. Use this method to retrieve log entries that originated
483
- # from a project/folder/organization/billing account. For ways to export log
484
- # entries, see [Exporting Logs](https://cloud.google.com/logging/docs/export).
485
- #
486
- # @param resource_names [Array<String>]
487
- # Required. Names of one or more parent resources from which to
488
- # retrieve log entries:
489
- #
490
- # "projects/[PROJECT_ID]"
491
- # "organizations/[ORGANIZATION_ID]"
492
- # "billingAccounts/[BILLING_ACCOUNT_ID]"
493
- # "folders/[FOLDER_ID]"
494
- #
495
- #
496
- # Projects listed in the `project_ids` field are added to this list.
497
- # @param filter [String]
498
- # Optional. A filter that chooses which log entries to return. See [Advanced
499
- # Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). Only log entries that
500
- # match the filter are returned. An empty filter matches all log entries in
501
- # the resources listed in `resource_names`. Referencing a parent resource
502
- # that is not listed in `resource_names` will cause the filter to return no
503
- # results.
504
- # The maximum length of the filter is 20000 characters.
505
- # @param order_by [String]
506
- # Optional. How the results should be sorted. Presently, the only permitted
507
- # values are `"timestamp asc"` (default) and `"timestamp desc"`. The first
508
- # option returns entries in order of increasing values of
509
- # `LogEntry.timestamp` (oldest first), and the second option returns entries
510
- # in order of decreasing timestamps (newest first). Entries with equal
511
- # timestamps are returned in order of their `insert_id` values.
512
- # @param page_size [Integer]
513
- # The maximum number of resources contained in the underlying API
514
- # response. If page streaming is performed per-resource, this
515
- # parameter does not affect the return value. If page streaming is
516
- # performed per-page, this determines the maximum number of
517
- # resources in a page.
518
- # @param options [Google::Gax::CallOptions]
519
- # Overrides the default settings for this call, e.g, timeout,
520
- # retries, etc.
521
- # @yield [result, operation] Access the result along with the RPC operation
522
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Logging::V2::LogEntry>]
523
- # @yieldparam operation [GRPC::ActiveCall::Operation]
524
- # @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogEntry>]
525
- # An enumerable of Google::Logging::V2::LogEntry instances.
526
- # See Google::Gax::PagedEnumerable documentation for other
527
- # operations such as per-page iteration or access to the response
528
- # object.
529
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
530
- # @example
531
- # require "google/cloud/logging/v2"
532
- #
533
- # logging_client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new
534
- #
535
- # # TODO: Initialize `formatted_resource_names`:
536
- # formatted_resource_names = []
537
- #
538
- # # Iterate over all results.
539
- # logging_client.list_log_entries(formatted_resource_names).each do |element|
540
- # # Process element.
541
- # end
542
- #
543
- # # Or iterate over results one page at a time.
544
- # logging_client.list_log_entries(formatted_resource_names).each_page do |page|
545
- # # Process each page at a time.
546
- # page.each do |element|
547
- # # Process element.
548
- # end
549
- # end
550
-
551
- def list_log_entries \
552
- resource_names,
553
- filter: nil,
554
- order_by: nil,
555
- page_size: nil,
556
- options: nil,
557
- &block
558
- req = {
559
- resource_names: resource_names,
560
- filter: filter,
561
- order_by: order_by,
562
- page_size: page_size
563
- }.delete_if { |_, v| v.nil? }
564
- req = Google::Gax::to_proto(req, Google::Logging::V2::ListLogEntriesRequest)
565
- @list_log_entries.call(req, options, &block)
566
- end
567
-
568
- # Lists the descriptors for monitored resource types used by Logging.
569
- #
570
- # @param page_size [Integer]
571
- # The maximum number of resources contained in the underlying API
572
- # response. If page streaming is performed per-resource, this
573
- # parameter does not affect the return value. If page streaming is
574
- # performed per-page, this determines the maximum number of
575
- # resources in a page.
576
- # @param options [Google::Gax::CallOptions]
577
- # Overrides the default settings for this call, e.g, timeout,
578
- # retries, etc.
579
- # @yield [result, operation] Access the result along with the RPC operation
580
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
581
- # @yieldparam operation [GRPC::ActiveCall::Operation]
582
- # @return [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
583
- # An enumerable of Google::Api::MonitoredResourceDescriptor instances.
584
- # See Google::Gax::PagedEnumerable documentation for other
585
- # operations such as per-page iteration or access to the response
586
- # object.
587
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
588
- # @example
589
- # require "google/cloud/logging/v2"
590
- #
591
- # logging_client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new
592
- #
593
- # # Iterate over all results.
594
- # logging_client.list_monitored_resource_descriptors.each do |element|
595
- # # Process element.
596
- # end
597
- #
598
- # # Or iterate over results one page at a time.
599
- # logging_client.list_monitored_resource_descriptors.each_page do |page|
600
- # # Process each page at a time.
601
- # page.each do |element|
602
- # # Process element.
603
- # end
604
- # end
605
-
606
- def list_monitored_resource_descriptors \
607
- page_size: nil,
608
- options: nil,
609
- &block
610
- req = {
611
- page_size: page_size
612
- }.delete_if { |_, v| v.nil? }
613
- req = Google::Gax::to_proto(req, Google::Logging::V2::ListMonitoredResourceDescriptorsRequest)
614
- @list_monitored_resource_descriptors.call(req, options, &block)
615
- end
616
-
617
- # Lists the logs in projects, organizations, folders, or billing accounts.
618
- # Only logs that have entries are listed.
619
- #
620
- # @param parent [String]
621
- # Required. The resource name that owns the logs:
622
- #
623
- # "projects/[PROJECT_ID]"
624
- # "organizations/[ORGANIZATION_ID]"
625
- # "billingAccounts/[BILLING_ACCOUNT_ID]"
626
- # "folders/[FOLDER_ID]"
627
- # @param page_size [Integer]
628
- # The maximum number of resources contained in the underlying API
629
- # response. If page streaming is performed per-resource, this
630
- # parameter does not affect the return value. If page streaming is
631
- # performed per-page, this determines the maximum number of
632
- # resources in a page.
633
- # @param options [Google::Gax::CallOptions]
634
- # Overrides the default settings for this call, e.g, timeout,
635
- # retries, etc.
636
- # @yield [result, operation] Access the result along with the RPC operation
637
- # @yieldparam result [Google::Gax::PagedEnumerable<String>]
638
- # @yieldparam operation [GRPC::ActiveCall::Operation]
639
- # @return [Google::Gax::PagedEnumerable<String>]
640
- # An enumerable of String instances.
641
- # See Google::Gax::PagedEnumerable documentation for other
642
- # operations such as per-page iteration or access to the response
643
- # object.
644
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
645
- # @example
646
- # require "google/cloud/logging/v2"
647
- #
648
- # logging_client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new
649
- # formatted_parent = Google::Cloud::Logging::V2::LoggingServiceV2Client.project_path("[PROJECT]")
650
- #
651
- # # Iterate over all results.
652
- # logging_client.list_logs(formatted_parent).each do |element|
653
- # # Process element.
654
- # end
655
- #
656
- # # Or iterate over results one page at a time.
657
- # logging_client.list_logs(formatted_parent).each_page do |page|
658
- # # Process each page at a time.
659
- # page.each do |element|
660
- # # Process element.
661
- # end
662
- # end
663
-
664
- def list_logs \
665
- parent,
666
- page_size: nil,
667
- options: nil,
668
- &block
669
- req = {
670
- parent: parent,
671
- page_size: page_size
672
- }.delete_if { |_, v| v.nil? }
673
- req = Google::Gax::to_proto(req, Google::Logging::V2::ListLogsRequest)
674
- @list_logs.call(req, options, &block)
675
- end
676
- end
677
- end
678
- end
679
- end
680
- end