
= Secure Credentials Vault

The `/scv` endpoint requires `application/json` for all operations.

NOTE: The alias `_all` is reserved, you cannot create credentials using that alias. It is used in `GET /scv/_all` to get all credentials.

== GETs (reading data)

[caption=]
.Secure Credentials Vault API GET functions
[options="autowidth"]
|===
| Resource  | Description

| `/scv`                | Fetches the list of Secure Credentials Vault aliases
| `/scv/\{alias}`       | Fetches the credential with the given `alias`.
| `/scv/_all`           | Fetches the credentials for all aliases (returns a list of credentials).

|===

== PUT (modifying data)

[caption=]
.Secure Credentials Vault API PUT function
[options="autowidth"]
|===
| Resource  | Description

| `/scv/\{alias}`       | Modify a credential with the given `alias`.

|===

== POSTs (Creating Data)
[caption=]
.Secure Credentials Vault API POST function
[options="autowidth"]
|===

| Resource            | Description
| `/scv`              | Add a credential to the Secure Credentials Vault

|===

== DELETEs (Removing Data)
[caption=]
.Secure Credentials Vault API DELETE function
[options="autowidth"]
|===
| Resource            | Description

| `/scv/\{alias}`       | Delete the credentials with the given `alias`

|===

== Examples using cURL

.Get a list of all aliases
[source,bash]
----
curl -u admin:admin "http://127.0.0.1:8980/opennms/rest/scv"
----

.Response
[source,json]
----
["foo"]
----

.Fetch a single alias
[source,bash]
----
curl -u admin:admin "http://127.0.0.1:8980/opennms/rest/scv/foo"
----

.Response
[source,json]
----
{"alias":"foo","username":"barr","password":"******","attributes":{}}
----

.Fetch all credentials
[source,bash]
----
curl -u admin:admin "http://127.0.0.1:8980/opennms/rest/scv/_all"
----

.Response
[source,json]
----
[
  {"alias":"foo","username":"barr","password":"******","attributes":{}},
  {"alias":"foo2","username":"barr2","password":"******","attributes":{}}
]
----

.Create an entry in the vault
[source,bash]
----
curl -u admin:admin -H 'Content-Type: application/json' -d@scv.json http://localhost:8980/opennms/rest/scv
----

.JSON Payload scv.json
[source,json]
----
{"alias":"biff","username":"biff","password":"quux","attributes":{}}
----
