executor: pf_api_pki_cas
input:
  cn: ""
  mail: ""
  organisational_unit: ""
  organisation: ""
  country: ""
  state: ""
  locality: ""
  key_type: ""
  digest: ""
  key_usage: ""
  extended_key_usage: ""
  days: ""
  key_size: ""
  ocsp_url: ""
  time_to_sleep: 0
steps:
- type: get_login_token

- type: http
  method: POST
  url: '{{.pfserver_webadmin_url}}/api/v1/pki/cas'
  ignore_verify_ssl: true
  body: >-
    {
      "cn": "{{.input.cn}}",
      "mail": "{{.input.mail}}",
      "organisational_unit": "{{.input.organisational_unit}}",
      "organisation": "{{.input.organisation}}",
      "country": "{{.input.country}}",
      "state": "{{.input.state}}",
      "locality": "{{.input.locality}}",
      "key_type": "{{.input.key_type}}",
      "digest": "{{.input.digest}}",
      "key_usage": "{{.input.key_usage}}",
      "extended_key_usage": "{{.input.extended_key_usage}}",
      "days": "{{.input.days}}",
      "key_size": "{{.input.key_size}}",
      "ocsp_url": "{{.input.ocsp_url}}"
    }
  headers:
    "Authorization": "{{.result.token}}"
    "Content-Type": "application/json"
  assertions:
    - result.statuscode ShouldEqual 200
    - result.bodyjson.__type__ ShouldEqual Map
  vars:
    http_json:
      from: result.bodyjson

- type: sleep
  time_to_sleep: "{{.input.time_to_sleep}}"

output:
  pf_api_pki_cas_id: "{{.http_json.items.items0.id}}"
