=begin
#NSX-T Data Center Policy API

#VMware NSX-T Data Center Policy REST API

OpenAPI spec version: 3.1.0.0.0

Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.17

=end

require 'uri'

module NSXTPolicy
  class PolicySecurityServiceInsertionServiceDefinitionsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create a Service Definition on given enforcement point.
    # Create a Service Definition on given enforcement point.
    # @param enforcement_point_id Enforcement point id
    # @param service_definition 
    # @param [Hash] opts the optional parameters
    # @return [ServiceDefinition]
    def create_service_definition(enforcement_point_id, service_definition, opts = {})
      data, _status_code, _headers = create_service_definition_with_http_info(enforcement_point_id, service_definition, opts)
      data
    end

    # Create a Service Definition on given enforcement point.
    # Create a Service Definition on given enforcement point.
    # @param enforcement_point_id Enforcement point id
    # @param service_definition 
    # @param [Hash] opts the optional parameters
    # @return [Array<(ServiceDefinition, Fixnum, Hash)>] ServiceDefinition data, response status code and response headers
    def create_service_definition_with_http_info(enforcement_point_id, service_definition, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: PolicySecurityServiceInsertionServiceDefinitionsApi.create_service_definition ...'
      end
      # verify the required parameter 'enforcement_point_id' is set
      if @api_client.config.client_side_validation && enforcement_point_id.nil?
        fail ArgumentError, "Missing the required parameter 'enforcement_point_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.create_service_definition"
      end
      # verify the required parameter 'service_definition' is set
      if @api_client.config.client_side_validation && service_definition.nil?
        fail ArgumentError, "Missing the required parameter 'service_definition' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.create_service_definition"
      end
      # resource path
      local_var_path = '/enforcement-points/{enforcement-point-id}/service-definitions'.sub('{' + 'enforcement-point-id' + '}', enforcement_point_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(service_definition)
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:POST, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'ServiceDefinition')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: PolicySecurityServiceInsertionServiceDefinitionsApi#create_service_definition\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Delete an existing Service Definition on the given enforcement point 
    # Delete an existing Service Definition on the given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def delete_service_definition(enforcement_point_id, service_definition_id, opts = {})
      delete_service_definition_with_http_info(enforcement_point_id, service_definition_id, opts)
      nil
    end

    # Delete an existing Service Definition on the given enforcement point 
    # Delete an existing Service Definition on the given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def delete_service_definition_with_http_info(enforcement_point_id, service_definition_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: PolicySecurityServiceInsertionServiceDefinitionsApi.delete_service_definition ...'
      end
      # verify the required parameter 'enforcement_point_id' is set
      if @api_client.config.client_side_validation && enforcement_point_id.nil?
        fail ArgumentError, "Missing the required parameter 'enforcement_point_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.delete_service_definition"
      end
      # verify the required parameter 'service_definition_id' is set
      if @api_client.config.client_side_validation && service_definition_id.nil?
        fail ArgumentError, "Missing the required parameter 'service_definition_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.delete_service_definition"
      end
      # resource path
      local_var_path = '/enforcement-points/{enforcement-point-id}/service-definitions/{service-definition-id}'.sub('{' + 'enforcement-point-id' + '}', enforcement_point_id.to_s).sub('{' + 'service-definition-id' + '}', service_definition_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: PolicySecurityServiceInsertionServiceDefinitionsApi#delete_service_definition\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # List all Service Definitions registered on given enforcement point.
    # List all Service Definitions registered on given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param [Hash] opts the optional parameters
    # @return [ServiceInsertionServiceListResult]
    def list_service_definitions(enforcement_point_id, opts = {})
      data, _status_code, _headers = list_service_definitions_with_http_info(enforcement_point_id, opts)
      data
    end

    # List all Service Definitions registered on given enforcement point.
    # List all Service Definitions registered on given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param [Hash] opts the optional parameters
    # @return [Array<(ServiceInsertionServiceListResult, Fixnum, Hash)>] ServiceInsertionServiceListResult data, response status code and response headers
    def list_service_definitions_with_http_info(enforcement_point_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: PolicySecurityServiceInsertionServiceDefinitionsApi.list_service_definitions ...'
      end
      # verify the required parameter 'enforcement_point_id' is set
      if @api_client.config.client_side_validation && enforcement_point_id.nil?
        fail ArgumentError, "Missing the required parameter 'enforcement_point_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.list_service_definitions"
      end
      # resource path
      local_var_path = '/enforcement-points/{enforcement-point-id}/service-definitions'.sub('{' + 'enforcement-point-id' + '}', enforcement_point_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'ServiceInsertionServiceListResult')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: PolicySecurityServiceInsertionServiceDefinitionsApi#list_service_definitions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Read Service Definition with given service-definition-id.
    # Read Service Definition with given service-definition-id. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param [Hash] opts the optional parameters
    # @return [ServiceDefinition]
    def read_service_definition(enforcement_point_id, service_definition_id, opts = {})
      data, _status_code, _headers = read_service_definition_with_http_info(enforcement_point_id, service_definition_id, opts)
      data
    end

    # Read Service Definition with given service-definition-id.
    # Read Service Definition with given service-definition-id. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param [Hash] opts the optional parameters
    # @return [Array<(ServiceDefinition, Fixnum, Hash)>] ServiceDefinition data, response status code and response headers
    def read_service_definition_with_http_info(enforcement_point_id, service_definition_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: PolicySecurityServiceInsertionServiceDefinitionsApi.read_service_definition ...'
      end
      # verify the required parameter 'enforcement_point_id' is set
      if @api_client.config.client_side_validation && enforcement_point_id.nil?
        fail ArgumentError, "Missing the required parameter 'enforcement_point_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.read_service_definition"
      end
      # verify the required parameter 'service_definition_id' is set
      if @api_client.config.client_side_validation && service_definition_id.nil?
        fail ArgumentError, "Missing the required parameter 'service_definition_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.read_service_definition"
      end
      # resource path
      local_var_path = '/enforcement-points/{enforcement-point-id}/service-definitions/{service-definition-id}'.sub('{' + 'enforcement-point-id' + '}', enforcement_point_id.to_s).sub('{' + 'service-definition-id' + '}', service_definition_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'ServiceDefinition')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: PolicySecurityServiceInsertionServiceDefinitionsApi#read_service_definition\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Update an existing Service Definition on the given enforcement point 
    # Update an existing Service Definition on the given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param service_definition 
    # @param [Hash] opts the optional parameters
    # @return [ServiceDefinition]
    def update_service_definition(enforcement_point_id, service_definition_id, service_definition, opts = {})
      data, _status_code, _headers = update_service_definition_with_http_info(enforcement_point_id, service_definition_id, service_definition, opts)
      data
    end

    # Update an existing Service Definition on the given enforcement point 
    # Update an existing Service Definition on the given enforcement point. 
    # @param enforcement_point_id Enforcement point id
    # @param service_definition_id Id of service definition
    # @param service_definition 
    # @param [Hash] opts the optional parameters
    # @return [Array<(ServiceDefinition, Fixnum, Hash)>] ServiceDefinition data, response status code and response headers
    def update_service_definition_with_http_info(enforcement_point_id, service_definition_id, service_definition, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: PolicySecurityServiceInsertionServiceDefinitionsApi.update_service_definition ...'
      end
      # verify the required parameter 'enforcement_point_id' is set
      if @api_client.config.client_side_validation && enforcement_point_id.nil?
        fail ArgumentError, "Missing the required parameter 'enforcement_point_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.update_service_definition"
      end
      # verify the required parameter 'service_definition_id' is set
      if @api_client.config.client_side_validation && service_definition_id.nil?
        fail ArgumentError, "Missing the required parameter 'service_definition_id' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.update_service_definition"
      end
      # verify the required parameter 'service_definition' is set
      if @api_client.config.client_side_validation && service_definition.nil?
        fail ArgumentError, "Missing the required parameter 'service_definition' when calling PolicySecurityServiceInsertionServiceDefinitionsApi.update_service_definition"
      end
      # resource path
      local_var_path = '/enforcement-points/{enforcement-point-id}/service-definitions/{service-definition-id}'.sub('{' + 'enforcement-point-id' + '}', enforcement_point_id.to_s).sub('{' + 'service-definition-id' + '}', service_definition_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(service_definition)
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'ServiceDefinition')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: PolicySecurityServiceInsertionServiceDefinitionsApi#update_service_definition\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
