=begin #Fastly API #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/) The version of the OpenAPI document: 1.0.0 Contact: oss@fastly.com =end require 'cgi' module Fastly class VersionApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Activate a service version # Activate the current version. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [VersionResponse] def activate_service_version(opts = {}) data, _status_code, _headers = activate_service_version_with_http_info(opts) data end # Activate a service version # Activate the current 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<(VersionResponse, Integer, Hash)>] VersionResponse data, response status code and response headers def activate_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.activate_service_version ...' 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 VersionApi.activate_service_version" 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 VersionApi.activate_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}/activate'.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] || 'VersionResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.activate_service_version", :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: VersionApi#activate_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Clone a service version # Clone the current configuration into a new version. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [Version] def clone_service_version(opts = {}) data, _status_code, _headers = clone_service_version_with_http_info(opts) data end # Clone a service version # Clone the current configuration into a new 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<(Version, Integer, Hash)>] Version data, response status code and response headers def clone_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.clone_service_version ...' 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 VersionApi.clone_service_version" 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 VersionApi.clone_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}/clone'.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] || 'Version' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.clone_service_version", :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: VersionApi#clone_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create a service version # Create a version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @return [VersionCreateResponse] def create_service_version(opts = {}) data, _status_code, _headers = create_service_version_with_http_info(opts) data end # Create a service version # Create a version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @return [Array<(VersionCreateResponse, Integer, Hash)>] VersionCreateResponse data, response status code and response headers def create_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.create_service_version ...' end # unbox the parameters from the hash service_id = opts[:'service_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 VersionApi.create_service_version" end # resource path local_var_path = '/service/{service_id}/version'.sub('{' + 'service_id' + '}', CGI.escape(service_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] || 'VersionCreateResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.create_service_version", :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: VersionApi#create_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Deactivate a service version # Deactivate the current version. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [VersionResponse] def deactivate_service_version(opts = {}) data, _status_code, _headers = deactivate_service_version_with_http_info(opts) data end # Deactivate a service version # Deactivate the current 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<(VersionResponse, Integer, Hash)>] VersionResponse data, response status code and response headers def deactivate_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.deactivate_service_version ...' 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 VersionApi.deactivate_service_version" 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 VersionApi.deactivate_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}/deactivate'.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] || 'VersionResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.deactivate_service_version", :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: VersionApi#deactivate_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a version of a service # Get the version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [VersionResponse] def get_service_version(opts = {}) data, _status_code, _headers = get_service_version_with_http_info(opts) data end # Get a version of a service # Get the version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [Array<(VersionResponse, Integer, Hash)>] VersionResponse data, response status code and response headers def get_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.get_service_version ...' 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 VersionApi.get_service_version" 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 VersionApi.get_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}'.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] || 'VersionResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.get_service_version", :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: VersionApi#get_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List versions of a service # List the versions for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @return [Array] def list_service_versions(opts = {}) data, _status_code, _headers = list_service_versions_with_http_info(opts) data end # List versions of a service # List the versions for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers def list_service_versions_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.list_service_versions ...' end # unbox the parameters from the hash service_id = opts[:'service_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 VersionApi.list_service_versions" end # resource path local_var_path = '/service/{service_id}/version'.sub('{' + 'service_id' + '}', CGI.escape(service_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' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.list_service_versions", :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: VersionApi#list_service_versions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Lock a service version # Locks the specified version. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @return [Version] def lock_service_version(opts = {}) data, _status_code, _headers = lock_service_version_with_http_info(opts) data end # Lock a service version # Locks the specified 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<(Version, Integer, Hash)>] Version data, response status code and response headers def lock_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.lock_service_version ...' 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 VersionApi.lock_service_version" 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 VersionApi.lock_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}/lock'.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] || 'Version' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.lock_service_version", :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: VersionApi#lock_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update a service version # Update a particular version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @option opts [Boolean] :active Whether this is the active version or not. (default to false) # @option opts [String] :comment A freeform descriptive note. # @option opts [Boolean] :deployed Unused at this time. # @option opts [Boolean] :locked Whether this version is locked or not. Objects can not be added or edited on locked versions. (default to false) # @option opts [Integer] :number The number of this version. # @option opts [Boolean] :staging Unused at this time. (default to false) # @option opts [Boolean] :testing Unused at this time. (default to false) # @return [VersionResponse] def update_service_version(opts = {}) data, _status_code, _headers = update_service_version_with_http_info(opts) data end # Update a service version # Update a particular version for a particular service. # @option opts [String] :service_id Alphanumeric string identifying the service. (required) # @option opts [Integer] :version_id Integer identifying a service version. (required) # @option opts [Boolean] :active Whether this is the active version or not. (default to false) # @option opts [String] :comment A freeform descriptive note. # @option opts [Boolean] :deployed Unused at this time. # @option opts [Boolean] :locked Whether this version is locked or not. Objects can not be added or edited on locked versions. (default to false) # @option opts [Integer] :number The number of this version. # @option opts [Boolean] :staging Unused at this time. (default to false) # @option opts [Boolean] :testing Unused at this time. (default to false) # @return [Array<(VersionResponse, Integer, Hash)>] VersionResponse data, response status code and response headers def update_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.update_service_version ...' 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 VersionApi.update_service_version" 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 VersionApi.update_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}'.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['active'] = opts[:'active'] if !opts[:'active'].nil? form_params['comment'] = opts[:'comment'] if !opts[:'comment'].nil? form_params['deployed'] = opts[:'deployed'] if !opts[:'deployed'].nil? form_params['locked'] = opts[:'locked'] if !opts[:'locked'].nil? form_params['number'] = opts[:'number'] if !opts[:'number'].nil? form_params['staging'] = opts[:'staging'] if !opts[:'staging'].nil? form_params['testing'] = opts[:'testing'] if !opts[:'testing'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'VersionResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.update_service_version", :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: VersionApi#update_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Validate a service version # Validate the version 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 [InlineResponse200] def validate_service_version(opts = {}) data, _status_code, _headers = validate_service_version_with_http_info(opts) data end # Validate a service version # Validate the version 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<(InlineResponse200, Integer, Hash)>] InlineResponse200 data, response status code and response headers def validate_service_version_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VersionApi.validate_service_version ...' 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 VersionApi.validate_service_version" 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 VersionApi.validate_service_version" end # resource path local_var_path = '/service/{service_id}/version/{version_id}/validate'.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] || 'InlineResponse200' # auth_names auth_names = opts[:debug_auth_names] || ['token'] new_options = opts.merge( :operation => :"VersionApi.validate_service_version", :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: VersionApi#validate_service_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end