Vridlo/api/vridlo.users: Difference between revisions

From ALT Linux Wiki
Line 21: Line 21:
  Name array for the user.
  Name array for the user.
* '''admin''' is ''boolean'' (Optional)
* '''admin''' is ''boolean'' (Optional)
  Is the user admin, the field requires '''superuser''' permission.
  Is the user admin, the field requires '''superuser''' permission token.
* '''description''' is ''string'' (Optional)
* '''description''' is ''string'' (Optional)
  Description of the user.
  Description of the user.

Revision as of 14:11, 27 November 2019

vridlo.user.slug

This allows accessing to the specified user record by <slug> URI-parameter. Added into API v1.0.

Path

/v1/users/<slug>

Methods

POST

Creates the user specified by <slug> URI-parameter using the set of properties passed as form data or get parameter array, and returns state of the created record as JSON.

Authentication

This method requires write authentication with write permission to user model.

Arguments
  • names is array of Name (Mandatory)
Name array for the user.
  • admin is boolean (Optional)
Is the user admin, the field requires superuser permission token.
  • description is string (Optional)
Description of the user.
  • recitals is array of Recital (Mandatory)
Recital record array for the user.
Sample request
[
 {
  "admin": false,
  "description": "Info user",
  "names": [
    {
       "kind": "firstname"
       "text": "User"
    },
    {
       "kind": "paternal"
       "text": "Batkovič"
    },
    {
       "kind": "lastname"
       "text": "Batkovič"
    },
    {
       "kind": "nickname"
       "text": "Bublo"
    }
  ],
  "recitals": [
   {
      "kind": "email",
      "address": "user@gmail.com",
      "foremost": false
   },
   {
      "kind": "email",
      "address": "user@altlinux.org",
      "foremost": true
   },
   {
      "kind": "login",
      "address": "user",
      "foremost": false
   },
   {
      "kind": "location",
      "address": {
         "x": "37.618448",
         "y": "55.753165",
         "grid": "yandex",
         "name": "Moskva. Kremlin. Senatskij palace"
      },
      "foremost": false
   }
  }
 }
]
Example Response

Good response with created record:

[
 {
  "admin": false,
  "description": "Info user",
  "names": [
    {
       "kind": "firstname"
       "text": "User"
    },
    {
       "kind": "paternal"
       "text": "Batkovič"
    },
    {
       "kind": "lastname"
       "text": "Batkovič"
    },
    {
       "kind": "nickname"
       "text": "Bublo"
    }
  ],
  "recitals": [
   {
      "kind": "email",
      "address": "user@gmail.com",
      "foremost": false
   },
   {
      "kind": "email",
      "address": "user@altlinux.org",
      "foremost": true
   },
   {
      "kind": "login",
      "address": "user",
      "foremost": false
   },
   {
      "kind": "jabber",
      "address": "user@jabber.ru",
      "foremost": false
   },
   {
      "kind": "website",
      "address": "http://user.me",
      "foremost": false
   },
   {
      "kind": "location",
      "address": {
         "x": "37.618448",
         "y": "55.753165",
         "grid": "yandex",
         "name": "Moskva. Kremlin. Senatskij palace"
      },
      "foremost": false
   }
  }
 }
]

Error response 423:

[
 {
  "error_code": 3
 }
]
Return Codes
  • 200 (OK)
The resource wasn't found, and was created. Returned data responds to the current state of the resource.
  • 422.3 (SSL is required)
SSL is required to access the Vridlo API.
  • 422.5 (Invalid incoming data)
The incoming data is invalid. See details for help.
  • 404 (Not Found)
The record with provided slug is not found.
  • 500 (Internal Server Error)
The Internal Server Error has occurred.

GET

Gets properties of the user specified by <slug> URI-parameter, and returns then as JSON. Do not poll this method more than once an hour.

Authentication

This method requires NO authentication.

Arguments

This method requires NO arguments.

Example Response

Good response:

[
 {
  "id": 100000,
  "name": "ruby",
  "epoch": "1",
  "version": "2.5.5",
  "release": "alt1",
  "arch": "i586",
  "built_at": "10.10.10 10:10:10",
  "description": "ruby package",
  "group_id": 100,
  "group_name": "Development/Ruby",
  "md5": "236abd7880b4577f2b9470c09fee79d6",
  "sha": "4a01982354f6d7cab8d9275e43dc0e4329b1d307",
  "size": "100000",
  "builder_name": "Ruby Builder Bot",
  "builder_id": 1000,
  "src_id": 100000,
  "repo_status": "skip",
 }
]

Error response 423:

[
 {
  "error_code": 3
 }
]
Return Codes
  • 200 (OK)
The resource was found and is accessible. Returned data responds to the current state of the resource.
  • 422.3 (SSL is required)
SSL is required to access the Vridlo API.
  • 404 (Not Found)
The record with provided slug is not found.
  • 500 (Internal Server Error)
The Internal Server Error has occurred.

PUT/PATCH

Sets one or many properties of the user specified by <slug> URI-parameter, and returns updated state as JSON.

Authentication

This method requires write authentication with write permission to user model.

Arguments
  • id (Mandatory)
Id of the user.
  • name (Mandatory)
Name of the user.
  • epoch (Optional)
Epoch of the user build.
  • version (Mandatory)
Version of the user build. Must be valid.
  • release (Mandatory)
Release of the user build. Must be valid.
  • arch (Mandatory)
Arch of the user build. Must be valid.
  • description (Optional)
Description of the user.
  • built_at (Mandatory)
Rpm Built at time. Must be valid.
  • group_id (Mandatory)
Group Id which the user is belong to. Must be valid.
  • sha (Mandatory)
Sha of user file. Must be valid.
  • size (Mandatory)
Size of the user.
  • builder_id (Mandatory)
Id of the builder. Must be valid.
  • src_id (Optional)
Id of the source repo. Must be valid if arch is not "src", or blank if arch is "src".
  • repo_status (Optional)
Status of validation the package by a repocop.
Example Request

PUT:/v1/users/ca?name=Core_Assembler

Example Response

Good response:

[
 {
  "id": 100000,
  "name": "ruby",
  "epoch": "1",
  "version": "2.5.5",
  "release": "alt1",
  "arch": "i586",
  "built_at": "10.10.10 10:10:10",
  "description": "ruby package",
  "group_id": 100,
  "md5": "236abd7880b4577f2b9470c09fee79d6",
  "sha": "4a01982354f6d7cab8d9275e43dc0e4329b1d307",
  "size": "100000",
  "builder_id": 1000,
  "src_id": 100000,
  "repo_status": "skip",
 }
]

Error response 423:

[
 {
  "error_code": 3
 }
]
Return Codes
  • 200 (OK)
The resource was found and is accessible. Changes were made on the resource successfully. Returned data responds to the current state of the resource.
  • 204 (No Content)
The resource was found and is accessible. But no changes were made on the resource.
  • 422.3 (SSL is required)
SSL is required to access the Vridlo API.
  • 422.5 (Invalid incoming data)
The incoming data is invalid. See details for help.
  • 404 (Not Found)
The record with provided id/slug is not found.
  • 500 (Internal Server Error)
The Internal Server Error has occurred.

DELETE

Destroys the user specified by <slug> URI-parameter, and returns state of the destroyed record as JSON.

Authentication

This method requires write authentication with write permission to user model.

Arguments

This method requires NO arguments.

Example Response

Good response returning deleted record:

[
 {
  "id": 100001,
  "name": "ruby",
  "epoch": "1",
  "version": "2.5.5",
  "release": "alt1",
  "arch": "src",
  "built_at": "10.10.10 10:10:10",
  "description": "ruby package",
  "group_id": 100,
  "group_name": "Development/Ruby",
  "md5": "236abd7880b4577f2b9470c09fee79d6",
  "sha": "4a01982354f6d7cab8d9275e43dc0e4329b1d307",
  "size": "100000",
  "builder_name": "Ruby Builder Bot",
  "builder_id": 1000,
  "repo_status": "skip",
 }
]

Error response 423:

[
 {
  "error_code": 3
 }
]
Return Codes
  • 200 (OK)
The resource was found and is accessible, and successfully destroyed. Returned data responds to the state of the destroyed resource.
  • 422.3 (SSL is required)
SSL is required to access the Vridlo API.
  • 404 (Not Found)
The record with provided slug is not found.
  • 500 (Internal Server Error)
The Internal Server Error has occurred.