Class: Zm::Client::Resource

Inherits:
Base::AdminObject show all
Defined in:
lib/zm/client/resource/resource.rb

Overview

objectClass: zimbraCalendarResource

Instance Attribute Summary collapse

Attributes inherited from Base::Object

#grantee_type, #id, #name, #parent, #token

Instance Method Summary collapse

Methods inherited from Base::AdminObject

#init_from_json, #soap_account_connector, #soap_admin_connector, #to_h

Methods inherited from Base::Object

#arrow_name, #clone, #concat, #convert_json_string_value, #disable_builder, #enable_builder, #init_from_json, #instance_variables_array, #instance_variables_hash, #logger, #recorded?, #save!, #to_s, #use_builder?

Constructor Details

#initialize(parent) ⇒ Resource

Returns a new instance of Resource.



11
12
13
14
15
# File 'lib/zm/client/resource/resource.rb', line 11

def initialize(parent)
  extend(ResourceCommon)
  super(parent)
  @grantee_type = 'usr'.freeze
end

Instance Attribute Details

#home_urlObject

Returns the value of attribute home_url.



9
10
11
# File 'lib/zm/client/resource/resource.rb', line 9

def home_url
  @home_url
end

#zimbraCalResAutoDeclineRecurringObject

Returns the value of attribute zimbraCalResAutoDeclineRecurring.



9
10
11
# File 'lib/zm/client/resource/resource.rb', line 9

def zimbraCalResAutoDeclineRecurring
  @zimbraCalResAutoDeclineRecurring
end

Instance Method Details

#account_login_passwordObject

Raises:



46
47
48
49
50
# File 'lib/zm/client/resource/resource.rb', line 46

def 
  raise ZmError, 'password is required to login !' if password.nil?

  @token = sacc.auth_password(@name, @password)
end

#account_login_preauthObject

Raises:



39
40
41
42
43
44
# File 'lib/zm/client/resource/resource.rb', line 39

def 
  domain_key
  raise ZmError, 'domain key is required to login !' if @domainkey.nil?

  @token = sacc.auth_preauth(@name, @domainkey)
end

#admin_loginObject



52
53
54
# File 'lib/zm/client/resource/resource.rb', line 52

def 
  @token = sac.delegate_auth(@name)
end

#all_instance_variable_keysObject



17
18
19
# File 'lib/zm/client/resource/resource.rb', line 17

def all_instance_variable_keys
  ResourceCommon::ALL_ATTRS
end

#create!Object



97
98
99
100
101
102
103
104
# File 'lib/zm/client/resource/resource.rb', line 97

def create!
  rep = sac.create_resource(
    @name,
    @password,
    instance_variables_array(attrs_write)
  )
  @id = rep[:Body][:CreateCalendarResourceResponse][:calresource].first[:id]
end

#delete!Object



81
82
83
# File 'lib/zm/client/resource/resource.rb', line 81

def delete!
  sac.delete_resource(@id)
end

#domain_keyObject



60
61
62
# File 'lib/zm/client/resource/resource.rb', line 60

def domain_key
  @domainkey ||= @parent.domain_key(domain_name)
end

#domain_nameObject



56
57
58
# File 'lib/zm/client/resource/resource.rb', line 56

def domain_name
  @name.split('@').last
end

#foldersObject



77
78
79
# File 'lib/zm/client/resource/resource.rb', line 77

def folders
  @folders ||= FoldersCollection.new(self)
end

#infosObject



64
65
66
# File 'lib/zm/client/resource/resource.rb', line 64

def infos
  @infos ||= read_infos
end

#logged?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/zm/client/resource/resource.rb', line 27

def logged?
  !@token.nil?
end

#loginObject



31
32
33
34
35
36
37
# File 'lib/zm/client/resource/resource.rb', line 31

def 
  if @parent.logged?
    
  else
    
  end
end

#modify!Object



90
91
92
93
94
95
# File 'lib/zm/client/resource/resource.rb', line 90

def modify!
  attrs_to_modify = instance_variables_array(attrs_write)
  return if attrs_to_modify.empty?

  sac.modify_resource(@id, attrs_to_modify)
end

#read_infosObject



68
69
70
71
72
73
74
75
# File 'lib/zm/client/resource/resource.rb', line 68

def read_infos
  @infos = sacc.get_info(@token)[:Body][:GetInfoResponse]
  @id = @infos[:id]
  @used = @infos[:used]
  @public_url = @infos[:publicURL]
  @zimbraCOSId = @infos[:cos][:id]
  @home_url = @infos[:rest]
end

#rename!(email) ⇒ Object



106
107
108
109
# File 'lib/zm/client/resource/resource.rb', line 106

def rename!(email)
  sac.rename_resource(@id, email)
  @name = email
end

#rest_account_connectorObject Also known as: rac



21
22
23
# File 'lib/zm/client/resource/resource.rb', line 21

def 
   ||= RestAccountConnector.new
end

#update!(hash) ⇒ Object



85
86
87
88
# File 'lib/zm/client/resource/resource.rb', line 85

def update!(hash)
  sac.modify_resource(@id, hash)
  hash.each { |k, v| send "#{k}=", v }
end

#uploaderObject



111
112
113
# File 'lib/zm/client/resource/resource.rb', line 111

def uploader
  @uploader ||= Upload.new(self)
end