@PLUGIN@ - /config/ REST API

This page describes the REST endpoints that are added by the @PLUGIN@ plugin.

Please also take note of the general information on the REST API.

Service User Endpoints

Create Service User

POST /config/server/@PLUGIN@~serviceusers/{username}

Creates a service user.

The public SSH key for creating the service user must be specified in the request body as a ServiceUserInput entity.

Caller must be a member of a group that is granted the ‘Create Service User’ capability (provided by this plugin) or the ‘Administrate Server’ capability.

Request

  PUT /config/server/@PLUGIN@~serviceusers/JenkinsVoter HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "ssh_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw=="
  }

As response a ServiceUserInfo entity is returned that describes the created account.

Response

  HTTP/1.1 201 Created
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  {
    "created_by": "jdoe",
    "created_at": "Thu, 21 Nov 2013 15:00:55 +0100",
    "_account_id": 1000195,
    "name": "JenkinsVoter",
    "avatars": []
  }

Get Service User

GET /config/server/@PLUGIN@~serviceusers/{username}

Gets a service user.

In order to be able to see a service user the caller must have created that service user or be a member of a group that is granted the ‘Administrate Server’ capability.

Request

  GET /config/server/@PLUGIN@~serviceusers/JenkinsVoter HTTP/1.0

As response a ServiceUserInfo entity is returned that describes the service user.

Response

  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  {
    "created_by": "jdoe",
    "created_at": "Thu, 21 Nov 2013 15:00:55 +0100",
    "_account_id": 1000195,
    "name": "JenkinsVoter",
    "username": "JenkinsVoter",
    "avatars": []
  }

List Service Users

GET /config/server/@PLUGIN@~serviceusers/_

Lists service users.

In order to see a service user the caller must have created that service user or be a member of a group that is granted the ‘Administrate Server’ capability.

Request

  GET /config/server/@PLUGIN@~serviceusers/ HTTP/1.0

As response a map is returned that maps the username to a ServiceUserInfo entity. The username in ServiceUserInfo is not set since it is already available as map key.

Response

  HTTP/1.1 201 Created
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  {
    "GlobalVerifier": {
      "created_by": "jdoe",
      "created_at": "Mon, 27 Jan 2014 21:00:12 +0100",
      "_account_id": 1000107,
      "name": "GlobalVerifier",
      "avatars": []
    },
    "JenkinsVoter": {
      "created_by": "jdoe",
      "created_at": "Thu, 21 Nov 2013 15:00:55 +0100",
      "_account_id": 1000195,
      "name": "JenkinsVoter",
      "avatars": []
    }
  }

List SSH keys

GET /config/server/@PLUGIN@~serviceusers/{username}/sshkeys/_

Lists the SSH keys of a service user.

Request

  GET /config/server/@PLUGIN@~serviceusers/JenkinsVoter/sshkeys/ HTTP/1.0

As response a list of SshKeyInfo entities is returned.

Response

  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  [
    {
      "seq": 1,
      "ssh_public_key": "ssh-rsa AAAAB3NzaC1...",
      "encoded_key": "AAAAB3NzaC1...",
      "algorithm": "ssh-rsa",
      "comment": "jenkins.voter@gerrit.com",
      "valid": true
    }
  ]

Get SSH key

GET /config/server/@PLUGIN@~serviceusers/{username}/sshkeys/{ssh-key-id}_

Gets an SSH key of a service user.

Request

  GET /config/server/@PLUGIN@~serviceusers/JenkinsVoter/sshkeys/1 HTTP/1.0

As response an SshKeyInfo entity is returned.

Response

  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  {
    "seq": 1,
    "ssh_public_key": "ssh-rsa AAAAB3NzaC1...",
    "encoded_key": "AAAAB3NzaC1...",
    "algorithm": "ssh-rsa",
    "comment": "jenkins.voter@gerrit.com",
    "valid": true
  }

Add SSH key

POST /config/server/@PLUGIN@~serviceusers/{username}/sshkeys_

Adds an SSH key for a service user.

Request

  POST /config/server/@PLUGIN@~serviceusers/JenkinsVoter/sshkeys HTTP/1.0
  Content-Type: plain/text

  AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d

As response an SshKeyInfo entity is returned that describes the new SSH key.

Response

  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  [
    {
      "seq": 2,
      "ssh_public_key": "ssh-rsa AAAAB1NzaA2...",
      "encoded_key": "AAAAB1NzaA2...",
      "algorithm": "ssh-rsa",
      "comment": "jenkins.voter@gerrit.com",
      "valid": true
    }
  ]

Delete SSH key

DELETE /config/server/@PLUGIN@~serviceusers/{username}/sshkeys/{ssh-key-id}_

Deletes an SSH key of a service user.

Request

  DELETE /config/server/@PLUGIN@~serviceusers/JenkinsVoter/sshkeys/2 HTTP/1.0

Response

  HTTP/1.1 204 No Content

Get Config

GET /config/server/@PLUGIN@~config

Gets the configuration of the @PLUGIN@ plugin.

Request

  GET /config/server/@PLUGIN@~config HTTP/1.0

As response a ConfigInfo entity is returned that contains the configuration.

Response

  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json;charset=UTF-8

  )]}'
  {
    "on_success": "Don\u0027t forget to assign \u003ca href\u003d\"Documentation/access-control.html\"\u003eaccess rights\u003c/a\u003e to the service user."
  }

Put Config

PUT /config/server/@PLUGIN@~config

Sets the configuration of the @PLUGIN@ plugin.

The new configuration must be specified as a ConfigInfo entity in the request body. Not setting a parameter leaves the parameter unchanged.

Request

  PUT /config/server/@PLUGIN@~config HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "info": "Please find more information about service users in the <a href\"wiki.html\">wiki</a>."
  }

JSON Entities

ConfigInfo

The ConfigInfo entity contains configuration of the @PLUGIN@ plugin.

  • info: HTML formatted message that should be displayed in the service user creation dialog.
  • on_success: HTML formatted message that should be displayed after a service user was successfully created.
  • allow_email: Whether it is allowed to provide an email address for a service user (not set if false).

ServiceUserInfo

The ServiceUserInfo entity contains information about a service user. It has the same fields as a detailed AccountInfo and in addition the following fields:

  • created_by: The username of the user that created this service user.
  • created_at: The date when the service user was created in the format ‘EEE, dd MMM yyyy HH:mm:ss Z’.

ServiceUserInput

The ServiceUserInput entity contains options for creating a service user.

  • ssh_key: Content of the public SSH key to load into the account's keyring.

SEE ALSO

GERRIT

Part of Gerrit Code Review