class RubyAem::Aem

Aem class represents an AEM client instance.

Public Class Methods

new(conf = {}) click to toggle source

Initialise a Ruby AEM instance.

@param conf configuration hash of the following configuration values:

  • 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

@return new RubyAem::Aem instance

# File lib/ruby_aem.rb, line 54
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,
    granite: SwaggerAemClient::GraniteApi.new
  }

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

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

Public Instance Methods

aem() click to toggle source

Create an AEM instance.

@return new RubyAem::Resources::Aem instance

# File lib/ruby_aem.rb, line 119
def aem
  RubyAem::Resources::Aem.new(@client)
end
aem_configmgr() click to toggle source

Create an AEM ConfigMgr instance.

@return new RubyAem::Resources::Aem instance

# File lib/ruby_aem.rb, line 126
def aem_configmgr
  RubyAem::Resources::AemConfigMgr.new(@client)
end
authorizable_keystore(intermediate_path, authorizable_id) click to toggle source

Create a Keystore instance for given authorizable id.

@return new RubyAem::Resources::AuhtorizableKeystore instance

# File lib/ruby_aem.rb, line 187
def authorizable_keystore(intermediate_path, authorizable_id)
  RubyAem::Resources::AuthorizableKeystore.new(@client, intermediate_path, authorizable_id)
end
bundle(name) click to toggle source

Create a bundle instance.

@param name the bundle's name, e.g. com.adobe.cq.social.cq-social-forum @return new RubyAem::Resources::Bundle instance

# File lib/ruby_aem.rb, line 134
def bundle(name)
  RubyAem::Resources::Bundle.new(@client, name)
end
certificate(serial_number) click to toggle source

Create a certificate instance.

@param serial_number the certificate's serial number @return new RubyAem::Resources::Certificate instance

# File lib/ruby_aem.rb, line 142
def certificate(serial_number)
  RubyAem::Resources::Certificate.new(@client, serial_number)
end
certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id) click to toggle source

# Create a certificate chain instance. # @param private_key_alias Alias of the private key associated to this certificate chain @param keystore_intermediate_path AEM User home path @param keystore_authorizable_id AEM User id # @return new RubyAem::Resources::CertificateChain instance

# File lib/ruby_aem.rb, line 152
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) click to toggle source

Create a config property instance.

@param name the property's name @param type the property's type, e.g. Boolean @param value the property's value, e.g. true @return new RubyAem::Resources::ConfigProperty instance

# File lib/ruby_aem.rb, line 162
def config_property(name, type, value)
  RubyAem::Resources::ConfigProperty.new(@client, name, type, value)
end
flush_agent(run_mode, name) click to toggle source

Create a flush agent instance.

@param run_mode AEM run mode: author or publish @param name the flush agent's name, e.g. some-flush-agent @return new RubyAem::Resources::FlushAgent instance

# File lib/ruby_aem.rb, line 171
def flush_agent(run_mode, name)
  RubyAem::Resources::FlushAgent.new(@client, run_mode, name)
end
group(path, name) click to toggle source

Create a group instance.

@param path the path to group node, e.g. /home/groups/s/ @param name the name of the AEM group, e.g. somegroup @return new RubyAem::Resources::Group instance

# File lib/ruby_aem.rb, line 180
def group(path, name)
  RubyAem::Resources::Group.new(@client, path, name)
end
node(path, name) click to toggle source

Create a node instance.

@param path the path to the node, e.g. /apps/system/ @param name the node name, e.g. somenode @return new RubyAem::Resources::Node instance

# File lib/ruby_aem.rb, line 196
def node(path, name)
  RubyAem::Resources::Node.new(@client, path, name)
end
outbox_replication_agent(run_mode, name) click to toggle source

Create an outbox replication agent instance.

@param run_mode AEM run mode: author or publish @param name the outbox replication agent's name, e.g. some-outbox-replication-agent @return new RubyAem::Resources::OutboxReplicationAgent instance

# File lib/ruby_aem.rb, line 232
def outbox_replication_agent(run_mode, name)
  RubyAem::Resources::OutboxReplicationAgent.new(@client, run_mode, name)
end
package(group_name, package_name, package_version) click to toggle source

Create a package instance.

@param group_name the group name of the package, e.g. somepackagegroup @param package_name the name of the package, e.g. somepackage @param package_version the version of the package, e.g. 1.2.3 @return new RubyAem::Resources::Package instance

# File lib/ruby_aem.rb, line 206
def package(group_name, package_name, package_version)
  RubyAem::Resources::Package.new(@client, group_name, package_name, package_version)
end
path(name) click to toggle source

Create a path instance.

@param name the name of the path, e.g. /etc/designs @return new RubyAem::Resources::Path instance

# File lib/ruby_aem.rb, line 214
def path(name)
  RubyAem::Resources::Path.new(@client, name)
end
replication_agent(run_mode, name) click to toggle source

Create a replication agent instance.

@param run_mode AEM run mode: author or publish @param name the replication agent's name, e.g. some-replication-agent @return new RubyAem::Resources::ReplicationAgent instance

# File lib/ruby_aem.rb, line 223
def replication_agent(run_mode, name)
  RubyAem::Resources::ReplicationAgent.new(@client, run_mode, name)
end
repository() click to toggle source

Create a repository instance.

@return new RubyAem::Resources::Repository instance

# File lib/ruby_aem.rb, line 248
def repository
  RubyAem::Resources::Repository.new(@client)
end
reverse_replication_agent(run_mode, name) click to toggle source

Create a reverse replication agent instance.

@param run_mode AEM run mode: author or publish @param name the reverse replication agent's name, e.g. some-reverse-replication-agent @return new RubyAem::Resources::ReverseReplicationAgent instance

# File lib/ruby_aem.rb, line 241
def reverse_replication_agent(run_mode, name)
  RubyAem::Resources::ReverseReplicationAgent.new(@client, run_mode, name)
end
saml() click to toggle source

Create a Saml instance.

@return new RubyAem::Resources::Saml instance

# File lib/ruby_aem.rb, line 255
def saml
  RubyAem::Resources::Saml.new(@client)
end
sanitise_conf(conf) click to toggle source

Set default configuration values and handle numeric/boolean String values

# File lib/ruby_aem.rb, line 101
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
ssl() click to toggle source

Create a SSL instance.

@return new RubyAem::Resources::Saml instance

# File lib/ruby_aem.rb, line 262
def ssl
  RubyAem::Resources::Ssl.new(@client)
end
truststore() click to toggle source

Create a Truststore instance.

@return new RubyAem::Resources::Truststore instance

# File lib/ruby_aem.rb, line 269
def truststore
  RubyAem::Resources::Truststore.new(@client)
end
user(path, name) click to toggle source

Create a user instance.

@param path the path to user node, e.g. /home/users/s/ @param name the username of the AEM user, e.g. someuser, admin, johncitizen @return new RubyAem::Resources::User instance

# File lib/ruby_aem.rb, line 278
def user(path, name)
  RubyAem::Resources::User.new(@client, path, name)
end