class Fastly::DirectorApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/fastly/api/director_api.rb, line 17
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

create_director(opts = {}) click to toggle source

Create a director Create a director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [Array<Backend>] :backends List of backends associated to a director. @option opts [Integer] :capacity Unused. @option opts [String] :comment A freeform descriptive note. @option opts [String] :name Name for the Director. @option opts [Integer] :quorum The percentage of capacity that needs to be up for a director to be considered up. &#x60;0&#x60; to &#x60;100&#x60;. (default to 75) @option opts [String] :shield Selected POP to serve as a shield for the backends. Defaults to &#x60;null&#x60; meaning no origin shielding if not set. Refer to the [POPs API endpoint](www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding. (default to ‘null’) @option opts [Integer] :type What type of load balance group to use. (default to 1) @option opts [Integer] :retries How many backends to search if it fails. (default to 5) @return [DirectorResponse]

# File lib/fastly/api/director_api.rb, line 33
def create_director(opts = {})
  data, _status_code, _headers = create_director_with_http_info(opts)
  data
end
create_director_with_http_info(opts = {}) click to toggle source

Create a director Create a director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [Array<Backend>] :backends List of backends associated to a director. @option opts [Integer] :capacity Unused. @option opts [String] :comment A freeform descriptive note. @option opts [String] :name Name for the Director. @option opts [Integer] :quorum The percentage of capacity that needs to be up for a director to be considered up. &#x60;0&#x60; to &#x60;100&#x60;. (default to 75) @option opts [String] :shield Selected POP to serve as a shield for the backends. Defaults to &#x60;null&#x60; meaning no origin shielding if not set. Refer to the [POPs API endpoint](www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding. (default to ‘null’) @option opts [Integer] :type What type of load balance group to use. (default to 1) @option opts [Integer] :retries How many backends to search if it fails. (default to 5) @return [Array<(DirectorResponse, Integer, Hash)>] DirectorResponse data, response status code and response headers

# File lib/fastly/api/director_api.rb, line 51
def create_director_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DirectorApi.create_director ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling DirectorApi.create_director"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling DirectorApi.create_director"
  end
  if @api_client.config.client_side_validation && !opts[:'quorum'].nil? && opts[:'quorum'] > 100
    fail ArgumentError, 'invalid value for "opts[:"quorum"]" when calling DirectorApi.create_director, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'quorum'].nil? && opts[:'quorum'] < 0
    fail ArgumentError, 'invalid value for "opts[:"quorum"]" when calling DirectorApi.create_director, must be greater than or equal to 0.'
  end

  allowable_values = [1, 3, 4]
  if @api_client.config.client_side_validation && opts[:'type'] && !allowable_values.include?(opts[:'type'])
    fail ArgumentError, "invalid value for \"type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/director'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['backends'] = @api_client.build_collection_param(opts[:'backends'], :csv) if !opts[:'backends'].nil?
  form_params['capacity'] = opts[:'capacity'] if !opts[:'capacity'].nil?
  form_params['comment'] = opts[:'comment'] if !opts[:'comment'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['quorum'] = opts[:'quorum'] if !opts[:'quorum'].nil?
  form_params['shield'] = opts[:'shield'] if !opts[:'shield'].nil?
  form_params['type'] = opts[:'type'] if !opts[:'type'].nil?
  form_params['retries'] = opts[:'retries'] if !opts[:'retries'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DirectorResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"DirectorApi.create_director",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DirectorApi#create_director\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
delete_director(opts = {}) click to toggle source

Delete a director Delete the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [InlineResponse200]

# File lib/fastly/api/director_api.rb, line 137
def delete_director(opts = {})
  data, _status_code, _headers = delete_director_with_http_info(opts)
  data
end
delete_director_with_http_info(opts = {}) click to toggle source

Delete a director Delete the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [Array<(InlineResponse200, Integer, Hash)>] InlineResponse200 data, response status code and response headers

# File lib/fastly/api/director_api.rb, line 148
def delete_director_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DirectorApi.delete_director ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  director_name = opts[:'director_name']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling DirectorApi.delete_director"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling DirectorApi.delete_director"
  end
  # verify the required parameter 'director_name' is set
  if @api_client.config.client_side_validation && director_name.nil?
    fail ArgumentError, "Missing the required parameter 'director_name' when calling DirectorApi.delete_director"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/director/{director_name}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s)).sub('{' + 'director_name' + '}', CGI.escape(director_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'InlineResponse200'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"DirectorApi.delete_director",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DirectorApi#delete_director\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_director(opts = {}) click to toggle source

Get a director Get the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [DirectorResponse]

# File lib/fastly/api/director_api.rb, line 214
def get_director(opts = {})
  data, _status_code, _headers = get_director_with_http_info(opts)
  data
end
get_director_with_http_info(opts = {}) click to toggle source

Get a director Get the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [Array<(DirectorResponse, Integer, Hash)>] DirectorResponse data, response status code and response headers

# File lib/fastly/api/director_api.rb, line 225
def get_director_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DirectorApi.get_director ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  director_name = opts[:'director_name']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling DirectorApi.get_director"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling DirectorApi.get_director"
  end
  # verify the required parameter 'director_name' is set
  if @api_client.config.client_side_validation && director_name.nil?
    fail ArgumentError, "Missing the required parameter 'director_name' when calling DirectorApi.get_director"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/director/{director_name}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s)).sub('{' + 'director_name' + '}', CGI.escape(director_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DirectorResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"DirectorApi.get_director",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DirectorApi#get_director\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
list_directors(opts = {}) click to toggle source

List directors List the directors for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @return [Array<DirectorResponse>]

# File lib/fastly/api/director_api.rb, line 290
def list_directors(opts = {})
  data, _status_code, _headers = list_directors_with_http_info(opts)
  data
end
list_directors_with_http_info(opts = {}) click to toggle source

List directors List the directors for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @return [Array<(Array<DirectorResponse>, Integer, Hash)>] Array<DirectorResponse> data, response status code and response headers

# File lib/fastly/api/director_api.rb, line 300
def list_directors_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DirectorApi.list_directors ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling DirectorApi.list_directors"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling DirectorApi.list_directors"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/director'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<DirectorResponse>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"DirectorApi.list_directors",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DirectorApi#list_directors\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
update_director(opts = {}) click to toggle source

Update a director Update the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [DirectorResponse]

# File lib/fastly/api/director_api.rb, line 361
def update_director(opts = {})
  data, _status_code, _headers = update_director_with_http_info(opts)
  data
end
update_director_with_http_info(opts = {}) click to toggle source

Update a director Update the director for a particular service and version. @option opts [String] :service_id Alphanumeric string identifying the service. (required) @option opts [Integer] :version_id Integer identifying a service version. (required) @option opts [String] :director_name Name for the Director. (required) @return [Array<(DirectorResponse, Integer, Hash)>] DirectorResponse data, response status code and response headers

# File lib/fastly/api/director_api.rb, line 372
def update_director_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DirectorApi.update_director ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  version_id = opts[:'version_id']
  director_name = opts[:'director_name']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling DirectorApi.update_director"
  end
  # verify the required parameter 'version_id' is set
  if @api_client.config.client_side_validation && version_id.nil?
    fail ArgumentError, "Missing the required parameter 'version_id' when calling DirectorApi.update_director"
  end
  # verify the required parameter 'director_name' is set
  if @api_client.config.client_side_validation && director_name.nil?
    fail ArgumentError, "Missing the required parameter 'director_name' when calling DirectorApi.update_director"
  end
  # resource path
  local_var_path = '/service/{service_id}/version/{version_id}/director/{director_name}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'version_id' + '}', CGI.escape(version_id.to_s)).sub('{' + 'director_name' + '}', CGI.escape(director_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DirectorResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"DirectorApi.update_director",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DirectorApi#update_director\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end