class Comet::Organization

Organization is a typed class wrapper around the underlying Comet Server API data structure.

Attributes

branding[RW]

@type [Comet::BrandingOptions] branding

email[RW]

@type [Comet::AdminEmailOptions] email

hosts[RW]

@type [Array<String>] hosts

is_suspended[RW]

@type [Boolean] is_suspended

name[RW]

@type [String] name

remote_storage[RW]

@type [Array<Comet::RemoteStorageOption>] remote_storage

software_build_role[RW]

@type [Comet::SoftwareBuildRoleOptions] software_build_role

unknown_json_fields[RW]

@type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations

webhook_options[RW]

@type [Hash{String => Comet::WebhookOption}] webhook_options

Public Class Methods

new() click to toggle source
# File lib/comet/models/organization.rb, line 44
def initialize
  clear
end

Public Instance Methods

clear() click to toggle source
# File lib/comet/models/organization.rb, line 48
def clear
  @name = ''
  @hosts = []
  @software_build_role = Comet::SoftwareBuildRoleOptions.new
  @branding = Comet::BrandingOptions.new
  @remote_storage = []
  @webhook_options = {}
  @email = Comet::AdminEmailOptions.new
  @unknown_json_fields = {}
end
from_hash(obj) click to toggle source

@param [Hash] obj The complete object as a Ruby hash

# File lib/comet/models/organization.rb, line 67
def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'Name'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @name = v
    when 'Hosts'
      if v.nil?
        @hosts = []
      else
        @hosts = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @hosts[i1] = v1
        end
      end
    when 'SoftwareBuildRole'
      @software_build_role = Comet::SoftwareBuildRoleOptions.new
      @software_build_role.from_hash(v)
    when 'Branding'
      @branding = Comet::BrandingOptions.new
      @branding.from_hash(v)
    when 'RemoteStorage'
      if v.nil?
        @remote_storage = []
      else
        @remote_storage = Array.new(v.length)
        v.each_with_index do |v1, i1|
          @remote_storage[i1] = Comet::RemoteStorageOption.new
          @remote_storage[i1].from_hash(v1)
        end
      end
    when 'WebhookOptions'
      @webhook_options = {}
      if v.nil?
        @webhook_options = {}
      else
        v.each do |k1, v1|
          @webhook_options[k1] = Comet::WebhookOption.new
          @webhook_options[k1].from_hash(v1)
        end
      end
    when 'Email'
      @email = Comet::AdminEmailOptions.new
      @email.from_hash(v)
    when 'IsSuspended'
      @is_suspended = v
    else
      @unknown_json_fields[k] = v
    end
  end
end
from_json(json_string) click to toggle source

@param [String] json_string The complete object in JSON format

# File lib/comet/models/organization.rb, line 60
def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end
to_h() click to toggle source

@return [Hash] The complete object as a Ruby hash

# File lib/comet/models/organization.rb, line 142
def to_h
  to_hash
end
to_hash() click to toggle source

@return [Hash] The complete object as a Ruby hash

# File lib/comet/models/organization.rb, line 125
def to_hash
  ret = {}
  ret['Name'] = @name
  ret['Hosts'] = @hosts
  ret['SoftwareBuildRole'] = @software_build_role
  ret['Branding'] = @branding
  ret['RemoteStorage'] = @remote_storage
  ret['WebhookOptions'] = @webhook_options
  ret['Email'] = @email
  ret['IsSuspended'] = @is_suspended
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end
to_json(options = {}) click to toggle source

@return [String] The complete object as a JSON string

# File lib/comet/models/organization.rb, line 147
def to_json(options = {})
  to_hash.to_json(options)
end