<commit_before>include Infoblox::Api

action :create do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  request_params[:comment] = new_resource.comment unless new_resource.comment.nil?
  request_params[:disable] = new_resource.disable unless new_resource.disable.nil? 

  resp = create_cname_record(request_params)
end

action :delete do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  delete_cname_record(request_params)
end

action :get_cname_record_info do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  record = find_cname_record(request_params)
  unless record.empty?
    record.first
    Chef::Log.info "Successfully retrived CNAME record."
  else
    Chef::Log.info "CNAME record not found."
  end
end

# create cname-record
def create_cname_record(params)
  record = Infoblox::Cname.new(connection: connection, name: params[:name], canonical: params[:canonical])
  record.comment = params[:comment] if params[:comment]
  record.disable = params[:disable] if params[:disable]

  begin
    record.post
    Chef::Log.info "cname-record successfully created."
  rescue Exception => e
    unless e.message.match(/Client.Ibap.Data.Conflict/).nil?
      Chef::Log.info "cname-record already exists, Please select another cname-record."
    else
      raise e.message
    end
  end
end

# delete cname-record
def delete_cname_record(params)
  cname_record_obj = find_cname_record(params)
  unless cname_record_obj.empty?
    begin
      cname_record_obj.first.delete
      Chef::Log.info "Cname Record successfully deleted"
    rescue Exception => e
      Chef::Log.error e.message
    end
  else
    Chef::Log.info "Cname Record Not Found. Please verify name and canonical name."
  end
end

def find_cname_record(params)
  return Infoblox::Cname.find(connection, name: params[:name], canonical: params[:canonical])
end<commit_msg>Added extattrs support<commit_after>include Infoblox::Api

action :create do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  request_params[:comment] = new_resource.comment unless new_resource.comment.nil?
  request_params[:disable] = new_resource.disable unless new_resource.disable.nil? 
  request_params[:extattrs] = new_resource.extattrs unless new_resource.extattrs.nil?
  resp = create_cname_record(request_params)
end

action :delete do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  delete_cname_record(request_params)
end

action :get_cname_record_info do
  request_params = {}
  request_params[:name] = new_resource.name
  request_params[:canonical] = new_resource.canonical
  record = find_cname_record(request_params)
  unless record.empty?
    resp = record.first
    Chef::Log.info "Successfully retrived CNAME record."
    return resp
  else
    Chef::Log.info "CNAME record not found."
    return false
  end
end

# create cname-record
def create_cname_record(params)
  record = Infoblox::Cname.new(connection: connection, name: params[:name], canonical: params[:canonical])
  record.comment = params[:comment] if params[:comment]
  record.disable = params[:disable] if params[:disable]
  record.extattrs = params[:extattrs] if params[:extattrs]
  begin
    resp = record.post
    Chef::Log.info "cname-record successfully created."
    return resp
  rescue Exception => e
    Chef::Log.error e.message.split("text\":")[1].chomp('}')
    return false
  end
end

# delete cname-record
def delete_cname_record(params)
  cname_record_obj = find_cname_record(params)
  unless cname_record_obj.empty?
    begin
      resp = cname_record_obj.first.delete
      Chef::Log.info "Cname Record successfully deleted"
      return resp
    rescue Exception => e
      Chef::Log.error e.message.split("text\":")[1].chomp('}')
      return false
    end
  else
    Chef::Log.info "Cname Record Not Found. Please verify name and canonical name."
    return false
  end
end

def find_cname_record(params)
  Infoblox::Cname.find(connection, name: params[:name], canonical: params[:canonical])
end
{'fraction_non_alphanumeric': 0.10097719869706841, 'fraction_numerical': 0.00046533271288971617, 'mean_word_length': 4.694039735099338, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2941473', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1323, 'n_words': 303}