summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Brown <anbrown@blackberry.com>2015-08-12 08:52:25 -0400
committerAndrew Brown <anbrown@blackberry.com>2015-08-12 08:52:25 -0400
commit3197fc49cacb71c9c55de40935a5e08303afb7a3 (patch)
treea291011c455b191e98d32ef3db1246d2e99cf926 /lib
parentae7634c600535ba3f64ce8af31afc6fef9dab31c (diff)
downloadchef-zero-3197fc49cacb71c9c55de40935a5e08303afb7a3.tar.gz
Preliminary support for _identifiers API
Adding preliminary support for the _identifiers REST endpoint.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef_zero/endpoints/node_identifiers_endpoint.rb22
-rw-r--r--lib/chef_zero/server.rb2
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/node_identifiers_endpoint.rb b/lib/chef_zero/endpoints/node_identifiers_endpoint.rb
new file mode 100644
index 0000000..9f89a98
--- /dev/null
+++ b/lib/chef_zero/endpoints/node_identifiers_endpoint.rb
@@ -0,0 +1,22 @@
+require 'ffi_yajl'
+require 'chef_zero/rest_base'
+require 'uuidtools'
+
+module ChefZero
+ module Endpoints
+ # /organizations/NAME/nodes/NAME/_identifiers
+ class NodeIdentifiersEndpoint < RestBase
+ def get(request)
+ if get_data(request, request.rest_path[0..3])
+ result = {
+ :id => UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.gsub('-',''),
+ :authz_id => '0'*32,
+ :org_id => UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.gsub('-','') }
+ json_response(200, result)
+ else
+ raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
+ end
+ end
+ end
+ end
+end
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb
index 9cf7b39..672f795 100644
--- a/lib/chef_zero/server.rb
+++ b/lib/chef_zero/server.rb
@@ -61,6 +61,7 @@ require 'chef_zero/endpoints/environment_recipes_endpoint'
require 'chef_zero/endpoints/environment_role_endpoint'
require 'chef_zero/endpoints/license_endpoint'
require 'chef_zero/endpoints/node_endpoint'
+require 'chef_zero/endpoints/node_identifiers_endpoint'
require 'chef_zero/endpoints/organizations_endpoint'
require 'chef_zero/endpoints/organization_endpoint'
require 'chef_zero/endpoints/organization_association_requests_endpoint'
@@ -540,6 +541,7 @@ module ChefZero
[ "/organizations/*/environments/*/roles/*", EnvironmentRoleEndpoint.new(self) ],
[ "/organizations/*/nodes", RestListEndpoint.new(self) ],
[ "/organizations/*/nodes/*", NodeEndpoint.new(self) ],
+ [ "/organizations/*/nodes/*/_identifiers", NodeIdentifiersEndpoint.new(self) ],
[ "/organizations/*/policies/*/*", PoliciesEndpoint.new(self) ],
[ "/organizations/*/principals/*", PrincipalEndpoint.new(self) ],
[ "/organizations/*/roles", RestListEndpoint.new(self) ],