Class: OCI::Nosql::Models::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/nosql/models/schema.rb

Overview

The table schema information as a JSON object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Schema

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/oci/nosql/models/schema.rb', line 67

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.columns = attributes[:'columns'] if attributes[:'columns']

  self.primary_key = attributes[:'primaryKey'] if attributes[:'primaryKey']

  raise 'You cannot provide both :primaryKey and :primary_key' if attributes.key?(:'primaryKey') && attributes.key?(:'primary_key')

  self.primary_key = attributes[:'primary_key'] if attributes[:'primary_key']

  self.shard_key = attributes[:'shardKey'] if attributes[:'shardKey']

  raise 'You cannot provide both :shardKey and :shard_key' if attributes.key?(:'shardKey') && attributes.key?(:'shard_key')

  self.shard_key = attributes[:'shard_key'] if attributes[:'shard_key']

  self.ttl = attributes[:'ttl'] if attributes[:'ttl']

  self.identity = attributes[:'identity'] if attributes[:'identity']
end

Instance Attribute Details

#columnsArray<OCI::Nosql::Models::Column>

[Required] The columns of a table.

Returns:



13
14
15
# File 'lib/oci/nosql/models/schema.rb', line 13

def columns
  @columns
end

#identityOCI::Nosql::Models::Identity



28
29
30
# File 'lib/oci/nosql/models/schema.rb', line 28

def identity
  @identity
end

#primary_keyArray<String>

[Required] A list of column names that make up a key.

Returns:

  • (Array<String>)


17
18
19
# File 'lib/oci/nosql/models/schema.rb', line 17

def primary_key
  @primary_key
end

#shard_keyArray<String>

[Required] A list of column names that make up a key.

Returns:

  • (Array<String>)


21
22
23
# File 'lib/oci/nosql/models/schema.rb', line 21

def shard_key
  @shard_key
end

#ttlInteger

[Required] The default Time-to-Live for the table, in days.

Returns:

  • (Integer)


25
26
27
# File 'lib/oci/nosql/models/schema.rb', line 25

def ttl
  @ttl
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/oci/nosql/models/schema.rb', line 31

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'columns': :'columns',
    'primary_key': :'primaryKey',
    'shard_key': :'shardKey',
    'ttl': :'ttl',
    'identity': :'identity'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/oci/nosql/models/schema.rb', line 44

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'columns': :'Array<OCI::Nosql::Models::Column>',
    'primary_key': :'Array<String>',
    'shard_key': :'Array<String>',
    'ttl': :'Integer',
    'identity': :'OCI::Nosql::Models::Identity'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



99
100
101
102
103
104
105
106
107
108
# File 'lib/oci/nosql/models/schema.rb', line 99

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    columns == other.columns &&
    primary_key == other.primary_key &&
    shard_key == other.shard_key &&
    ttl == other.ttl &&
    identity == other.identity
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/oci/nosql/models/schema.rb', line 133

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


113
114
115
# File 'lib/oci/nosql/models/schema.rb', line 113

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



122
123
124
# File 'lib/oci/nosql/models/schema.rb', line 122

def hash
  [columns, primary_key, shard_key, ttl, identity].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



166
167
168
169
170
171
172
173
174
175
# File 'lib/oci/nosql/models/schema.rb', line 166

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



160
161
162
# File 'lib/oci/nosql/models/schema.rb', line 160

def to_s
  to_hash.to_s
end