Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
david_michael
Participant

How to create a new ServiceAccount via API?

Jump to solution

This is really confusing! https://api-v2-docs.dome9.com/?shell#serviceaccount_postserviceaccount

According to the link I should be able to create a new service account via the API

curl -X POST https://api.dome9.com/v2/service-account \
  --basic -u <key-id>:<key-secret>  \ 
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

But that block doesn't make any sense? Does it return a generic ID which I then use to update with another call? If I do post to it I get an error:

 

HTTP Error 411. The request must be chunked or have a content length.

 

 Looking for some guidance, I'd like to be able to create a new service account to onboard Kubernetes clusters, 1 account per cluster. Thanks!!

 

-David

0 Kudos
1 Solution

Accepted Solutions
Mark_Halsall
Employee
Employee

Hi David,

My API guru says:

The name and role-ids for the service-account must be provided in the request as described in the body parameter section of the documentation.

With curl:

curl 'https://api.dome9.com/v2/service-account'
--basic -u <key-id>:<key-secret>  \
-H 'Content-Type: application/json'
-H 'Accept: application/json' --data-raw '{"name":"<SERVICE_ACCOUNT_NAME>","roleIds":[<LIST,OF,ROLE,IDS>]}'

The response will contain all relevant information about the newly created service-account:

{"name": "SERVICE_ACCOUNT_NAME",
"id": "b72019f5-e5af-4ad5-a6a3-27c6a89079cd",
    "apiKeyId": "6b83cacf-d2dd-4f55-8811-c75ec879791e",
    "apiKeySecret": "26ycmazsqblt1owufed7kxhg",
    "roleIds": [  LIST, OF, ROLE, IDS ]
}

To get a list of all roles and their ids:

curl 'https://api.dome9.com/v2/role' \
  --basic -u <key-id>:<key-secret>  \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

 

View solution in original post

3 Replies
david_michael
Participant

Is documentation in the link out of date? Is there a better resource? It looks completely wrong! I'll see if I can create a service request on that product/capability.

0 Kudos
Mark_Halsall
Employee
Employee

Hi David,

My API guru says:

The name and role-ids for the service-account must be provided in the request as described in the body parameter section of the documentation.

With curl:

curl 'https://api.dome9.com/v2/service-account'
--basic -u <key-id>:<key-secret>  \
-H 'Content-Type: application/json'
-H 'Accept: application/json' --data-raw '{"name":"<SERVICE_ACCOUNT_NAME>","roleIds":[<LIST,OF,ROLE,IDS>]}'

The response will contain all relevant information about the newly created service-account:

{"name": "SERVICE_ACCOUNT_NAME",
"id": "b72019f5-e5af-4ad5-a6a3-27c6a89079cd",
    "apiKeyId": "6b83cacf-d2dd-4f55-8811-c75ec879791e",
    "apiKeySecret": "26ycmazsqblt1owufed7kxhg",
    "roleIds": [  LIST, OF, ROLE, IDS ]
}

To get a list of all roles and their ids:

curl 'https://api.dome9.com/v2/role' \
  --basic -u <key-id>:<key-secret>  \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

 

david_michael
Participant

Thanks @Mark_Halsall! I confirmed the docs were updated. This should make things much easier from now on!

0 Kudos