=======
Clients
=======
.. include:: ../../complete.rst
The Clients endpoints provide a way to view clients and their sites,
users, apps and invitations.
Listing Clients
---------------
.. http:get:: /api/v1/jb/clients/
Get a list of clients
**Example Request**:
.. code::
GET /api/v1/jb/clients/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
[
{
"id": 1,
"site": {
"domain": "localhost:8000",
"formatted_name": "localhost"
},
"name": "Juicebox",
"default_from_email": "",
"invitation_subject": "",
"invitation_body": "",
"login_title": "Welcome to Juicebox",
"login_subtitle": "",
"support_email": "support@juiceanalytics.com",
"home_location": "/",
"subtitle_404": "Oops, the application you're looking for does not exist.",
"message_404": "You may want to head back to the homepage.
If you think something is broken, report a problem.",
"subtitle_500": "Looks like we're having some server issues.",
"message_500": "Go back to the previous page and try again. If you think something is broken, report a problem.",
"password_min_length": 8,
"password_allow_common": false,
"password_require_numeric": false,
"password_require_upper": false,
"password_require_lower": false,
"password_require_special": false,
"password_expiration_days": 0
}
]
:>jsonarr int id: the id of the client
:>jsonarr object site: the site details for the client
:>jsonarr string name: the client name
:>jsonarr string default_from_email: the email address used in emails sent from the system
:>jsonarr string invitation_subject: the subject used in invite emails (If not supplied, defaults to: "You've been invited to")
:>jsonarr string invitation_body: additional test to include in the invite email
:>jsonarr string login_title: the title shown on the login screen
:>jsonarr string login_subtitle: the subtitle shown on the login screen
:>jsonarr string support_email: the email address they should contact for support
:>jsonarr string home_location: the URL that users should be directed to by default
:>jsonarr string subtitle_404: the subtitle shown when the user access a page that cannot be found
:>jsonarr string message_404: the message shown when the user access a page that cannot be found
:>jsonarr string subtitle_500: the subtitle shown when the user encounters an error
:>jsonarr string message_500: the message shown when the user encouters an error
:>jsonarr int password_min_length: Passwords must be at least this many characters long
:>jsonarr boolean password_allow_common: Allow commonly used passwords
:>jsonarr boolean password_require_numeric: Require users to have a number in their password
:>jsonarr boolean password_require_upper: Require users to have an uppercase letter in their password
:>jsonarr boolean password_require_lower: Require users to have an lowercase letter in their password
:>jsonarr boolean password_require_special: Require users to have an special character (like '!@#$%') in their password
:>jsonarr int password_expiration_days: Require users to change their password after this number of days, 0=disabled
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
Get Client Details
------------------
.. http:get:: /api/v1/jb/clients/(int:id)/
Get details for a client
**Example Request**:
.. code::
GET /api/v1/jb/clients/1/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
{
"id": 1,
"site": {
"domain": "localhost:8000",
"formatted_name": "localhost"
},
"name": "Juicebox",
"default_from_email": "",
"invitation_subject": "",
"invitation_body": "",
"login_title": "Welcome to Juicebox",
"login_subtitle": "",
"support_email": "support@juiceanalytics.com",
"home_location": "/",
"subtitle_404": "Oops, the application you're looking for does not exist.",
"message_404": "You may want to head back to the homepage.
If you think something is broken, report a problem.",
"subtitle_500": "Looks like we're having some server issues.",
"message_500": "Go back to the previous page and try again. If you think something is broken, report a problem.",
"password_min_length": 8,
"password_allow_common": false,
"password_require_numeric": false,
"password_require_upper": false,
"password_require_lower": false,
"password_require_special": false,
"password_expiration_days": 0
}
:param int id: the id of the client
:>json int id: the id of the client
:>json object site: the site details for the client
:>json string name: the client name
:>json string default_from_email: the email address used in emails sent from the system
:>json string invitation_subject: the subject used in invite emails (If not supplied, defaults to: "You've been invited to")
:>json string invitation_body: additional test to include in the invite email
:>json string login_title: the title shown on the login screen
:>json string login_subtitle: the subtitle shown on the login screen
:>json string support_email: the email address they should contact for support
:>json string home_location: the URL that users should be directed to by default
:>json string subtitle_404: the subtitle shown when the user access a page that cannot be found
:>json string message_404: the message shown when the user access a page that cannot be found
:>json string subtitle_500: the subtitle shown when the user encounters an error
:>json string message_500: the message shown when the user encouters an error
:>json int password_min_length: Passwords must be at least this many characters long
:>json boolean password_allow_common: Allow commonly used passwords
:>json boolean password_require_numeric: Require users to have a number in their password
:>json boolean password_require_upper: Require users to have an uppercase letter in their password
:>json boolean password_require_lower: Require users to have an lowercase letter in their password
:>json boolean password_require_special: Require users to have an special character (like '!@#$%') in their password
:>json int password_expiration_days: Require users to change their password after this number of days, 0=disabled
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Update Client Details
---------------------
.. http:patch:: /api/v1/jb/clients/(int:id)/
Update details for a client
**Example Request**:
.. code::
PATCH /api/v1/jb/clients/1/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
{
"name": "My Client Name"
}
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
{
"id": 1,
"site": {
"domain": "localhost:8000",
"formatted_name": "localhost"
},
"name": "My Client Name",
"default_from_email": "",
"invitation_subject": "",
"invitation_body": "",
"login_title": "Welcome to Juicebox",
"login_subtitle": "",
"support_email": "support@juiceanalytics.com",
"home_location": "/",
"subtitle_404": "Oops, the application you're looking for does not exist.",
"message_404": "You may want to head back to the homepage.
If you think something is broken, report a problem.",
"subtitle_500": "Looks like we're having some server issues.",
"message_500": "Go back to the previous page and try again. If you think something is broken, report a problem."
"password_min_length": 8,
"password_allow_common": false,
"password_require_numeric": false,
"password_require_upper": false,
"password_require_lower": false,
"password_require_special": false,
"password_expiration_days": 0
}
:param int id: the id of the client
:json int id: the id of the client
:>json object site: the site details for the client
:>json string name: the client name
:>json string default_from_email: the email address used in emails sent from the system
:>json string invitation_subject: the subject used in invite emails (If not supplied, defaults to: "You've been invited to")
:>json string invitation_body: additional test to include in the invite email
:>json string login_title: the title shown on the login screen
:>json string login_subtitle: the subtitle shown on the login screen
:>json string support_email: the email address they should contact for support
:>json string home_location: the URL that users should be directed to by default
:>json string subtitle_404: the subtitle shown when the user access a page that cannot be found
:>json string message_404: the message shown when the user access a page that cannot be found
:>json string subtitle_500: the subtitle shown when the user encounters an error
:>json string message_500: the message shown when the user encouters an error
:>json int password_min_length: Passwords must be at least this many characters long
:>json boolean password_allow_common: Allow commonly used passwords
:>json boolean password_require_numeric: Require users to have a number in their password
:>json boolean password_require_upper: Require users to have an uppercase letter in their password
:>json boolean password_require_lower: Require users to have an lowercase letter in their password
:>json boolean password_require_special: Require users to have an special character (like '!@#$%') in their password
:>json int password_expiration_days: Require users to change their password after this number of days, 0=disabled
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Get Site Details for a Client
-----------------------------
.. http:get:: /api/v1/jb/clients/(int:id)/site/
Get site details for a client
**Example Request**:
.. code::
GET /api/v1/jb/clients/1/site/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
{
"id": 2,
"domain": "localhost:8000",
"name": "localhost:8000"
}
:param int id: the id of the client
:>json int id: the id of the site
:>json string domain: the domain name and optionally a port for the site
:>json string name: the name of the site, which is often the same as the domain
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Get a Client's User List
------------------------
.. http:get:: /api/v1/jb/clients/(int:id)/users/
Get a details for a client
**Example Request**:
.. code::
GET /api/v1/jb/clients/1/users/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
[
{
"extra": { },
"last_login": "2016-06-01T13:34:30.718746Z",
"email": "user@juice.com",
"handle": "@user",
"first_name": "User",
"last_name": "User",
"is_active": true,
"date_joined": "2013-07-28T21:04:32Z",
"is_demo_user": false,
"profile_color": "ff0000",
"profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png",
"last_activated": "2016-06-01T13:22:24.439209Z",
"last_deactivated": null,
"last_password_set": "2016-06-01T13:22:24.439209Z",
"apps": [
"zylTKNVx"
]
}
]
:param int id: the id of the client
:>json int extra: extra data associated with the user for use in your apps
:>json string email: the user's email address
:>json string handle: the user's discussion handle
:>json string first_name: the user's first name
:>json string last_name: the user's last name
:>json boolean is_active: the active status of the user
:>json boolean is_demo_user: the demo status of the user
:>json string profile_color: hex color code of the user's profile
:>json string profile_avatar: the user's selected avatar
:>json array apps: A list of app ids to which the user has access
:>json date last_login: the last date the user logged into the system
:>json date date_joined: the date the user was created
:>json date last_activated: the date the user was last activated
:>json date last_deactivated: the date the user was last deactivated
:>json date last_password_set: the date the user last set their password
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Get a Client's Invited User List
--------------------------------
.. http:get:: /api/v1/jb/clients/(int:id)/users/invitations/
Get a list of pending invited users
**Example Request**:
.. code::
GET /api/v1/jb/clients/1/users/invitations/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
[
{
"id": 3,
"user": {
"extra": {},
"last_login": null,
"email": "jason@juice.com",
"handle": "@jason",
"first_name": "",
"last_name": "",
"is_active": true,
"date_joined": "2016-06-01T18:13:17.943920Z",
"is_demo_user": false,
"profile_color": "ff0000",
"profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png",
"last_activated": "2016-06-01T18:13:17.943951Z",
"last_deactivated": null,
"apps": []
},
"initial_apps": [],
"extra": {},
"email": "invited_user@juiceanalytics.com",
"key": "0626d808767dc0abc76a4266ad2df687b3008156",
"date_invited": "2016-06-01T18:24:04.358609Z",
"invitation_email_count": 1
},
]
:param int id: the id of the client
:>json int id: the id of the invite
:>json object user: the user who performed the invite
:>json int extra: extra data associated with the user for use in your apps
:>json string email: the invited user's email address
:>json string key: a unique key to identify the invited user
:>json array initial_apps: A list of app ids to which the user has been invited
:>json date date_invited: the date the user invited to join the system
:>json int invitation_email_count: a counter to show how many times the user has been sent an invite
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Invite a User to Join a Client
------------------------------
.. http:post:: /api/v1/jb/clients/(int:id)/users/invitations/
Get a list of pending invited users
**Example Request**:
.. code::
POST /api/v1/jb/clients/1/users/invitations/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
{
"email": "new_user@juiceanalytics.com",
"extra": {},
"initial_apps": [
"zylTKNVx"
]
}
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
{
"id": 4,
"user": {
"extra": {},
"last_login": null,
"email": "jason@juice.com",
"handle": "@jason",
"first_name": "",
"last_name": "",
"is_active": true,
"date_joined": "2016-06-01T18:13:17.943920Z",
"is_demo_user": false,
"profile_color": "ff0000",
"profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png",
"last_activated": "2016-06-01T18:13:17.943951Z",
"last_deactivated": null,
"apps": []
},
"initial_apps": ["zylTKNVx",],
"extra": {},
"email": "new_user@juiceanalytics.com",
"key": "0626d808767dc0abc76a4266ad2df687b3008156",
"date_invited": "2016-06-01T18:24:04.358609Z",
"invitation_email_count": 1
},
:param int id: the id of the client
:json object user: the user who performed the invite
:>json int extra: extra data associated with the user for use in your apps
:>json string email: the invited user's email address
:>json string key: a unique key to identify the invited user
:>json array initial_apps: A list of app details to which the user has been invited
:>json date date_invited: the date the user invited to join the system
:>json int invitation_email_count: a counter to show how many times the user has been sent an invite
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 200: OK
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found
Get a Client's App List
-----------------------
.. http:get:: /api/v1/jb/clients/(int:id)/apps/
Get a list of apps for a client
**Example Request**:
.. code::
GET /api/v1/jb/clients/1/apps/
Accept: application/json
Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665
**Example Response**:
.. code::
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
[
{
"id": "zylTKNVx",
"slug": "datademo",
"label": "Data Services Demo",
"show_help": false,
"help_html": "\n",
"show_footer": false,
"footer_html": "",
"description": "US Census Bureau data services demo"
}
]
:param int id: the id of the client
:>json string id: the unique id of the application
:>json string slug: a shortened name of the application
:>json string label: The label or name of the application
:>json string description: A short description of the app
:>json string help_html: HTML to append to the built in help
:>json string footer_html: HTML to show as the app footer
:>json boolean show_help: should we show help in the app
:>json boolean show_footer: should we show a footer in the app
:reqheader Accept: the response content type depends on ``Accept`` header
:reqheader Authorization: contains the token to be used for authentication
:resheader Content-Type: this depends on ``Accept`` header of request
:statuscode 201: Invite Created
:statuscode 403: Authentication Failed
:statuscode 404: Client with the supplied ID not found