class ChefCLI::Policyfile::ChefServerLockFetcher

def fetch_lock_data

def fetch_lock_data
  if revision
    http_client.get("policies/#{policy_name}/revisions/#{revision}")
  elsif policy_group
    http_client.get("policy_groups/#{policy_group}/policies/#{policy_name}")
  else
    raise ChefCLI::BUG.new("The source_options should have been validated: #{source_options.inspect}")
  end
rescue Net::ProtocolError => e
  if e.respond_to?(:response) && e.response.code.to_s == "404"
    raise ChefCLI::PolicyfileLockDownloadError.new("No Policyfile lock named '#{policy_name}' found with revision '#{revision}' at #{http_client.url}") if revision
    raise ChefCLI::PolicyfileLockDownloadError.new("No Policyfile lock named '#{policy_name}' found with policy group '#{policy_group}' at #{http_client.url}") if policy_group
  else
    raise ChefCLI::PolicyfileLockDownloadError.new("HTTP error attempting to fetch policyfile lock from #{http_client.url}")
  end
rescue => e
  raise e
end