=begin
#Alfresco Content Services REST API

#**Core API**  Provides access to the core features of Alfresco Content Services. 

OpenAPI spec version: 1

Generated by: https://github.com/swagger-api/swagger-codegen.git

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=end

require "uri"

module Alfresco
  class TagsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end

    # Create a tag for a node
    # Creates a tag on the node **nodeId**. You specify the tag in a JSON body like this:  ```JSON {   \"tag\":\"test-tag-1\" } ```  **Note:** You can create more than one tag by  specifying a list of tags in the JSON body like this:  ```JSON [   {     \"tag\":\"test-tag-1\"   },   {     \"tag\":\"test-tag-2\"   } ] ``` If you specify a list as input, then a paginated list rather than an entry is returned in the response body. For example:  ```JSON {   \"list\": {     \"pagination\": {       \"count\": 2,       \"hasMoreItems\": false,       \"totalItems\": 2,       \"skipCount\": 0,       \"maxItems\": 100     },     \"entries\": [       {         \"entry\": {           ...         }       },       {         \"entry\": {          ...         }       }     ]   } } ``` 
    # @param node_id The identifier of a node.
    # @param tag_body_create The new tag
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [TagEntry]
    def create_tag_for_node(node_id, tag_body_create, opts = {})
      data, _status_code, _headers = create_tag_for_node_with_http_info(node_id, tag_body_create, opts)
      return data
    end

    # Create a tag for a node
    # Creates a tag on the node **nodeId**. You specify the tag in a JSON body like this:  &#x60;&#x60;&#x60;JSON {   \&quot;tag\&quot;:\&quot;test-tag-1\&quot; } &#x60;&#x60;&#x60;  **Note:** You can create more than one tag by  specifying a list of tags in the JSON body like this:  &#x60;&#x60;&#x60;JSON [   {     \&quot;tag\&quot;:\&quot;test-tag-1\&quot;   },   {     \&quot;tag\&quot;:\&quot;test-tag-2\&quot;   } ] &#x60;&#x60;&#x60; If you specify a list as input, then a paginated list rather than an entry is returned in the response body. For example:  &#x60;&#x60;&#x60;JSON {   \&quot;list\&quot;: {     \&quot;pagination\&quot;: {       \&quot;count\&quot;: 2,       \&quot;hasMoreItems\&quot;: false,       \&quot;totalItems\&quot;: 2,       \&quot;skipCount\&quot;: 0,       \&quot;maxItems\&quot;: 100     },     \&quot;entries\&quot;: [       {         \&quot;entry\&quot;: {           ...         }       },       {         \&quot;entry\&quot;: {          ...         }       }     ]   } } &#x60;&#x60;&#x60; 
    # @param node_id The identifier of a node.
    # @param tag_body_create The new tag
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [Array<(TagEntry, Fixnum, Hash)>] TagEntry data, response status code and response headers
    def create_tag_for_node_with_http_info(node_id, tag_body_create, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.create_tag_for_node ..."
      end
      # verify the required parameter 'node_id' is set
      fail ArgumentError, "Missing the required parameter 'node_id' when calling TagsApi.create_tag_for_node" if node_id.nil?
      # verify the required parameter 'tag_body_create' is set
      fail ArgumentError, "Missing the required parameter 'tag_body_create' when calling TagsApi.create_tag_for_node" if tag_body_create.nil?
      # resource path
      local_var_path = "/nodes/{nodeId}/tags".sub('{format}','json').sub('{' + 'nodeId' + '}', node_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(tag_body_create)
      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 => 'TagEntry')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: TagsApi#create_tag_for_node\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Delete a tag from a node
    # Deletes tag **tagId** from node **nodeId**.
    # @param node_id The identifier of a node.
    # @param tag_id The identifier of a tag.
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def delete_tag_from_node(node_id, tag_id, opts = {})
      delete_tag_from_node_with_http_info(node_id, tag_id, opts)
      return nil
    end

    # Delete a tag from a node
    # Deletes tag **tagId** from node **nodeId**.
    # @param node_id The identifier of a node.
    # @param tag_id The identifier of a tag.
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def delete_tag_from_node_with_http_info(node_id, tag_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.delete_tag_from_node ..."
      end
      # verify the required parameter 'node_id' is set
      fail ArgumentError, "Missing the required parameter 'node_id' when calling TagsApi.delete_tag_from_node" if node_id.nil?
      # verify the required parameter 'tag_id' is set
      fail ArgumentError, "Missing the required parameter 'tag_id' when calling TagsApi.delete_tag_from_node" if tag_id.nil?
      # resource path
      local_var_path = "/nodes/{nodeId}/tags/{tagId}".sub('{format}','json').sub('{' + 'nodeId' + '}', node_id.to_s).sub('{' + 'tagId' + '}', tag_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # 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: TagsApi#delete_tag_from_node\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get a tag
    # Get a specific tag with **tagId**.
    # @param tag_id The identifier of a tag.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [TagEntry]
    def get_tag(tag_id, opts = {})
      data, _status_code, _headers = get_tag_with_http_info(tag_id, opts)
      return data
    end

    # Get a tag
    # Get a specific tag with **tagId**.
    # @param tag_id The identifier of a tag.
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [Array<(TagEntry, Fixnum, Hash)>] TagEntry data, response status code and response headers
    def get_tag_with_http_info(tag_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.get_tag ..."
      end
      # verify the required parameter 'tag_id' is set
      fail ArgumentError, "Missing the required parameter 'tag_id' when calling TagsApi.get_tag" if tag_id.nil?
      # resource path
      local_var_path = "/tags/{tagId}".sub('{format}','json').sub('{' + 'tagId' + '}', tag_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # 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 => 'TagEntry')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: TagsApi#get_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List tags
    # Gets a list of tags in this repository.  You can use the **include** parameter to return additional **values** information. 
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :skip_count The number of entities that exist in the collection before those included in this list.  If not supplied then the default value is 0.  (default to 0)
    # @option opts [Integer] :max_items The maximum number of items to return in the list.  If not supplied then the default value is 100.  (default to 100)
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @option opts [Array<String>] :include Returns additional information about the tag. The following optional fields can be requested: * count 
    # @return [TagPaging]
    def list_tags(opts = {})
      data, _status_code, _headers = list_tags_with_http_info(opts)
      return data
    end

    # List tags
    # Gets a list of tags in this repository.  You can use the **include** parameter to return additional **values** information. 
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :skip_count The number of entities that exist in the collection before those included in this list.  If not supplied then the default value is 0. 
    # @option opts [Integer] :max_items The maximum number of items to return in the list.  If not supplied then the default value is 100. 
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @option opts [Array<String>] :include Returns additional information about the tag. The following optional fields can be requested: * count 
    # @return [Array<(TagPaging, Fixnum, Hash)>] TagPaging data, response status code and response headers
    def list_tags_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.list_tags ..."
      end
      if !opts[:'skip_count'].nil? && opts[:'skip_count'] < 0.0
        fail ArgumentError, 'invalid value for "opts[:"skip_count"]" when calling TagsApi.list_tags, must be greater than or equal to 0.0.'
      end

      if !opts[:'max_items'].nil? && opts[:'max_items'] < 1.0
        fail ArgumentError, 'invalid value for "opts[:"max_items"]" when calling TagsApi.list_tags, must be greater than or equal to 1.0.'
      end

      # resource path
      local_var_path = "/tags".sub('{format}','json')

      # query parameters
      query_params = {}
      query_params[:'skipCount'] = opts[:'skip_count'] if !opts[:'skip_count'].nil?
      query_params[:'maxItems'] = opts[:'max_items'] if !opts[:'max_items'].nil?
      query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
      query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # 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 => 'TagPaging')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: TagsApi#list_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List tags for a node
    # Gets a list of tags for node **nodeId**.
    # @param node_id The identifier of a node.
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :skip_count The number of entities that exist in the collection before those included in this list.  If not supplied then the default value is 0.  (default to 0)
    # @option opts [Integer] :max_items The maximum number of items to return in the list.  If not supplied then the default value is 100.  (default to 100)
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [TagPaging]
    def list_tags_for_node(node_id, opts = {})
      data, _status_code, _headers = list_tags_for_node_with_http_info(node_id, opts)
      return data
    end

    # List tags for a node
    # Gets a list of tags for node **nodeId**.
    # @param node_id The identifier of a node.
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :skip_count The number of entities that exist in the collection before those included in this list.  If not supplied then the default value is 0. 
    # @option opts [Integer] :max_items The maximum number of items to return in the list.  If not supplied then the default value is 100. 
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [Array<(TagPaging, Fixnum, Hash)>] TagPaging data, response status code and response headers
    def list_tags_for_node_with_http_info(node_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.list_tags_for_node ..."
      end
      # verify the required parameter 'node_id' is set
      fail ArgumentError, "Missing the required parameter 'node_id' when calling TagsApi.list_tags_for_node" if node_id.nil?
      if !opts[:'skip_count'].nil? && opts[:'skip_count'] < 0.0
        fail ArgumentError, 'invalid value for "opts[:"skip_count"]" when calling TagsApi.list_tags_for_node, must be greater than or equal to 0.0.'
      end

      if !opts[:'max_items'].nil? && opts[:'max_items'] < 1.0
        fail ArgumentError, 'invalid value for "opts[:"max_items"]" when calling TagsApi.list_tags_for_node, must be greater than or equal to 1.0.'
      end

      # resource path
      local_var_path = "/nodes/{nodeId}/tags".sub('{format}','json').sub('{' + 'nodeId' + '}', node_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'skipCount'] = opts[:'skip_count'] if !opts[:'skip_count'].nil?
      query_params[:'maxItems'] = opts[:'max_items'] if !opts[:'max_items'].nil?
      query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # 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 => 'TagPaging')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: TagsApi#list_tags_for_node\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Update a tag
    # Updates the tag **tagId**.
    # @param tag_id The identifier of a tag.
    # @param tag_body_update The updated tag
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [TagEntry]
    def update_tag(tag_id, tag_body_update, opts = {})
      data, _status_code, _headers = update_tag_with_http_info(tag_id, tag_body_update, opts)
      return data
    end

    # Update a tag
    # Updates the tag **tagId**.
    # @param tag_id The identifier of a tag.
    # @param tag_body_update The updated tag
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :fields A list of field names.  You can use this parameter to restrict the fields returned within a response if, for example, you want to save on overall bandwidth.  The list applies to a returned individual entity or entries within a collection.  If the API method also supports the **include** parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. 
    # @return [Array<(TagEntry, Fixnum, Hash)>] TagEntry data, response status code and response headers
    def update_tag_with_http_info(tag_id, tag_body_update, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: TagsApi.update_tag ..."
      end
      # verify the required parameter 'tag_id' is set
      fail ArgumentError, "Missing the required parameter 'tag_id' when calling TagsApi.update_tag" if tag_id.nil?
      # verify the required parameter 'tag_body_update' is set
      fail ArgumentError, "Missing the required parameter 'tag_body_update' when calling TagsApi.update_tag" if tag_body_update.nil?
      # resource path
      local_var_path = "/tags/{tagId}".sub('{format}','json').sub('{' + 'tagId' + '}', tag_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?

      # header parameters
      header_params = {}

      # HTTP header 'Accept' (if needed)
      local_header_accept = ['application/json']
      local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

      # HTTP header 'Content-Type'
      local_header_content_type = ['application/json']
      header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(tag_body_update)
      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 => 'TagEntry')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: TagsApi#update_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
