class GdsApi::Router

def add_backend(id, url)

def add_backend(id, url)
  put_json("#{endpoint}/backends/#{CGI.escape(id)}", backend: { backend_url: url })
end

def add_gone_route(path, type)

def add_gone_route(path, type)
  put_json(
    "#{endpoint}/routes",
    route: { incoming_path: path, route_type: type, handler: "gone" },
  )
end

def add_redirect_route(path, type, destination, options = {})

def add_redirect_route(path, type, destination, options = {})
  put_json(
    "#{endpoint}/routes",
    route: {
      incoming_path: path,
      route_type: type,
      handler: "redirect",
      redirect_to: destination,
      segments_mode: options[:segments_mode],
    },
  )
end

def add_route(path, type, backend_id)

def add_route(path, type, backend_id)
  put_json(
    "#{endpoint}/routes",
    route: {
      incoming_path: path,
      route_type: type,
      handler: "backend",
      backend_id:,
    },
  )
end

def delete_backend(id)

def delete_backend(id)
  delete_json("#{endpoint}/backends/#{CGI.escape(id)}")
end

def delete_route(path, hard_delete: false)

def delete_route(path, hard_delete: false)
  url = "#{endpoint}/routes?incoming_path=#{CGI.escape(path)}"
  url += "&hard_delete=true" if hard_delete
  delete_json(url)
end

def get_backend(id)

def get_backend(id)
  get_json("#{endpoint}/backends/#{CGI.escape(id)}")
end

def get_route(path)

def get_route(path)
  get_json("#{endpoint}/routes?incoming_path=#{CGI.escape(path)}")
end