google-cloud-pubsub 0.32.2 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02df7490b94ade13d3c63495002c52b2d207eea1c607a3043b2610a0f4bc285f
4
- data.tar.gz: 1386f2606152b290a445e1d7e9869da0d7cfc2d59bb3b9b2baf720a229a45e2a
3
+ metadata.gz: b01f6b6652fd9e503c9f9b515152ce1cc9aef8fc8516fc4831894b2fe3b74e98
4
+ data.tar.gz: b588531371dd2bfee17f06377a0c63496737d9ad803027d4ef6293c6366d685b
5
5
  SHA512:
6
- metadata.gz: 99ff80e29fa39ae47633ab1dcfd82a141825833cbb38329ee8b827fdb17006fd80e988c71075cdcd563a04336283f8ba7b2e9dc6d3d50346abf36d217d6cc654
7
- data.tar.gz: 891c467d54a0355228b3108d096b4e220702c1ec4bfb393f83b5e2c878c616d378999e442ba80948fed1af4cc91c64bd431e757cc1b415368901cbb6836c6208
6
+ metadata.gz: 2114333eba63efe69ef02805271651a8a02301df0512788358ef58ebf97eefc94d67eb09c6842e96c6a0568f3718093ba363ba5b0052bd4e5dc8d536a877a090
7
+ data.tar.gz: 22d09f6ff60fe999bab76b6fcb5ae621eccf491ee090a762d54bf20b2b2cb2832867a439ce4c2be473f2a14da87b0ad42f714fe9574da6b68f0aab1aa6d3edba
@@ -1,5 +1,12 @@
1
1
  # Release History
2
2
 
3
+ ### 0.33.0 / 2018-09-20
4
+
5
+ * Add support for user labels to Snapshot, Subscription and Topic.
6
+ * Update documentation.
7
+ * Change documentation URL to googleapis GitHub org.
8
+ * Fix circular require warning.
9
+
3
10
  ### 0.32.2 / 2018-09-12
4
11
 
5
12
  * Add missing documentation files to package.
data/LOGGING.md CHANGED
@@ -5,7 +5,7 @@ To enable logging for this library, set the logger for the underlying
5
5
  that you set may be a Ruby stdlib
6
6
  [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
7
7
  shown below, or a
8
- [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
8
+ [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
9
9
  that will write logs to [Stackdriver
10
10
  Logging](https://cloud.google.com/logging/). See
11
11
  [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
  gem "google-cloud-core"
23
- require "google/cloud"
23
+ require "google/cloud" unless defined? Google::Cloud.new
24
24
  require "google/cloud/config"
25
25
  require "googleauth"
26
26
 
@@ -163,6 +163,14 @@ module Google
163
163
  # Creates a new topic.
164
164
  #
165
165
  # @param [String] topic_name Name of a topic.
166
+ # @param [Hash] labels A hash of user-provided labels associated with
167
+ # the topic. You can use these to organize and group your topics.
168
+ # Label keys and values can be no longer than 63 characters, can only
169
+ # contain lowercase letters, numeric characters, underscores and
170
+ # dashes. International characters are allowed. Label values are
171
+ # optional. Label keys must start with a letter and each label in the
172
+ # list must have a different key. See [Creating and Managing
173
+ # Labels](https://cloud.google.com/pubsub/docs/labels).
166
174
  # @param [Hash] async A hash of values to configure the topic's
167
175
  # {AsyncPublisher} that is created when {Topic#publish_async}
168
176
  # is called. Optional.
@@ -191,9 +199,9 @@ module Google
191
199
  # pubsub = Google::Cloud::Pubsub.new
192
200
  # topic = pubsub.create_topic "my-topic"
193
201
  #
194
- def create_topic topic_name, async: nil
202
+ def create_topic topic_name, labels: nil, async: nil
195
203
  ensure_service!
196
- grpc = service.create_topic topic_name
204
+ grpc = service.create_topic topic_name, labels: labels
197
205
  Topic.from_grpc grpc, service, async: async
198
206
  end
199
207
  alias new_topic create_topic
@@ -123,13 +123,22 @@ module Google
123
123
 
124
124
  ##
125
125
  # Creates the given topic with the given name.
126
- def create_topic topic_name, options = {}
126
+ def create_topic topic_name, labels: nil, options: {}
127
127
  execute do
128
128
  publisher.create_topic topic_path(topic_name, options),
129
+ labels: labels,
129
130
  options: default_options
130
131
  end
131
132
  end
132
133
 
134
+ def update_topic topic_obj, *fields
135
+ mask = Google::Protobuf::FieldMask.new paths: fields.map(&:to_s)
136
+ execute do
137
+ publisher.update_topic \
138
+ topic_obj, mask, options: default_options
139
+ end
140
+ end
141
+
133
142
  ##
134
143
  # Deletes the topic with the given name. All subscriptions to this topic
135
144
  # are also deleted. Raises GRPC status code 5 if the topic does not
@@ -213,6 +222,7 @@ module Google
213
222
  deadline = options[:deadline]
214
223
  retain_acked = options[:retain_acked]
215
224
  mrd = Convert.number_to_duration options[:retention]
225
+ labels = options[:labels]
216
226
 
217
227
  execute do
218
228
  subscriber.create_subscription name,
@@ -221,6 +231,7 @@ module Google
221
231
  ack_deadline_seconds: deadline,
222
232
  retain_acked_messages: retain_acked,
223
233
  message_retention_duration: mrd,
234
+ labels: labels,
224
235
  options: default_options
225
236
  end
226
237
  end
@@ -320,15 +331,24 @@ module Google
320
331
 
321
332
  ##
322
333
  # Creates a snapshot on a given subscription.
323
- def create_snapshot subscription, snapshot_name
334
+ def create_snapshot subscription, snapshot_name, labels: nil
324
335
  name = snapshot_path snapshot_name
325
336
  execute do
326
337
  subscriber.create_snapshot name,
327
338
  subscription_path(subscription),
339
+ labels: labels,
328
340
  options: default_options
329
341
  end
330
342
  end
331
343
 
344
+ def update_snapshot snapshot_obj, *fields
345
+ mask = Google::Protobuf::FieldMask.new paths: fields.map(&:to_s)
346
+ execute do
347
+ subscriber.update_snapshot \
348
+ snapshot_obj, mask, options: default_options
349
+ end
350
+ end
351
+
332
352
  ##
333
353
  # Deletes an existing snapshot.
334
354
  # All pending messages in the snapshot are immediately dropped.
@@ -110,6 +110,41 @@ module Google
110
110
  self.class.timestamp_from_grpc @grpc.expire_time
111
111
  end
112
112
 
113
+ ##
114
+ # A hash of user-provided labels associated with this snapshot.
115
+ # Labels can be used to organize and group snapshots.See [Creating and
116
+ # Managing Labels](https://cloud.google.com/pubsub/docs/labels).
117
+ #
118
+ # The returned hash is frozen and changes are not allowed. Use
119
+ # {#labels=} to update the labels for this snapshot.
120
+ #
121
+ # @return [Hash] The frozen labels hash.
122
+ #
123
+ def labels
124
+ @grpc.labels.to_h.freeze
125
+ end
126
+
127
+ ##
128
+ # Sets the hash of user-provided labels associated with this
129
+ # snapshot. Labels can be used to organize and group snapshots.
130
+ # Label keys and values can be no longer than 63 characters, can only
131
+ # contain lowercase letters, numeric characters, underscores and dashes.
132
+ # International characters are allowed. Label values are optional. Label
133
+ # keys must start with a letter and each label in the list must have a
134
+ # different key. See [Creating and Managing
135
+ # Labels](https://cloud.google.com/pubsub/docs/labels).
136
+ #
137
+ # @param [Hash] new_labels The new labels hash.
138
+ #
139
+ def labels= new_labels
140
+ raise ArgumentError, "Value must be a Hash" if new_labels.nil?
141
+ labels_map = Google::Protobuf::Map.new(:string, :string)
142
+ Hash(new_labels).each { |k, v| labels_map[String(k)] = String(v) }
143
+ update_grpc = @grpc.dup
144
+ update_grpc.labels = labels_map
145
+ @grpc = service.update_snapshot update_grpc, :labels
146
+ end
147
+
113
148
  ##
114
149
  # Removes an existing snapshot. All messages retained in the snapshot
115
150
  # are immediately dropped. After a snapshot is deleted, a new one may be
@@ -174,6 +174,42 @@ module Google
174
174
  )
175
175
  end
176
176
 
177
+ ##
178
+ # A hash of user-provided labels associated with this subscription.
179
+ # Labels can be used to organize and group subscriptions.See [Creating
180
+ # and Managing Labels](https://cloud.google.com/pubsub/docs/labels).
181
+ #
182
+ # The returned hash is frozen and changes are not allowed. Use
183
+ # {#labels=} to update the labels for this subscription.
184
+ #
185
+ # @return [Hash] The frozen labels hash.
186
+ #
187
+ def labels
188
+ @grpc.labels.to_h.freeze
189
+ end
190
+
191
+ ##
192
+ # Sets the hash of user-provided labels associated with this
193
+ # subscription. Labels can be used to organize and group subscriptions.
194
+ # Label keys and values can be no longer than 63 characters, can only
195
+ # contain lowercase letters, numeric characters, underscores and dashes.
196
+ # International characters are allowed. Label values are optional. Label
197
+ # keys must start with a letter and each label in the list must have a
198
+ # different key. See [Creating and Managing
199
+ # Labels](https://cloud.google.com/pubsub/docs/labels).
200
+ #
201
+ # @param [Hash] new_labels The new labels hash.
202
+ #
203
+ def labels= new_labels
204
+ raise ArgumentError, "Value must be a Hash" if new_labels.nil?
205
+ labels_map = Google::Protobuf::Map.new(:string, :string)
206
+ Hash(new_labels).each { |k, v| labels_map[String(k)] = String(v) }
207
+ update_grpc = @grpc.dup
208
+ update_grpc.labels = labels_map
209
+ @grpc = service.update_subscription update_grpc, :labels
210
+ @lazy = nil
211
+ end
212
+
177
213
  ##
178
214
  # Determines whether the subscription exists in the Pub/Sub service.
179
215
  #
@@ -484,6 +520,14 @@ module Google
484
520
  # ([0-9], dashes (-), underscores (_), periods (.), tildes (~), plus
485
521
  # (+) or percent signs (%). It must be between 3 and 255 characters in
486
522
  # length, and it must not start with "goog". Optional.
523
+ # @param [Hash] labels A hash of user-provided labels associated with
524
+ # the snapshot. You can use these to organize and group your
525
+ # snapshots. Label keys and values can be no longer than 63
526
+ # characters, can only contain lowercase letters, numeric characters,
527
+ # underscores and dashes. International characters are allowed. Label
528
+ # values are optional. Label keys must start with a letter and each
529
+ # label in the list must have a different key. See [Creating and
530
+ # Managing Labels](https://cloud.google.com/pubsub/docs/labels).
487
531
  #
488
532
  # @return [Google::Cloud::Pubsub::Snapshot]
489
533
  #
@@ -505,9 +549,9 @@ module Google
505
549
  # snapshot = sub.create_snapshot
506
550
  # snapshot.name #=> "projects/my-project/snapshots/gcr-analysis-..."
507
551
  #
508
- def create_snapshot snapshot_name = nil
552
+ def create_snapshot snapshot_name = nil, labels: nil
509
553
  ensure_service!
510
- grpc = service.create_snapshot name, snapshot_name
554
+ grpc = service.create_snapshot name, snapshot_name, labels: labels
511
555
  Snapshot.from_grpc grpc, service
512
556
  end
513
557
  alias new_snapshot create_snapshot
@@ -28,6 +28,8 @@ module Google
28
28
  #
29
29
  # A named resource to which messages are published.
30
30
  #
31
+ # See {Project#create_topic} and {Project#topic}.
32
+ #
31
33
  # @example
32
34
  # require "google/cloud/pubsub"
33
35
  #
@@ -84,10 +86,49 @@ module Google
84
86
  ##
85
87
  # The name of the topic in the form of
86
88
  # "/projects/project-identifier/topics/topic-name".
89
+ #
90
+ # @return [String]
91
+ #
87
92
  def name
88
93
  @grpc.name
89
94
  end
90
95
 
96
+ ##
97
+ # A hash of user-provided labels associated with this topic. Labels can
98
+ # be used to organize and group topics. See [Creating and Managing
99
+ # Labels](https://cloud.google.com/pubsub/docs/labels).
100
+ #
101
+ # The returned hash is frozen and changes are not allowed. Use
102
+ # {#labels=} to update the labels for this topic.
103
+ #
104
+ # @return [Hash] The frozen labels hash.
105
+ #
106
+ def labels
107
+ @grpc.labels.to_h.freeze
108
+ end
109
+
110
+ ##
111
+ # Sets the hash of user-provided labels associated with this
112
+ # topic. Labels can be used to organize and group topics.
113
+ # Label keys and values can be no longer than 63 characters, can only
114
+ # contain lowercase letters, numeric characters, underscores and dashes.
115
+ # International characters are allowed. Label values are optional. Label
116
+ # keys must start with a letter and each label in the list must have a
117
+ # different key. See [Creating and Managing
118
+ # Labels](https://cloud.google.com/pubsub/docs/labels).
119
+ #
120
+ # @param [Hash] new_labels The new labels hash.
121
+ #
122
+ def labels= new_labels
123
+ raise ArgumentError, "Value must be a Hash" if new_labels.nil?
124
+ labels_map = Google::Protobuf::Map.new(:string, :string)
125
+ Hash(new_labels).each { |k, v| labels_map[String(k)] = String(v) }
126
+ update_grpc = @grpc.dup
127
+ update_grpc.labels = labels_map
128
+ @grpc = service.update_topic update_grpc, :labels
129
+ @lazy = nil
130
+ end
131
+
91
132
  ##
92
133
  # Permanently deletes the topic.
93
134
  #
@@ -131,6 +172,14 @@ module Google
131
172
  # Default is 604,800 seconds (7 days).
132
173
  # @param [String] endpoint A URL locating the endpoint to which messages
133
174
  # should be pushed.
175
+ # @param [Hash] labels A hash of user-provided labels associated with
176
+ # the subscription. You can use these to organize and group your
177
+ # subscriptions. Label keys and values can be no longer than 63
178
+ # characters, can only contain lowercase letters, numeric characters,
179
+ # underscores and dashes. International characters are allowed. Label
180
+ # values are optional. Label keys must start with a letter and each
181
+ # label in the list must have a different key. See [Creating and
182
+ # Managing Labels](https://cloud.google.com/pubsub/docs/labels).
134
183
  #
135
184
  # @return [Google::Cloud::Pubsub::Subscription]
136
185
  #
@@ -154,10 +203,10 @@ module Google
154
203
  # endpoint: "https://example.com/push"
155
204
  #
156
205
  def subscribe subscription_name, deadline: nil, retain_acked: false,
157
- retention: nil, endpoint: nil
206
+ retention: nil, endpoint: nil, labels: nil
158
207
  ensure_service!
159
208
  options = { deadline: deadline, retain_acked: retain_acked,
160
- retention: retention, endpoint: endpoint }
209
+ retention: retention, endpoint: endpoint, labels: labels }
161
210
  grpc = service.create_subscription name, subscription_name, options
162
211
  Subscription.from_grpc grpc, service
163
212
  end
@@ -16,46 +16,46 @@
16
16
  module Google
17
17
  module Iam
18
18
  module V1
19
- # Request message for +SetIamPolicy+ method.
19
+ # Request message for `SetIamPolicy` method.
20
20
  # @!attribute [rw] resource
21
21
  # @return [String]
22
22
  # REQUIRED: The resource for which the policy is being specified.
23
- # +resource+ is usually specified as a path. For example, a Project
24
- # resource is specified as +projects/\\{project}+.
23
+ # `resource` is usually specified as a path. For example, a Project
24
+ # resource is specified as `projects/{project}`.
25
25
  # @!attribute [rw] policy
26
26
  # @return [Google::Iam::V1::Policy]
27
- # REQUIRED: The complete policy to be applied to the +resource+. The size of
27
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
28
28
  # the policy is limited to a few 10s of KB. An empty policy is a
29
29
  # valid policy but certain Cloud Platform services (such as Projects)
30
30
  # might reject them.
31
31
  class SetIamPolicyRequest; end
32
32
 
33
- # Request message for +GetIamPolicy+ method.
33
+ # Request message for `GetIamPolicy` method.
34
34
  # @!attribute [rw] resource
35
35
  # @return [String]
36
36
  # REQUIRED: The resource for which the policy is being requested.
37
- # +resource+ is usually specified as a path. For example, a Project
38
- # resource is specified as +projects/\\{project}+.
37
+ # `resource` is usually specified as a path. For example, a Project
38
+ # resource is specified as `projects/{project}`.
39
39
  class GetIamPolicyRequest; end
40
40
 
41
- # Request message for +TestIamPermissions+ method.
41
+ # Request message for `TestIamPermissions` method.
42
42
  # @!attribute [rw] resource
43
43
  # @return [String]
44
44
  # REQUIRED: The resource for which the policy detail is being requested.
45
- # +resource+ is usually specified as a path. For example, a Project
46
- # resource is specified as +projects/\\{project}+.
45
+ # `resource` is usually specified as a path. For example, a Project
46
+ # resource is specified as `projects/{project}`.
47
47
  # @!attribute [rw] permissions
48
48
  # @return [Array<String>]
49
- # The set of permissions to check for the +resource+. Permissions with
49
+ # The set of permissions to check for the `resource`. Permissions with
50
50
  # wildcards (such as '*' or 'storage.*') are not allowed. For more
51
51
  # information see
52
52
  # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
53
53
  class TestIamPermissionsRequest; end
54
54
 
55
- # Response message for +TestIamPermissions+ method.
55
+ # Response message for `TestIamPermissions` method.
56
56
  # @!attribute [rw] permissions
57
57
  # @return [Array<String>]
58
- # A subset of +TestPermissionsRequest.permissions+ that the caller is
58
+ # A subset of `TestPermissionsRequest.permissions` that the caller is
59
59
  # allowed.
60
60
  class TestIamPermissionsResponse; end
61
61
  end
@@ -20,9 +20,9 @@ module Google
20
20
  # specify access control policies for Cloud Platform resources.
21
21
  #
22
22
  #
23
- # A +Policy+ consists of a list of +bindings+. A +Binding+ binds a list of
24
- # +members+ to a +role+, where the members can be user accounts, Google groups,
25
- # Google domains, and service accounts. A +role+ is a named list of permissions
23
+ # A `Policy` consists of a list of `bindings`. A `Binding` binds a list of
24
+ # `members` to a `role`, where the members can be user accounts, Google groups,
25
+ # Google domains, and service accounts. A `role` is a named list of permissions
26
26
  # defined by IAM.
27
27
  #
28
28
  # **Example**
@@ -49,55 +49,55 @@ module Google
49
49
  # [IAM developer's guide](https://cloud.google.com/iam).
50
50
  # @!attribute [rw] version
51
51
  # @return [Integer]
52
- # Version of the +Policy+. The default version is 0.
52
+ # Version of the `Policy`. The default version is 0.
53
53
  # @!attribute [rw] bindings
54
54
  # @return [Array<Google::Iam::V1::Binding>]
55
- # Associates a list of +members+ to a +role+.
56
- # Multiple +bindings+ must not be specified for the same +role+.
57
- # +bindings+ with no members will result in an error.
55
+ # Associates a list of `members` to a `role`.
56
+ # Multiple `bindings` must not be specified for the same `role`.
57
+ # `bindings` with no members will result in an error.
58
58
  # @!attribute [rw] etag
59
59
  # @return [String]
60
- # +etag+ is used for optimistic concurrency control as a way to help
60
+ # `etag` is used for optimistic concurrency control as a way to help
61
61
  # prevent simultaneous updates of a policy from overwriting each other.
62
- # It is strongly suggested that systems make use of the +etag+ in the
62
+ # It is strongly suggested that systems make use of the `etag` in the
63
63
  # read-modify-write cycle to perform policy updates in order to avoid race
64
- # conditions: An +etag+ is returned in the response to +getIamPolicy+, and
65
- # systems are expected to put that etag in the request to +setIamPolicy+ to
64
+ # conditions: An `etag` is returned in the response to `getIamPolicy`, and
65
+ # systems are expected to put that etag in the request to `setIamPolicy` to
66
66
  # ensure that their change will be applied to the same version of the policy.
67
67
  #
68
- # If no +etag+ is provided in the call to +setIamPolicy+, then the existing
68
+ # If no `etag` is provided in the call to `setIamPolicy`, then the existing
69
69
  # policy is overwritten blindly.
70
70
  class Policy; end
71
71
 
72
- # Associates +members+ with a +role+.
72
+ # Associates `members` with a `role`.
73
73
  # @!attribute [rw] role
74
74
  # @return [String]
75
- # Role that is assigned to +members+.
76
- # For example, +roles/viewer+, +roles/editor+, or +roles/owner+.
75
+ # Role that is assigned to `members`.
76
+ # For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
77
77
  # Required
78
78
  # @!attribute [rw] members
79
79
  # @return [Array<String>]
80
80
  # Specifies the identities requesting access for a Cloud Platform resource.
81
- # +members+ can have the following values:
81
+ # `members` can have the following values:
82
82
  #
83
- # * +allUsers+: A special identifier that represents anyone who is
83
+ # * `allUsers`: A special identifier that represents anyone who is
84
84
  # on the internet; with or without a Google account.
85
85
  #
86
- # * +allAuthenticatedUsers+: A special identifier that represents anyone
86
+ # * `allAuthenticatedUsers`: A special identifier that represents anyone
87
87
  # who is authenticated with a Google account or a service account.
88
88
  #
89
- # * +user:\\{emailid}+: An email address that represents a specific Google
90
- # account. For example, +alice@gmail.com+ or +joe@example.com+.
89
+ # * `user:{emailid}`: An email address that represents a specific Google
90
+ # account. For example, `alice@gmail.com` or `joe@example.com`.
91
91
  #
92
92
  #
93
- # * +serviceAccount:\\{emailid}+: An email address that represents a service
94
- # account. For example, +my-other-app@appspot.gserviceaccount.com+.
93
+ # * `serviceAccount:{emailid}`: An email address that represents a service
94
+ # account. For example, `my-other-app@appspot.gserviceaccount.com`.
95
95
  #
96
- # * +group:\\{emailid}+: An email address that represents a Google group.
97
- # For example, +admins@example.com+.
96
+ # * `group:{emailid}`: An email address that represents a Google group.
97
+ # For example, `admins@example.com`.
98
98
  #
99
- # * +domain:\\{domain}+: A Google Apps domain name that represents all the
100
- # users of that domain. For example, +google.com+ or +example.com+.
99
+ # * `domain:{domain}`: A Google Apps domain name that represents all the
100
+ # users of that domain. For example, `google.com` or `example.com`.
101
101
  class Binding; end
102
102
 
103
103
  # The difference delta between two policies.
@@ -114,8 +114,8 @@ module Google
114
114
  # Required
115
115
  # @!attribute [rw] role
116
116
  # @return [String]
117
- # Role that is assigned to +members+.
118
- # For example, +roles/viewer+, +roles/editor+, or +roles/owner+.
117
+ # Role that is assigned to `members`.
118
+ # For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
119
119
  # Required
120
120
  # @!attribute [rw] member
121
121
  # @return [String]