
    Vh                     n    d dl mZmZmZ eZdZdZdZd dl	m
Z
mZmZ d dlmZ d Zd Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functiona  
module: scaleway_volume
short_description: Scaleway volumes management module
author: Henryk Konsek (@hekonsek)
description:
  - This module manages volumes on Scaleway account U(https://developer.scaleway.com).
extends_documentation_fragment:
  - community.general.scaleway
  - community.general.attributes

attributes:
  check_mode:
    support: full
  diff_mode:
    support: none

options:
  state:
    type: str
    description:
      - Indicate desired state of the volume.
    default: present
    choices:
      - present
      - absent
  region:
    type: str
    description:
      - Scaleway region to use (for example par1).
    required: true
    choices:
      - ams1
      - EMEA-NL-EVS
      - par1
      - EMEA-FR-PAR1
      - par2
      - EMEA-FR-PAR2
      - waw1
      - EMEA-PL-WAW1
  name:
    type: str
    description:
      - Name used to identify the volume.
    required: true
  project:
    type: str
    description:
      - Scaleway project ID to which volume belongs.
    version_added: 4.3.0
  organization:
    type: str
    description:
      - ScaleWay organization ID to which volume belongs.
  size:
    type: int
    description:
      - Size of the volume in bytes.
  volume_type:
    type: str
    description:
      - Type of the volume (for example 'l_ssd').
aj  
- name: Create 10GB volume
  community.general.scaleway_volume:
    name: my-volume
    state: present
    region: par1
    project: "{{ scw_org }}"
    "size": 10000000000
    volume_type: l_ssd
  register: server_creation_check_task

- name: Make sure volume deleted
  community.general.scaleway_volume:
    name: my-volume
    state: absent
    region: par1
a  
data:
  description: This is only present when O(state=present).
  returned: when O(state=present)
  type: dict
  sample:
    {
      "volume": {
        "export_uri": null,
        "id": "c675f420-cfeb-48ff-ba2a-9d2a4dbe3fcd",
        "name": "volume-0-3",
        "project": "000a115d-2852-4b0a-9ce8-47f1134ba95a",
        "server": null,
        "size": 10000000000,
        "volume_type": "l_ssd"
      }
    }
)SCALEWAY_LOCATIONscaleway_argument_specScaleway)AnsibleModulec                    | j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }t        |   d   | j                   d	<   t        |       }|j                  d
      }	|	j                  }
|	j
                  }||}|	j                  s/| j                  dj                  |
|	j
                  d                d }|d
   D ]  }|d   |k(  s|d   |k(  s|} |dv r|| j                  d       ||||d}|j                  d|      }	|	j                  r| j                  d|	j
                         | j                  dj                  |	j                  |	j
                               y |dv r|| j                  d       | j                  r| j                  d       |j                  d|d   z         }	|	j                  dk(  r| j                  d|	j
                         | j                  dj                  |	j                  |	j
                               y y )Nregionstatenameorganizationprojectsizevolume_typeapi_endpointapi_urlvolumeszError getting volume [{0}: {1}]message)msg)presentF)changed)r   r   r   r   z/volumesT)r   dataz Error creating volume [{0}: {1}])absentz	/volumes/id   z Error deleting volume [{0}: {1}])paramsr   r   getstatus_codejsonok	fail_jsonformat	exit_jsonpost
check_modedelete)moduler   r   r   r   r   r   r   account_apiresponser   volumes_jsonvolumeByNamevolumepayloads                  u/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/scaleway_volume.pycorer0   w   sY   ]]8$FMM'"E== D==0LmmI&G== D--.K08HFMM)6"Ky)H&&K==L;;>EEy13 	4 Ly) ")'F6Nd,B!L" #U+GTR]^##J8;;T>?FF  (--1 	2 
+	U+T*%%kL4F&FG3&T>?FF  (--1 	2 
    c                  P   t               } | j                  t        t        dddg      t        d      t        d      t               t               t               t        dt        t	        j
                                     	             t        | dd
gd
g      }t        |       y )Nr   r   )defaultchoicesT)requiredint)type)r5   r4   )r   r   r   r   r   r   r   )r   r   )argument_specsupports_check_modemutually_exclusiverequired_one_of)r   updatedictlistr   keysr	   r0   )r8   r(   s     r/   mainr@      s    *,M9x.CD4 uVFT40A0F0F0H+IJ  # '
 (
	F 	Lr1   __main__N)
__future__r   r   r   r7   __metaclass__DOCUMENTATIONEXAMPLESRETURNCansible_collections.community.general.plugins.module_utils.scalewayr   r   r   ansible.module_utils.basicr	   r0   r@   __name__ r1   r/   <module>rK      sW    A @=~$
& D  D 452p2 zF r1   