Skip to content
danmacpherson edited this page Feb 7, 2013 · 1 revision

Provider Accounts

Create a new provider account

Request

Creating of Provider Account is done on nested route of Provider. This way there is no need to specify which Provider is Provider Account associated with.

Example for Mock Provider:

curl -X POST --user admin:password--header “Accept: application/xml”  --header “Content-Type: application/xml” -k https://localhost/conductor/api/provider_accounts --data
  "<provider_account>
   <label>account-label</label>
   <provider id='1'/>
   <credentials>
   <username>user</username>
   <password>password</password>
   </credentials>
  </provider_account>"

Example for EC2 Provider:

Creating of Provider Account for EC2 Provider in UI needs uploading some files. When using API we can just grab content of file and wrap using CDATA. In bash use single quotes around XML to suppress evaluation.

curl -X POST --user admin:password--header “Accept: application/xml”  --header “Content-Type: application/xml” -k https://localhost/conductor/api/provider_accounts --data 
  ‘<provider_account>
    <label>ec2account</label>
    <provider id='1'/>
    <credentials>
      <username>ec2user</username>
      <password>ec2password</password>
      <account_id>ec2account\_id</account_id>
      <x509private>\<![]([CDATA[ec2x509private]]></x509private>
      <x509public><)[CDATA[ec2x509public]]\></x509public>
    </credentials>
  </provider_account>’

Quota:

There can be specified Quota node for Provider Account:

<provider_account>
...
<quota><maximum_running_instances>100</maximum_running_instances></quota>
...
</provider_account>

or

<provider_account>
...
<quota maximum_running_instances='100' />
...
</provider_account>

If Quota is not specified, there is unlimited as default.

Response

If success,

http status Created - 201

<provider_account href="https://localhost/conductor/api/provider_accounts/1" id="1">
  <label>account-label</label>
  <provider href="https://localhost/conductor/api/providers/1" id="1">provider1</provider>
  <provider_type>type</provider_type>
  <credentials>
    <username>user</username>
    <password>password</password>
  </credentials>
  <quota_used>0%</quota_used>
  <quota maximum_running_instances='unlimited'></quota>
</provider_account>

If failure,

http status depending on error - in this example Unprocessable Entity - 422 for validation errors

<errors>
  <error>
    <message>Label can't be blank</message>
  </error>
</errors>

List all provider accounts

Request

curl -X GET --insecure --header 'Accept: application/xml' --header 'Content-Type: application/xml' --user admin:password https://localhost/conductor/api/provider_accounts

Response

<provider_accounts>
  <provider_account href="http://localhost/conductor/api/provider_accounts/6" id="6">
  </provider_account>
  <provider_account href="http://localhost/conductor/api/provider_accounts/7" id="7">
  </provider_account>
</provider_accounts>

There is possibility to get all provider accounts for one provider (nested resources)

Request

curl -X GET --insecure --header 'Accept: application/xml' --header 'Content-Type: application/xml' --user admin:password http://localhost/conductor/api/providers/1/provider_accounts

Response

<provider_accounts>
  <provider_account href="http://localhost/conductor/api/provider_accounts/6" id="6">
  </provider_account>
</provider_accounts>

Show a single provider account’s details

Request

curl -X GET --insecure --header 'Accept: application/xml' --header 'Content-Type: application/xml' --user admin:password http://localhost/conductor/api/provider_accounts/7

Response

Example for mock provider account

<provider_account href="http://localhost/conductor/api/provider_accounts/6" id="6">
  <label>mock account</label>
  <provider href="http://localhost/conductor/api/providers/1" id="1">mock 1</provider>
  <provider_type>mock</provider_type>
  <credentials>
    <password>mockpassword</password>
    <username>mockuser</username>
  </credentials>
  <quota_used>0%</quota_used>
  <quota maximum_running_instances='unlimited'></quota>
</provider_account>

Example fo ec2 provider account

<provider_account href="http://localhost/conductor/api/provider_accounts/7" id="7">
  <label>ec2 account 1</label>
  <provider href="http://localhost/conductor/api/providers/7" id="7">ec2-us-east-1</provider>
  <provider_type>ec2</provider_type>
  <credentials>
    <account_id>account number</account_id>
    <password>ec2 secret access key</password>
    <x509private>-----BEGIN PRIVATE KEY-----
 - private key here -
-----END PRIVATE KEY-----
</x509private>
    <username>ec2 access key</username>
    <x509public>-----BEGIN CERTIFICATE-----
 - certificate here -
-----END CERTIFICATE-----
</x509public>
  </credentials>
  <quota_used>0%</quota_used>
  <quota maximum_running_instances='unlimited'>
</provider_account>

Update a provider account

Request

curl -X PUT --user admin:password --header "Accept: application/xml" --header "Content-Type: application/xml" -k 
http://localhost/conductor/api/provider_accounts/1 
--data "
<provider_account>
<label>account-label</label>
<credentials>
<username>user</username>
<password>password</password>
</credentials>
</provider_account>"

Response

If success,

Same as show details

If failure,

for non existing provider

http status 404 Not Found

<error>
  <code>RecordNotFound</code>
  <message>Couldn't find ProviderAccount with ID=1</message>
</error>

for bad request - validation errors

http status depending on error - in this example Unprocessable Entity - 422 for validation errors

<errors>
  <error>
    <message>An error occurred when checking Provider credentials. Please check your setup and try again.</message>
  </error>
</errors>

Delete a provider account

Request

curl -X DELETE --user admin:password --header "Accept: application/xml" --header "Content-Type: application/xml" -k  http://localhost/conductor/api/provider_accounts/1

Response

If success, return 204 No Content.

If failure,

<error>
  <codee>RecordNotFound</codee>
  <message>Couldn't find Catalog with ID=1</message>
</error>
Clone this wiki locally