Method: Fastly::DirectorApi#create_director_with_http_info

Defined in:
lib/fastly/api/director_api.rb

#create_director_with_http_info(opts = {}) ⇒ Array<(DirectorResponse, Integer, Hash)>

Create a director Create a director for a particular service and version.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :version_id (Integer)

    Integer identifying a service version. (required)

  • :backends (Array<Backend>)

    List of backends associated to a director.

  • :capacity (Integer)

    Unused.

  • :comment (String)

    A freeform descriptive note.

  • :name (String)

    Name for the Director.

  • :quorum (Integer)

    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)

  • :shield (String)

    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’)

  • :type (Integer)

    What type of load balance group to use. (default to 1)

  • :retries (Integer)

    How many backends to search if it fails. (default to 5)

Returns:

  • (Array<(DirectorResponse, Integer, Hash)>)

    DirectorResponse data, response status code and response headers



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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