# OVH-BASH

This is a simple **OVH API wrapper** in BASH

All API specifications is here : [OVH API](https://eu.api.ovh.com/console/?section=%2FallDom&branch=v1)

It use the same configuration file as for the [go-ovh](https://github.com/ovh/go-ovh?tab=readme-ov-file#application-keyapplication-secret) wrapper

## Token creation

You need to follow : [createApp](https://www.ovh.com/auth/api/createApp)
And add the Application_key,secret_key and consumer_key to the [ovh.conf](/../golang/ovh.conf)

## How to use

**Examples**
1. Get all VPS
```bash
./ovh-bash get vps

[
  "vps-3e2da6b4.vps.ovh.net",
  "vps-556c9180.vps.ovh.net",
  "vps-59e2e922.vps.ovh.net",
  "vps-76fdb68a.vps.ovh.net",
  "vps-89819518.vps.ovh.net",
  "vps-b280dcff.vps.ovh.net",
  "vps-f31d3392.vps.ovh.net"
]
```
2. Get all records for a DNS Zone "linuxforward.com"
```bash
./ovh-bash get domain/zone/linuxforward.com/record/
[
  5344790631,
  5344790632,
  5344790633,
  5344790634,
  5344790635,
  5344790636,
  5344790637,
  [...]
  5344790668,
  5344790669,
  5344790670,
  5344790671
]
```

3. Get info from a specific DNS Zone record

```bash
./ovh-bash get domain/zone/linuxforward.com/record/5344790650
{
  "fieldType": "A",
  "id": 5344790650,
  "subDomain": "demodev",
  "target": "51.91.101.38",
  "ttl": 0,
  "zone": "linuxforward.com"
}

```

4. List all details from all VPS
```bash
./ovh-bash get vps | jq -r '.[]' | while read vps;  do ./ovh-bash get vps/${vps} | jq  '[.name, .model.name, .model.version, .model.disk, .model.memory]|@tsv' ; done | column -t
vps-3e2da6b4.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
vps-556c9180.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
vps-59e2e922.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
vps-76fdb68a.vps.ovh.net  vps-starter-1-2-20  2019v1  20  2048
vps-89819518.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
vps-b280dcff.vps.ovh.net  vps-value-1-2-40    2019v1  40  2048
vps-f31d3392.vps.ovh.net  vps-starter-1-2-20  2019v1  20  2048
```

5. If credentials are revoked

```bash
./ovh-bash get vps
{
  "class": "Client::Forbidden",
  "message": "This credential is not valid",
  "httpCode": "403 Forbidden",
  "errorCode": "INVALID_CREDENTIAL"
}
```
