Object Record Owners
This technical design describes API for Object Record Owners.
Implementation details can be found in external document: Event History - Object Records - Technical Design.
Object Records Owners API
POST /api/object-records/record_id/owners/
Creates Object Record Owner relations.
Permissions
Requires authentication and any of
object_records.editpermission- Object Record Ownership
URL parameters
| Key | Notes |
|---|---|
| record_id | Object Record ID |
Request example
- Headers
Request Method: POST
Content-Type: application/json
Authorization: JWT access_tokenBody
| Key | Type | Required | Notes |
|---|---|---|---|
| - | list | True | owner ids list |
Validations
- Maximum number of Owners per specific Object Record: 1.
- Maximum number of Owners in batch: 1.
- User is validated by account type,
one_time_completionaccount cannot be owner.
Sample request body
POST /api/object-records/1/owners/
json
[
2
]Response
| Key | Type | Notes |
|---|---|---|
| id | int | Automatically generated by the backend. |
| name | string | |
| owner_id | int | |
| type | string | |
| created_at | datetime | |
| created_by | user | |
| user | Object |
- Response
userObject
| Key | Type | Notes |
|---|---|---|
| id | int | Automatically generated by the backend. |
| username | string | |
| first_name | string | |
| last_name | string | |
| account_type | string | |
| company_name | string | |
| is_deleted | bool |
- Successful status 201 Created
- Response body schema
json
{
"id": 10,
"owner_id": 41,
"type": "user",
"name": "sample name",
"created_at": "2023-07-10T09:28:27.679165+02:00",
"created_by": "some name (test.autologyx@autologyx.com)",
"user": {
"id":41,
"first_name": "first name",
"last_name": "last name",
"username": "test.autologyx@autologyx.com",
"company_name": "autologyx",
"is_deleted": false,
"account_type": "full"
}
}Errors
| Cause | Response code | Message |
|---|---|---|
| record_id is invalid | 400 Bad Request | "detail": "Invalid pk "99999" - object does not exist." |
| record_id is not int | 400 Bad Request | "detail": "Incorrect type. Expected pk value, received str." |
| list in body is empty | 400 Bad Request | "detail": "This list may not be empty." |
| body has incorrect type | 400 Bad Request | "detail": "Expected a list of items but got type "str"." |
| owner has wrong type | 400 Bad Request | "detail": "1 Time Completion account cannot be owner." |
| batch size is above the limit | 400 Bad Request | "detail": "Up to 1 item allowed." |
| object record owners is above the limit | 400 Bad Request | "detail": "Limit of 1 Object Record Owners has been exceeded." |
| Request user does not have "users.list" permission for the user to be assigned as the Object Record owner | 400 Bad Request | "detail": ["You do not have permission to make user "{user_id}" the owner of Object Record "{record_id}"."] |
| insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
GET /api/object-records/record_id/owners/
Returns list of owners.
Permissions
Requires authentication and any of
object_records.viewpermission- Object Record Ownership
URL parameters
| Key | Notes |
|---|---|
| record_id | Object Record ID |
Request example
- Headers
Request Method: GET
Content-Type: application/json
Authorization: JWT access_tokenResponse
| Key | Type | Notes |
|---|---|---|
| limit | int | |
| offset | int | |
| total_count | int | Total number of results visible to the user (based on permissions). |
| filtered_count | int | Number of results visible to the user (based on permissions) with filters applied. |
| next | url | Next page URL (null if there is no next page) |
| previous | url | Previous page URL (null if there is no previous page) |
| results | Array | List of results. Described in the next table. |
Response results array
| Key | Type | Notes |
|---|---|---|
| id | int | Automatically generated by the backend. |
| name | string | |
| owner_id | int | |
| type | string | |
| created_at | datetime | |
| created_by | user | |
| user | Object |
- Successful status
200 OK - Response body schema
json
{
"limit":50,
"offset":0,
"filtered_count":1,
"total_count":1,
"next":null,
"previous":null,
"results":[
{
"id":22,
"owner_id":641,
"type":"user",
"name":"sample name",
"created_at":"2023-07-10T09:28:27.679165+02:00",
"created_by":"some name (test.autologyx@autologyx.com)",
"user":
{
"id":641,
"first_name":"sample first name",
"last_name":"sample last name",
"username":"test.autologyx@example.test",
"company_name":"autologyx",
"is_deleted":false,
"account_type":"full"
}
}]}Sorting
| Parameter | Example | Notes |
|---|---|---|
| id | {build}/api/object-records/record_id/owners/?ordering=id | Ascending |
| id | {build}/api/object-records/record_id/owners/?ordering=-id | Descending (-) |
| name | {build}/api/object-records/record_id/owners/?ordering=name | Ascending |
| name | {build}/api/object-records/record_id/owners/?ordering=-name | Descending (-) |
| created_at | {build}/api/object-records/record_id/owners/?ordering=created_at | Ascending |
| created_at | {build}/api/object-records/record_id/owners/?ordering=-created_at | Descending (-) |
Filtering
Filtering by Object Record related fields
| Parameter | Type | Example |
|---|---|---|
| id | int | {build}/api/object-records/record_id/owners/?id=1 |
| owner_id | datetime | {build}/api/object-records/record_id/owners/?owner_id=2 |
| name | string | {build}/api/object-records/record_id/owners/?name=John |
| created_at | datetime | {build}/api/object-records/record_id/owners/?created_at__gte=2022-01-01 |
| created_by | enum | {build}/api/object-records/record_id/owners/?created_by=321 |
Errors
| Cause | Response code | Message |
|---|---|---|
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
GET /api/object-records/record_id/owners/owner_id/
Response example
- Status
405 Method Not Allowed
DELETE /api/object-records/record_id/owners/object_record_owner_id/
Delete single object relation record.
Permissions
Requires authentication and any of
object_records.editpermission- Object Record Ownership
URL parameters
| Key | Notes |
|---|---|
| record_id | Object Record ID |
| object_record_owner_id | Object Record Owner ID |
Request example
- Headers
Request Method: DELETE
Content-Type: application/json
Authorization: JWT access_tokenResponse
- Successful status
204 No Content
Errors
| Cause | Response code | Message |
|---|---|---|
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
OPTIONS /api/object-records/record_id/owners/
Permissions
Requires authentication only.
Request example
- Headers
Request Method: DELETE
Content-Type: application/json
Authorization: JWT access_tokenResponse example
- Status
200 OK - Body
json
{
"list": {
"columns": [
{
"alias": "id",
"type": "int",
"predicates": [
"exact",
"gt",
"gte",
"lt",
"lte",
"range"
],
"sort_ok": true
},
{
"alias": "owner_id",
"type": "int",
"predicates": [
"exact",
"gt",
"gte",
"lt",
"lte",
"range"
],
"sort_ok": false
},
{
"alias": "name",
"type": "string",
"predicates": [
"exact",
"iexact",
"contains",
"icontains",
"startswith",
"istartswith",
"endswith",
"iendswith"
],
"sort_ok": true
},
{
"alias": "created_at",
"type": "datetime",
"predicates": [
"exact",
"gt",
"gte",
"lt",
"lte",
"range"
],
"sort_ok": true
},
{
"alias": "created_by",
"type": "enum",
"predicates": [
"exact",
"in"
],
"sort_ok": false,
"autocomplete": "/api/users/autocomplete/?text__icontains="
}
]
},
"batch": {
"type": "set",
"required": true,
"autocomplete": "/api/users/autocomplete/?account_type!=one_time_completion&text__icontains="
},
"restrictions": {
"limit_items": 1,
"limit_items_in_batch": 1
}
}