Class: Google::Cloud::PubSub::Schema
- Inherits:
-
Object
- Object
- Google::Cloud::PubSub::Schema
- Defined in:
- lib/google/cloud/pubsub/schema.rb,
lib/google/cloud/pubsub/schema/list.rb
Overview
Schema
A schema resource.
Defined Under Namespace
Classes: List
Lifecycle collapse
-
#exists? ⇒ Boolean
Determines whether the schema exists in the Pub/Sub service.
-
#reference? ⇒ Boolean
Determines whether the schema object was created without retrieving the resource representation from the Pub/Sub service.
-
#reload!(view: nil) ⇒ Google::Cloud::PubSub::Schema
(also: #refresh!)
Reloads the schema with current data from the Pub/Sub service.
-
#resource? ⇒ Boolean
Determines whether the schema object was created with a resource representation from the Pub/Sub service.
-
#resource_full? ⇒ Boolean
Whether the schema was created with a full resource representation from the Pub/Sub service.
-
#resource_partial? ⇒ Boolean
Whether the schema was created with a partial resource representation from the Pub/Sub service.
Instance Method Summary collapse
-
#definition ⇒ String?
The definition of the schema.
-
#delete ⇒ Boolean
Removes the schema, if it exists.
-
#name ⇒ String
The name of the schema.
-
#type ⇒ String?
The type of the schema.
-
#validate_message(message_data, message_encoding) ⇒ Boolean
Validates a message against a schema.
Instance Method Details
#definition ⇒ String?
The definition of the schema. This should be a string representing the full definition of the schema that is a valid schema definition of the type specified in #type.
82 83 84 85 |
# File 'lib/google/cloud/pubsub/schema.rb', line 82 def definition return nil if reference? @grpc.definition if @grpc.definition && !@grpc.definition.empty? end |
#delete ⇒ Boolean
Removes the schema, if it exists.
130 131 132 133 134 |
# File 'lib/google/cloud/pubsub/schema.rb', line 130 def delete ensure_service! service.delete_schema name true end |
#exists? ⇒ Boolean
Determines whether the schema exists in the Pub/Sub service.
189 190 191 192 193 194 195 196 197 198 |
# File 'lib/google/cloud/pubsub/schema.rb', line 189 def exists? # Always true if the object is not set as reference return true unless reference? # If we have a value, return it return @exists unless @exists.nil? ensure_grpc! @exists = true rescue Google::Cloud::NotFoundError @exists = false end |
#name ⇒ String
The name of the schema.
59 60 61 |
# File 'lib/google/cloud/pubsub/schema.rb', line 59 def name @grpc.name end |
#reference? ⇒ Boolean
Determines whether the schema object was created without retrieving the resource representation from the Pub/Sub service.
215 216 217 |
# File 'lib/google/cloud/pubsub/schema.rb', line 215 def reference? @grpc.type.nil? || @grpc.type == :TYPE_UNSPECIFIED end |
#reload!(view: nil) ⇒ Google::Cloud::PubSub::Schema Also known as: refresh!
Reloads the schema with current data from the Pub/Sub service.
168 169 170 171 172 173 174 175 |
# File 'lib/google/cloud/pubsub/schema.rb', line 168 def reload! view: nil ensure_service! @view = view || @view @grpc = service.get_schema name, @view @reference = nil @exists = nil self end |
#resource? ⇒ Boolean
Determines whether the schema object was created with a resource representation from the Pub/Sub service.
234 235 236 |
# File 'lib/google/cloud/pubsub/schema.rb', line 234 def resource? !reference? end |
#resource_full? ⇒ Boolean
Whether the schema was created with a full resource representation from the Pub/Sub service.
274 275 276 |
# File 'lib/google/cloud/pubsub/schema.rb', line 274 def resource_full? resource? && @grpc.definition && !@grpc.definition.empty? end |
#resource_partial? ⇒ Boolean
Whether the schema was created with a partial resource representation from the Pub/Sub service.
255 256 257 |
# File 'lib/google/cloud/pubsub/schema.rb', line 255 def resource_partial? resource? && !resource_full? end |
#type ⇒ String?
The type of the schema. Possible values include:
PROTOCOL_BUFFER
- A Protocol Buffer schema definition.AVRO
- An Avro schema definition.
71 72 73 74 |
# File 'lib/google/cloud/pubsub/schema.rb', line 71 def type return nil if reference? @grpc.type end |