---
- pause:
    prompt: |
      Enter your auth token (https://trailofbits.github.io/algo/cloud-scaleway.html)
    echo: false
  register: _scaleway_token
  when:
    - scaleway_token is undefined
    - lookup('env','SCW_TOKEN')|length <= 0

- pause:
    prompt: |
      What region should the server be located in?
        {% for r in scaleway_regions %}
        {{ loop.index }}. {{ r['alias'] }}
        {% endfor %}

      Enter the number of your desired region
      [{{ scaleway_regions.0.alias }}]
  register: _algo_region
  when: region is undefined

- name: Set scaleway facts
  set_fact:
    algo_scaleway_token: "{{ scaleway_token | default(_scaleway_token.user_input) | default(lookup('env','SCW_TOKEN'), true) }}"
    algo_region: >-
      {% if region is defined %}{{ region }}
      {%- elif _algo_region.user_input %}{{ scaleway_regions[_algo_region.user_input | int -1 ]['alias'] }}
      {%- else %}{{ scaleway_regions.0.alias }}{% endif %}
