Class: RubyAem::Aem

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_aem.rb

Overview

Aem class represents an AEM client instance.

Instance Method Summary collapse

Constructor Details

#initialize(conf = {}) ⇒ Object

Initialise a Ruby AEM instance.

  • username: username used to authenticate to AEM instance, default: ‘admin’

  • password: password used to authenticate to AEM instance, default: ‘admin’

  • protocol: AEM instance protocol (http or https), default: ‘http’

  • host: AEM instance host name, default: ‘localhost’

  • port: AEM instance port, default: 4502

  • timeout: connection timeout in seconds, default: 300 seconds

  • debug: if true, then additional debug messages will be included, default: false

Parameters:

  • conf (defaults to: {})

    configuration hash of the following configuration values:



53
54
55
56
57
58
59
60
61
62
63
64
65
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
96
# File 'lib/ruby_aem.rb', line 53

def initialize(conf = {})
  sanitise_conf(conf)

  SwaggerAemClient.configure { |swagger_conf|
    [
      swagger_conf.scheme = conf[:protocol],
      swagger_conf.host = "#{conf[:host]}:#{conf[:port]}",
      swagger_conf.username = conf[:username],
      swagger_conf.password = conf[:password],
      swagger_conf.timeout = conf[:timeout],
      swagger_conf.debugging = conf[:debug],
      swagger_conf.verify_ssl = conf[:verify_ssl],
      swagger_conf.verify_ssl_host = conf[:verify_ssl],
      swagger_conf.params_encoding = :multi
    ]
  }

  SwaggerAemOsgiClient.configure { |swagger_conf|
    [
      swagger_conf.scheme = conf[:protocol],
      swagger_conf.host = "#{conf[:host]}:#{conf[:port]}",
      swagger_conf.username = conf[:username],
      swagger_conf.password = conf[:password],
      swagger_conf.timeout = conf[:timeout],
      swagger_conf.debugging = conf[:debug],
      swagger_conf.verify_ssl = conf[:verify_ssl],
      swagger_conf.verify_ssl_host = conf[:verify_ssl],
      swagger_conf.params_encoding = :multi
    ]
  }

  apis = {
    console: SwaggerAemClient::ConsoleApi.new,
    configmgr: SwaggerAemOsgiClient::ConfigmgrApi.new,
    custom: SwaggerAemClient::CustomApi.new,
    cq: SwaggerAemClient::CqApi.new,
    crx: SwaggerAemClient::CrxApi.new,
    sling: SwaggerAemClient::SlingApi.new
  }

  spec = YAML.load_file(File.expand_path('../../conf/spec.yaml', __FILE__))

  @client = RubyAem::Client.new(apis, spec)
end

Instance Method Details

#aemObject

Create an AEM instance.

Returns:

  • new RubyAem::Resources::Aem instance



117
118
119
# File 'lib/ruby_aem.rb', line 117

def aem
  RubyAem::Resources::Aem.new(@client)
end

#aem_configmgrObject

Create an AEM ConfigMgr instance.

Returns:

  • new RubyAem::Resources::Aem instance



124
125
126
# File 'lib/ruby_aem.rb', line 124

def aem_configmgr
  RubyAem::Resources::AemConfigMgr.new(@client)
end

#authorizable_keystore(intermediate_path, authorizable_id) ⇒ Object

Create a Keystore instance for given authorizable id.

Returns:

  • new RubyAem::Resources::AuhtorizableKeystore instance



185
186
187
# File 'lib/ruby_aem.rb', line 185

def authorizable_keystore(intermediate_path, authorizable_id)
  RubyAem::Resources::AuthorizableKeystore.new(@client, intermediate_path, authorizable_id)
end

#bundle(name) ⇒ Object

Create a bundle instance.

Parameters:

  • name

    the bundle’s name, e.g. com.adobe.cq.social.cq-social-forum

Returns:

  • new RubyAem::Resources::Bundle instance



132
133
134
# File 'lib/ruby_aem.rb', line 132

def bundle(name)
  RubyAem::Resources::Bundle.new(@client, name)
end

#certificate(serial_number) ⇒ Object

Create a certificate instance.

Parameters:

  • serial_number

    the certificate’s serial number

Returns:

  • new RubyAem::Resources::Certificate instance



140
141
142
# File 'lib/ruby_aem.rb', line 140

def certificate(serial_number)
  RubyAem::Resources::Certificate.new(@client, serial_number)
end

#certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id) ⇒ Object

# Create a certificate chain instance. # # @return new RubyAem::Resources::CertificateChain instance

Parameters:

  • private_key_alias

    Alias of the private key associated to this certificate chain

  • keystore_intermediate_path

    AEM User home path

  • keystore_authorizable_id

    AEM User id



150
151
152
# File 'lib/ruby_aem.rb', line 150

def certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id)
  RubyAem::Resources::CertificateChain.new(@client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id)
end

#config_property(name, type, value) ⇒ Object

Create a config property instance.

Parameters:

  • name

    the property’s name

  • type

    the property’s type, e.g. Boolean

  • value

    the property’s value, e.g. true

Returns:

  • new RubyAem::Resources::ConfigProperty instance



160
161
162
# File 'lib/ruby_aem.rb', line 160

def config_property(name, type, value)
  RubyAem::Resources::ConfigProperty.new(@client, name, type, value)
end

#flush_agent(run_mode, name) ⇒ Object

Create a flush agent instance.

Parameters:

  • run_mode

    AEM run mode: author or publish

  • name

    the flush agent’s name, e.g. some-flush-agent

Returns:

  • new RubyAem::Resources::FlushAgent instance



169
170
171
# File 'lib/ruby_aem.rb', line 169

def flush_agent(run_mode, name)
  RubyAem::Resources::FlushAgent.new(@client, run_mode, name)
end

#group(path, name) ⇒ Object

Create a group instance.

Parameters:

  • path

    the path to group node, e.g. /home/groups/s/

  • name

    the name of the AEM group, e.g. somegroup

Returns:

  • new RubyAem::Resources::Group instance



178
179
180
# File 'lib/ruby_aem.rb', line 178

def group(path, name)
  RubyAem::Resources::Group.new(@client, path, name)
end

#node(path, name) ⇒ Object

Create a node instance.

Parameters:

  • path

    the path to the node, e.g. /apps/system/

  • name

    the node name, e.g. somenode

Returns:

  • new RubyAem::Resources::Node instance



194
195
196
# File 'lib/ruby_aem.rb', line 194

def node(path, name)
  RubyAem::Resources::Node.new(@client, path, name)
end

#outbox_replication_agent(run_mode, name) ⇒ Object

Create an outbox replication agent instance.

Parameters:

  • run_mode

    AEM run mode: author or publish

  • name

    the outbox replication agent’s name, e.g. some-outbox-replication-agent

Returns:

  • new RubyAem::Resources::OutboxReplicationAgent instance



230
231
232
# File 'lib/ruby_aem.rb', line 230

def outbox_replication_agent(run_mode, name)
  RubyAem::Resources::OutboxReplicationAgent.new(@client, run_mode, name)
end

#package(group_name, package_name, package_version) ⇒ Object

Create a package instance.

Parameters:

  • group_name

    the group name of the package, e.g. somepackagegroup

  • package_name

    the name of the package, e.g. somepackage

  • package_version

    the version of the package, e.g. 1.2.3

Returns:

  • new RubyAem::Resources::Package instance



204
205
206
# File 'lib/ruby_aem.rb', line 204

def package(group_name, package_name, package_version)
  RubyAem::Resources::Package.new(@client, group_name, package_name, package_version)
end

#path(name) ⇒ Object

Create a path instance.

Parameters:

  • name

    the name of the path, e.g. /etc/designs

Returns:

  • new RubyAem::Resources::Path instance



212
213
214
# File 'lib/ruby_aem.rb', line 212

def path(name)
  RubyAem::Resources::Path.new(@client, name)
end

#replication_agent(run_mode, name) ⇒ Object

Create a replication agent instance.

Parameters:

  • run_mode

    AEM run mode: author or publish

  • name

    the replication agent’s name, e.g. some-replication-agent

Returns:

  • new RubyAem::Resources::ReplicationAgent instance



221
222
223
# File 'lib/ruby_aem.rb', line 221

def replication_agent(run_mode, name)
  RubyAem::Resources::ReplicationAgent.new(@client, run_mode, name)
end

#repositoryObject

Create a repository instance.

Returns:

  • new RubyAem::Resources::Repository instance



246
247
248
# File 'lib/ruby_aem.rb', line 246

def repository
  RubyAem::Resources::Repository.new(@client)
end

#reverse_replication_agent(run_mode, name) ⇒ Object

Create a reverse replication agent instance.

Parameters:

  • run_mode

    AEM run mode: author or publish

  • name

    the reverse replication agent’s name, e.g. some-reverse-replication-agent

Returns:

  • new RubyAem::Resources::ReverseReplicationAgent instance



239
240
241
# File 'lib/ruby_aem.rb', line 239

def reverse_replication_agent(run_mode, name)
  RubyAem::Resources::ReverseReplicationAgent.new(@client, run_mode, name)
end

#samlObject

Create a Saml instance.

Returns:

  • new RubyAem::Resources::Saml instance



253
254
255
# File 'lib/ruby_aem.rb', line 253

def saml
  RubyAem::Resources::Saml.new(@client)
end

#sanitise_conf(conf) ⇒ Object

Set default configuration values and handle numeric/boolean String values



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ruby_aem.rb', line 99

def sanitise_conf(conf)
  conf[:username] ||= 'admin'
  conf[:password] ||= 'admin'
  conf[:protocol] ||= 'http'
  conf[:host] ||= 'localhost'
  conf[:port] ||= 4502
  conf[:timeout] ||= 300
  # handle custom configuration value being passed as a String
  # e.g. when the values are passed via environment variables
  conf[:port] = conf[:port].to_i
  conf[:timeout] = conf[:timeout].to_i
  conf[:verify_ssl] = conf[:verify_ssl] == 'true' if conf[:verify_ssl].is_a? String
  conf[:debug] = conf[:debug] == 'true' if conf[:debug].is_a? String
end

#truststoreObject

Create a Truststore instance.

Returns:

  • new RubyAem::Resources::Truststore instance



260
261
262
# File 'lib/ruby_aem.rb', line 260

def truststore
  RubyAem::Resources::Truststore.new(@client)
end

#user(path, name) ⇒ Object

Create a user instance.

Parameters:

  • path

    the path to user node, e.g. /home/users/s/

  • name

    the username of the AEM user, e.g. someuser, admin, johncitizen

Returns:

  • new RubyAem::Resources::User instance



269
270
271
# File 'lib/ruby_aem.rb', line 269

def user(path, name)
  RubyAem::Resources::User.new(@client, path, name)
end