
    Vh                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d dlmZmZmZ dd	d
ddddZd Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functionax  
module: storagebox
short_description: Modify a storage box's basic configuration
version_added: 2.1.0
author:
  - Felix Fontein (@felixfontein)
description:
  - Modify a storage box's basic configuration.
extends_documentation_fragment:
  - community.hrobot.robot
  - community.hrobot.attributes
  - community.hrobot.attributes.actiongroup_robot
attributes:
  check_mode:
    support: full
  diff_mode:
    support: full
  idempotent:
    support: full

options:
  id:
    description:
      - The ID of the storage box to modify.
    type: int
    required: true
  name:
    description:
      - The name of the storage box.
    type: str
  samba:
    description:
      - Whether the storage box is accessible through SAMBA.
    type: bool
  webdav:
    description:
      - Whether the storage box is accessible through WebDAV.
    type: bool
  ssh:
    description:
      - Whether the storage box is accessible through SSH.
    type: bool
  external_reachability:
    description:
      - Whether the storage box is externally reachable.
    type: bool
  zfs:
    description:
      - Whether the ZFS directory is visible.
    type: bool
z
---
- name: Setup storagebox
  community.hrobot.storagebox:
    hetzner_user: foo
    hetzner_password: bar
    name: "My storage box"
    ssh: true
    samba: false
    webdav: false
    external_reachability: false
    zfs: false
a  
name:
  description:
    - The storage box's name.
  type: str
  sample: Backup Server 1
  returned: success
webdav:
  description:
    - Whether WebDAV is active.
  type: bool
  sample: true
  returned: success
samba:
  description:
    - Whether SAMBA is active.
  type: bool
  sample: true
  returned: success
ssh:
  description:
    - Whether SSH is active.
  type: bool
  sample: true
  returned: success
external_reachability:
  description:
    - Whether the storage box is reachable externally.
  type: bool
  sample: true
  returned: success
zfs:
  description:
    - Shows whether the ZFS directory is visible.
  type: bool
  sample: false
  returned: success
)AnsibleModule)	urlencode)BASE_URLROBOT_DEFAULT_ARGUMENT_SPECfetch_url_json)namestoragebox_name)webdavr   )sambar   )sshr   )external_reachabilityr   )zfsr   )r   r   r   r   r   r   c                     | d   }t         j                         D ci c]  \  }}||j                  |       c}}S c c}}w )N
storagebox)
PARAMETERSvaluesget)resultsbkeydummys       o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/storagebox.pyextractr      s:    		B/9/@/@/BCeCCCCs   =c                  0   t        t        dd      t        d      t        d      t        d      t        d      t        d      t        d            } | j                  t               t        | d      }|j                  d	   }d
j                  t        |      }t        ||dg      \  }}|r!|j                  dj                  |             t        |      }t        |      }i }t        j                         D ]Z  \  }	\  }
}|j                  |	   }|||
   |k7  s$|||
<   t        |t              rt        |      j                         ||<   V|||<   \ |r|j                   swddi}t        ||t#        |      |ddg      \  }}|rH|d   j%                  d      xs g }|j                  dj                  dj'                  |                   t        |      }t        |      }t        |      |d<   ||d|d<    |j(                  di | y )NintT)typerequiredstr)r   bool)idr   r   r   r   r   r   )argument_specsupports_check_moder#   z{0}/storagebox/{1}STORAGEBOX_NOT_FOUND)accept_errorsz%Storagebox with ID {0} does not exist)msgzContent-typez!application/x-www-form-urlencodedPOSTINVALID_INPUT)dataheadersmethodr'   errorinvalidz'The values to update were invalid ({0})z, changed)beforeafterdiff )dictupdater	   r   paramsformatr   r
   	fail_jsonr   r   items
isinstancer"   r!   lower
check_moder   r   join	exit_json)r$   modulestoragebox_idurlr   r.   r1   r2   changesoption_name	data_namechange_namevaluer,   r/   s                  r   mainrH      s   UT*u f"/fM 45# F
 MM$'M

%
%h
>C"63?U>VWMFEDKKMZ[V_FLEG1;1A1A1C 1--ik*i E)#(i eT*+.u:+;+;+=GK(+0GK(1 v((!#FG&7#*+
 Wo)))4:G!J!Q!QRVR[R[\cRd!ef%[FWF9F6N Fv    __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   ?ansible_collections.community.hrobot.plugins.module_utils.robotr   r	   r
   r   r   rH   __name__r4   rI   r   <module>rT      sw    A @2h%
N 5 A  ("O
D
9x zF rI   