Sha256: eb9143a4d842e536c8031293d7df752cf2576794ff88dfeedf16f30e64ef780a

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

module Ridley
  # @author Jamie Winsor <reset@riotgames.com>
  class ClientObject < Ridley::ChefObject
    set_chef_id "name"
    set_chef_type "client"
    set_chef_json_class "Chef::ApiClient"

    attribute :name,
      type: String,
      required: true

    attribute :admin,
      type: Boolean,
      required: true,
      default: false

    attribute :validator,
      type: Boolean,
      required: true,
      default: false

    attribute :certificate,
      type: String

    attribute :public_key,
      type: String

    attribute :private_key,
      type: [ String, Boolean ]

    attribute :orgname,
      type: String

    # Regenerates the private key of the instantiated client object. The new
    # private key will be set to the value of the 'private_key' accessor
    # of the instantiated client object.
    #
    # @return [Boolean]
    #   true for success and false for failure
    def regenerate_key
      self.private_key = true
      self.save
    end

    # Override to_json to reflect to massage the returned attributes based on the type
    # of connection. Only OHC/OPC requires the json_class attribute is not present.
    def to_json
      if resource.connection.hosted?
        to_hash.except(:json_class).to_json
      else
        super
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ridley-1.0.0.rc2 lib/ridley/chef_objects/client_object.rb
ridley-1.0.0.rc1 lib/ridley/chef_objects/client_object.rb
ridley-0.12.4 lib/ridley/chef_objects/client_object.rb
ridley-0.12.3 lib/ridley/chef_objects/client_object.rb
ridley-0.12.2 lib/ridley/chef_objects/client_object.rb
ridley-0.12.1 lib/ridley/chef_objects/client_object.rb
ridley-0.12.0 lib/ridley/chef_objects/client_object.rb
ridley-0.11.2 lib/ridley/chef_objects/client_object.rb
ridley-0.12.0.rc1 lib/ridley/chef_objects/client_object.rb
ridley-0.11.1 lib/ridley/chef_objects/client_object.rb
ridley-0.11.0.rc1 lib/ridley/chef_objects/client_object.rb