class Cumulus::S3::LoggingConfig

Attributes

prefix[R]
target_bucket[R]

Public Class Methods

new(json = nil) click to toggle source

Public: Constructor

json - a hash representing the JSON configuration. Expects to be handed

the 'logging' node of S3 configuration.
# File lib/s3/models/LoggingConfig.rb, line 11
def initialize(json = nil)
  if json
    @target_bucket = json["target-bucket"]
    @prefix = json["prefix"] || ""
  end
end

Public Instance Methods

!=(other) click to toggle source

Public: Check if this LoggingConfig is not equal to the other object

other - the other object to check

Returns whether this LoggingConfig is not equal to `other`

# File lib/s3/models/LoggingConfig.rb, line 68
def !=(other)
  !(self == other)
end
==(other) click to toggle source

Public: Check LoggingConfig equality with other objects

other - the other object to check

Returns whether this LoggingConfig is equal to `other`

# File lib/s3/models/LoggingConfig.rb, line 53
def ==(other)
  if !other.is_a? LoggingConfig or
      @target_bucket != other.target_bucket or
      @prefix != other.prefix
    false
  else
    true
  end
end
populate!(aws) click to toggle source

Public: Populate this LoggingConfig with the values in an AWS BucketLogging object.

aws - the aws object to populate from

# File lib/s3/models/LoggingConfig.rb, line 22
def populate!(aws)
  @target_bucket = aws.logging_enabled.target_bucket
  @prefix = aws.logging_enabled.target_prefix
end
to_aws() click to toggle source

Public: Produce a hash that is compatible with AWS logging configuration.

Returns the logging configuration in AWS format

# File lib/s3/models/LoggingConfig.rb, line 30
def to_aws
  {
    target_bucket: @target_bucket,
    target_prefix: @prefix
  }
end
to_h() click to toggle source

Public: Convert this LoggingConfig to a hash that matches Cumulus configuration.

Returns the hash

# File lib/s3/models/LoggingConfig.rb, line 41
def to_h
  {
    "target-bucket" => @target_bucket,
    "prefix" => @prefix,
  }.reject { |k, v| v.nil? }
end
to_s() click to toggle source
# File lib/s3/models/LoggingConfig.rb, line 72
def to_s
  if @target_bucket and @prefix
    "Target bucket: #{@target_bucket} with prefix #{@prefix}"
  elsif @target_bucket
    "Target bucket: #{@target_bucket}"
  end
end