Class: Conjur::Variable
- Inherits:
 - 
      BaseObject
      
        
- Object
 - BaseObject
 - Conjur::Variable
 
 
- Includes:
 - ActsAsResource
 
- Defined in:
 - lib/conjur/variable.rb
 
Overview
Instance Attribute Summary
Attributes inherited from BaseObject
Instance Method Summary collapse
- 
  
    
      #add_value(value)  
    
    
  
  
  
  
  
  
  
  
  
    
Add a new value to the variable.
 - #as_json(options = {}) ⇒ Object
 - 
  
    
      #kind  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
The kind of secret represented by this variable, for example,
'postgres-url'or'aws-secret-access-key'. - 
  
    
      #mime_type  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
The MIME Type of the variable's value.
 - 
  
    
      #value(version = nil, options = {})  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Return the version of a variable.
 - 
  
    
      #version_count  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
Return the number of versions of the variable.
 
Methods included from ActsAsResource
#exists?, #owner, #permitted?, #permitted_roles
Methods inherited from BaseObject
#account, #identifier, #initialize, #inspect, #username
Methods included from Routing
Methods included from BuildObject
Methods included from LogSource
Constructor Details
This class inherits a constructor from Conjur::BaseObject
Instance Method Details
#add_value(value)
This method returns an undefined value.
Add a new value to the variable.
You must have the 'update' permission on a variable to call this method.
      128 129 130 131 132 133 134 135 136  | 
    
      # File 'lib/conjur/variable.rb', line 128 def add_value value log do |logger| logger << "Adding a value to variable #{id}" end invalidate do route = url_for(:secrets_add, credentials, id) route.post value end end  | 
  
#as_json(options = {}) ⇒ Object
      80 81 82 83 84 85  | 
    
      # File 'lib/conjur/variable.rb', line 80 def as_json ={} result = super() result["mime_type"] = mime_type result["kind"] = kind result end  | 
  
#kind ⇒ String
this is not the same as the kind part of a qualified Conjur id.
The kind of secret represented by this variable,  for example, 'postgres-url' or
'aws-secret-access-key'.
You must have the 'read' permission on a variable to call this method.
This attribute is only for human consumption, and does not take part in the Conjur permissions model.
      97 98 99  | 
    
      # File 'lib/conjur/variable.rb', line 97 def kind parser_for(:variable_kind, variable_attributes) || "secret" end  | 
  
#mime_type ⇒ String
The MIME Type of the variable's value.
You must have the 'read' permission on a variable to call this method.
This attribute is used by the Conjur services to set a response Content-Type header when
returning the value of a variable.  Conjur applies the same MIME Type to all versions of a variable,
so if you plan on accessing the variable in a way that depends on a correct Content-Type header
you should make sure to store appropriate data for the mime type in all versions.
      111 112 113  | 
    
      # File 'lib/conjur/variable.rb', line 111 def mime_type parser_for(:variable_mime_type, variable_attributes) || "text/plain" end  | 
  
#value(version = nil, options = {}) ⇒ String
Return the version of a variable.
You must have the 'execute' permission on a variable to call this method.
When no argument is given, the most recent version is returned.
When a version argument is given, the method returns a version according to the following rules:
- If 
versionis 0, the most recent version is returned. - If 
versionis less than 0 or greater than #version_count, aRestClient::ResourceNotFoundexception will be raised. - If #version_count is 0, a 
RestClient::ResourceNotFoundexception will be raised. - If 
versionis >= 1 andversion<= #version_count, the version at the 1 based index given byversionwill be returned. 
      189 190 191 192  | 
    
      # File 'lib/conjur/variable.rb', line 189 def value version = nil, = {} ['version'] = version if version url_for(:secrets_value, credentials, id, ).get.body end  | 
  
#version_count ⇒ Integer
Return the number of versions of the variable.
You must have the 'read' permission on a variable to call this method.
      148 149 150 151 152 153 154 155  | 
    
      # File 'lib/conjur/variable.rb', line 148 def version_count secrets = attributes['secrets'] if secrets.empty? 0 else secrets.last['version'] end end  |