Parent

Methods

Class/Module Index [+]

Quicksearch

ChefZero::Endpoints::ActorsEndpoint

/clients or /users

Public Instance Methods

post(request) click to toggle source
# File lib/chef_zero/endpoints/actors_endpoint.rb, line 8
def post(request)
  # First, find out if the user actually posted a public key.  If not, make
  # one.
  request_body = JSON.parse(request.body, :create_additions => false)
  public_key = request_body['public_key']
  if !public_key
    private_key, public_key = server.gen_key_pair
    request_body['public_key'] = public_key
    request.body = JSON.pretty_generate(request_body)
  end

  result = super(request)
  if result[0] == 201
    # If we generated a key, stuff it in the response.
    response = JSON.parse(result[2], :create_additions => false)
    response['private_key'] = private_key if private_key
    response['public_key'] = public_key
    json_response(201, response)
  else
    result
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.