#!/usr/bin/python
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
#

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = '''
---
module: ce_netstream_template
version_added: "2.4"
short_description: Manages NetStream template configuration on HUAWEI CloudEngine switches.
description:
    - Manages NetStream template configuration on HUAWEI CloudEngine switches.
author:
    - wangdezhuang (@CloudEngine-Ansible)
options:
    state:
        description:
            - Specify desired state of the resource.
        required: false
        default: present
        choices: ['present', 'absent']
    type:
        description:
            - Configure the type of netstream record.
        required: true
        choices: ['ip', 'vxlan']
    record_name:
        description:
            - Configure the name of netstream record.
              The value is a string of 1 to 32 case-insensitive characters.
        required: false
        default: null
    match:
        description:
            - Configure flexible flow statistics template keywords.
        required: false
        default: null
        choices: ['destination-address', 'destination-port', 'tos', 'protocol', 'source-address', 'source-port']
    collect_counter:
        description:
            - Configure the number of packets and bytes that are included in the flexible flow statistics sent to NSC.
        required: false
        default: null
        choices: ['bytes', 'packets']
    collect_interface:
        description:
            - Configure the input or output interface that are included in the flexible flow statistics sent to NSC.
        required: false
        default: null
        choices: ['input', 'output']
    description:
        description:
            - Configure the description of netstream record.
              The value is a string of 1 to 80 case-insensitive characters.
        required: false
        default: null
'''

EXAMPLES = '''
- name: netstream template module test
  hosts: cloudengine
  connection: local
  gather_facts: no
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: "{{ ansible_ssh_port }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: cli

  tasks:

  - name: Config ipv4 netstream record
    ce_netstream_template:
      state: present
      type: ip
      record_name: test
      provider: "{{ cli }}"
  - name: Undo ipv4 netstream record
    ce_netstream_template:
      state: absent
      type: ip
      record_name: test
      provider: "{{ cli }}"
  - name: Config ipv4 netstream record collect_counter
    ce_netstream_template:
      state: present
      type: ip
      record_name: test
      collect_counter: bytes
      provider: "{{ cli }}"
  - name: Undo ipv4 netstream record collect_counter
    ce_netstream_template:
      state: absent
      type: ip