class Opsmgr::Api::Client

Attributes

environment_name[R]
http_client[R]

Public Class Methods

new(environment, om_version) click to toggle source
# File lib/opsmgr/api/client.rb, line 14
def initialize(environment, om_version)
  @http_client = HttpClient.build(environment, om_version)
  @environment_name = environment.settings.dig('name').freeze
end

Public Instance Methods

add_product(product_name, version) click to toggle source
# File lib/opsmgr/api/client.rb, line 34
def add_product(product_name, version)
  response = http_client.add_product(product_name, version)
  basic_success_or_error("Error adding '#{product_name} #{version}'", response)
end
basic_success_or_error(message, response) click to toggle source
# File lib/opsmgr/api/client.rb, line 85
def basic_success_or_error(message, response)
  if response.code == '200'
    Result.new
  else
    Error.new(message, response)
  end
end
delete_unused_products() click to toggle source
# File lib/opsmgr/api/client.rb, line 80
def delete_unused_products
  response = http_client.delete_unused_products
  basic_success_or_error('There was an error deleting the unused products:', response)
end
download_staged_manifest(product_guid) click to toggle source
# File lib/opsmgr/api/client.rb, line 53
def download_staged_manifest(product_guid)
  response = http_client.download_staged_manifest(product_guid)
  if response.code == '200'
    StagedManifestResult.new(response.body)
  else
    Error.new("Error downloading staged manifest for '#{product_guid}'", response)
  end
end
import_installation(path, password) click to toggle source
# File lib/opsmgr/api/client.rb, line 93
def import_installation(path, password)
  response = http_client.import_installation(path, password)
  basic_success_or_error("Error importing #{path}", response)
end
import_stemcell(path) click to toggle source
# File lib/opsmgr/api/client.rb, line 98
def import_stemcell(path)
  response = http_client.import_stemcell(path)
  basic_success_or_error("Error importing stemcell #{path}", response)
end
installation_settings() click to toggle source
# File lib/opsmgr/api/client.rb, line 19
def installation_settings
  response = http_client.installation_settings
  if response.code == '200'
    InstallationSettingsResult.new(JSON.parse(response.body))
  else
    Error.new('Error viewing current installation settings', response)
  end
end
installed_products() click to toggle source
# File lib/opsmgr/api/client.rb, line 71
def installed_products
  response = http_client.installed_products
  if response.code == '200'
    InstalledProductsResult.new(Opsmgr::Settings::Microbosh::ProductList.new(JSON.parse(response.body)))
  else
    Error.new('Error listing installed products', response)
  end
end
list_products() click to toggle source
# File lib/opsmgr/api/client.rb, line 62
def list_products
  response = http_client.list_products
  if response.code == '200'
    ListProductsResult.new(JSON.parse(response.body))
  else
    Error.new('Error listing products', response)
  end
end
root_ca_certificate() click to toggle source
# File lib/opsmgr/api/client.rb, line 39
def root_ca_certificate
  response = http_client.root_ca_certificate
  if response.code == '200'
    JSON.parse(response.body)['root_ca_certificate_pem']
  else
    Error.new('Error retrieving the root ca certificate', response)
  end
end
upgrade_product(product_guid, to_version) click to toggle source
# File lib/opsmgr/api/client.rb, line 48
def upgrade_product(product_guid, to_version)
  response = http_client.upgrade_product(product_guid, to_version)
  basic_success_or_error("Error upgrading '#{product_guid}' to '#{to_version}'", response)
end
upload_component(path) click to toggle source

.pivotal file is referred to as a “product” but the Tempest developers call it a “component”

# File lib/opsmgr/api/client.rb, line 29
def upload_component(path)
  response = http_client.upload_component(path)
  basic_success_or_error("Error uploading #{path}", response)
end