Job assignments link a user or group (including "all users") to a job or all jobs. Because jobs can be hierarchical, it's important to understand the following:

  • Job assignments are automatically inherited if descendant jobs have no assignments of their own.
  • If any assignments are created for a job, its parent's assignments will no longer apply to the job. None of the parent's assignments will be copied automatically to the child (even though this happens when overriding assignments using Syncd's web interface).

Only Job Managers can view, create and delete job assignments. If you'd like to view assigned jobs instead of job assignments, use the Jobs interface.

Show

Request

GET /job_assignments/#{job-assignment-id}.xml

Optional parameters

The following optional parameters can be used to include extra data:

include=[users,
         user_groups,
         jobs]

Response

Status: 200 OK

<job-assignment>
  <id type="integer">#{job-assignment-id}</id>
  <!-- if assigned to all users --->
  <users>all</users>
  <!-- else if assigned to no users --->
  <users>none</users>
  <!-- else if assigned to a user -->
  <!--   if include=users -->
  <user>
    ...
  </user>
  <!--   else -->
  <user-id type="integer">#{user-id}</user-id>
  <!-- else if assigned to a user group --->
  <!--   end -->
  <!--   if include=user_groups -->
  <user-group>
    ...
  </user-group>
  <!--   else -->
  <user-group-id type="integer">#{user-group-id}</user-group-id>
  <!--   end -->
  <!-- end -->
  <!-- if assigned to all jobs --->
  <jobs>all</jobs>
  <!-- else if include=jobs -->
  <job>
    ...
  </job>
  <!-- else -->
  <job-id type="integer">#{job-id}</job-id>
  <!-- end -->
  <!-- if include=timestamps -->
  <created-at type="datetime">2008-01-08T03:47:52Z</created-at>
  <updated-at type="datetime">2008-01-08T03:47:52Z</updated-at>
  <!-- end -->
</job-assignment>

List

Any user can view their own assignments.

Request

All job assignments:

GET /job_assignments.xml

Assignments to a particular job (includes assignments to all jobs & inherited assignments):

GET /jobs/#{job-id}/assignments.xml

Direct assignments to a particular job (excludes assignments to all jobs & inherited assignments):

GET /jobs/#{job-id}/assignments/direct.xml

Assignments related to a particular user (includes assignments to the user's groups and all users):

GET /users/#{user-id}/job_assignments.xml

Direct assignments to a particular user (excludes assignments to the user's groups and all users):

GET /users/#{user-id}/job_assignments/direct.xml

Assignments for a particular user group:

GET /user_groups/#{user-group-id}/job_assignments.xml

Since all assignments to user groups are direct, there's no separate method for requesting only direct assignments.

Optional parameters

Specify start and end to request a specific range of items. For example:

GET /job_assignments.xml?start=1&end=4

The following optional parameters can be used to include extra data:

include=[users,
         user_groups,
         jobs]

For example:

GET /job_assignments.xml?include=users,user_groups,jobs

Response

Status: 200 OK

<job-assignments type="array">
  <job-assignment>
    ...
  </job-assignment>
  ...
</job-assignments>

Create

Request

POST /job_assignments.xml

Include the following data with your request:

<job-assignment>
  <!-- A user or group must be included -->
  <!--   To specify a user: -->
  <user-id>#{user-id}</user-id>
  <!--   To specify a user group: -->
  <user-group-id>#{user-group-id}</user-group-id>
  <!--   To specify all users: -->
  <users>all</users>
  <!--   To specify no users: -->
  <users>none</users>
  <!-- A job or all jobs must be included -->
  <!--   To specify a job: -->
  <job-id>#{job-id}</job-id>
  <!--   To specify all jobs: -->
  <jobs>all</jobs>
</job-assignment>

For example, to assign a user to a specific job:

<job-assignment>
  <user-id>25</user-id>
  <job-id>14</job-id>
</job-assignment>

Response

Status: 201 Created

<job-assignment>
  <id type="integer">#{new-job-assignment-id}</id>
  <user-id type="integer">25</user-id>
  <job-id type="integer">14</job-id>
  <!-- if include=timestamps -->
  <created-at type="datetime">2008-01-08T03:47:52Z</created-at>
  <updated-at type="datetime">2008-01-08T03:47:52Z</updated-at>
  <!-- end -->
</job-assignment>

Delete

Request

DELETE /job_assignments/#{job-assignment-id}.xml

Response

Status: 200 OK

Continue to Activities