Class: OCI::AiLanguage::Models::PiiEntityMask

Inherits:
PiiEntityMasking show all
Defined in:
lib/oci/ai_language/models/pii_entity_mask.rb

Overview

Mask PII entities with the given masking character.

Constant Summary

Constants inherited from PiiEntityMasking

OCI::AiLanguage::Models::PiiEntityMasking::MODE_ENUM

Instance Attribute Summary collapse

Attributes inherited from PiiEntityMasking

#exclude, #mode, #should_detect

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PiiEntityMasking

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ PiiEntityMask

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :exclude (Array<String>)

    The value to assign to the #exclude proprety

  • :should_detect (BOOLEAN)

    The value to assign to the #should_detect proprety

  • :masking_character (String)

    The value to assign to the #masking_character property

  • :leave_characters_unmasked (Integer)

    The value to assign to the #leave_characters_unmasked property

  • :is_unmasked_from_end (BOOLEAN)

    The value to assign to the #is_unmasked_from_end property



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 66

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

  attributes['mode'] = 'MASK'

  super(attributes)

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

  self.masking_character = attributes[:'maskingCharacter'] if attributes[:'maskingCharacter']

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

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

  self.leave_characters_unmasked = attributes[:'leaveCharactersUnmasked'] if attributes[:'leaveCharactersUnmasked']

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

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

  self.is_unmasked_from_end = attributes[:'isUnmaskedFromEnd'] unless attributes[:'isUnmaskedFromEnd'].nil?
  self.is_unmasked_from_end = false if is_unmasked_from_end.nil? && !attributes.key?(:'isUnmaskedFromEnd') # rubocop:disable Style/StringLiterals

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

  self.is_unmasked_from_end = attributes[:'is_unmasked_from_end'] unless attributes[:'is_unmasked_from_end'].nil?
  self.is_unmasked_from_end = false if is_unmasked_from_end.nil? && !attributes.key?(:'isUnmaskedFromEnd') && !attributes.key?(:'is_unmasked_from_end') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#is_unmasked_from_endBOOLEAN

Unmask from the end. By default, the whole entity is masked. This field works in concert with leaveCharactersUnmasked. For example, leaveCharactersUnmasked is 3 and isUnmaskedFromEnd is true, then if the entity is India the masked entity/result is **dia.

Returns:

  • (BOOLEAN)


25
26
27
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 25

def is_unmasked_from_end
  @is_unmasked_from_end
end

#leave_characters_unmaskedInteger

Number of characters to leave unmasked. By default, the whole entity is masked.

Returns:

  • (Integer)


18
19
20
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 18

def leave_characters_unmasked
  @leave_characters_unmasked
end

#masking_characterString

Masking character. By default, the character is an asterisk (*)

Returns:

  • (String)


14
15
16
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 14

def masking_character
  @masking_character
end

Class Method Details

.attribute_mapObject

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



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 28

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'mode': :'mode',
    'exclude': :'exclude',
    'should_detect': :'shouldDetect',
    'masking_character': :'maskingCharacter',
    'leave_characters_unmasked': :'leaveCharactersUnmasked',
    'is_unmasked_from_end': :'isUnmaskedFromEnd'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 42

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'mode': :'String',
    'exclude': :'Array<String>',
    'should_detect': :'BOOLEAN',
    'masking_character': :'String',
    'leave_characters_unmasked': :'Integer',
    'is_unmasked_from_end': :'BOOLEAN'
    # 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



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 104

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

  self.class == other.class &&
    mode == other.mode &&
    exclude == other.exclude &&
    should_detect == other.should_detect &&
    masking_character == other.masking_character &&
    leave_characters_unmasked == other.leave_characters_unmasked &&
    is_unmasked_from_end == other.is_unmasked_from_end
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



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 139

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


119
120
121
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 119

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



128
129
130
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 128

def hash
  [mode, exclude, should_detect, masking_character, leave_characters_unmasked, is_unmasked_from_end].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



172
173
174
175
176
177
178
179
180
181
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 172

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



166
167
168
# File 'lib/oci/ai_language/models/pii_entity_mask.rb', line 166

def to_s
  to_hash.to_s
end