# Rule Rest API

Overview

Resource | Operation | Description
--- | --- | ---
AllRule | POST /rule/ | create new rule
| GET /rule/ | get all rules for account
MoveRule | POST /rule/(rule_id)/mode | move rule
ReduceRule | POST /rule/(rule_id)/reduce | reduce rule
ReplicaLocks | GET /rule/(rule_id)/locks | get locks by rule id
Rule | PUT /rule/(rule_id) | update rule
| GET /rule/(rule_id) | get rule info
| DELETE /rule/(rule_id) | delete rule
RuleAnalysis | GET /rule/(rule_id)/analysis | analyse rule,
RuleHistory | GET /rule/(rule_id)/history | get rule history by id
RuleHistoryFull | GET /rule/(scope)/(name)/history | get rule history for DID

Details

`POST` `/rule/`

  Create a new replication rule.

  Request JSON Object:
  | dids (list) – List of data identifiers. account (string) – Account issuing the rule. copies (int) – The number of replicas. rse_expression (string) – RSE expression which gets resolved into a list of RSEs. grouping (string) – ALL - All files will be replicated to the same RSE. DATASET - All files in the same dataset will be replicated to the same RSE. NONE - Files will be completely spread over all allowed RSEs without any grouping considerations at all weight (int) – Weighting scheme to be used. lifetime (int) – The lifetime of the replication rule in seconds. locked (string) – If the is locked. subscription_id (string) – The subscription_id, if the rule is created by a subscription. source_replica_expression (string) – Only use replicas as source from these RSEs. activity (string) – Activity to be passed to the conveyor. notify (string) – Notification setting of the rule (‘Y’, ‘N’, ‘C’; None = ‘N’). purge_replicas (bool) – Purge setting if a replica should be directly deleted after the rule is deleted. ignore_availability (bool) – Option to ignore the availability of RSEs. comments (string) – Comment about the rule. ask_approval (bool) – Ask for approval for this rule. asynchronous (bool) – Create replication rule asynchronously by the judge-injector. priority (int) – Priority of the rule and the transfers which should be submitted. split_container (bool) – Should a container rule be split into individual dataset rules. meta (string) – Dictionary with metadata from the WFMS.
  Status Codes: | 201 Created – rule created 401 Unauthorized – Invalid Auth Token 404 Not Found – DID not found 409 Conflict – Invalid Replication Rule 409 Conflict – Duplicate Replication Rule 409 Conflict – Insufficient Target RSEs 409 Conflict – Insufficient Account Limit 409 Conflict – Invalid RSE Expression 409 Conflict – Replication Rule Creation Temporary Failed 409 Conflict – Invalid Rule Weight 409 Conflict – Staging Area Rule Requires Lifetime 409 Conflict – Scratch Disk Lifetime Conflict 409 Conflict – Manual Rule Approval Blocked 409 Conflict – Invalid Object
  Returns: | List of ids for created rules

`GET` `/rule/`

  Return all rules of a given account.

  Response Headers:
  | Content-Type – application/x-json-stream
  Status Codes: | 200 OK – Rule found 401 Unauthorized – Invalid Auth Token 404 Not Found – no rule found for id
  Query Parameters:
  | scope – The scope name.

`GET` `/rule/`(rule_id)`/analysis`

  get analysis for given rule.

  Response Headers:
  | Content-Type – application/x-json-stream
  Status Codes: | 200 OK – Rule found 500 Internal Server Error – Database Exception
  Returns: | JSON dict containing informations about the requested user.

`GET` `/rule/`(rule_id)`/history`

  get history for a given rule_id.

  Response Headers:
  | Content-Type – application/x-json-stream
  Status Codes: | 200 OK – Rule found 500 Internal Server Error – Database Exception
  Returns: | JSON dict containing informations about the requested user.

`POST` `/rule/`(rule_id)`/reduce`

  Reduce a replication rule.

  Status Codes: | 200 OK – Rule found. 401 Unauthorized – Invalid Auth Token. 404 Not Found – no rule found for id. 409 Conflict – Rule replace failed.
  Returns: | List of rule ids

`GET` `/rule/`(rule_id)`/locks`

  get locks for a given rule_id.

  Status Codes: | 200 OK – Rule found 500 Internal Server Error – Database Exception
  Returns: | JSON dict containing informations about the requested user.

`POST` `/rule/`(rule_id)`/mode`

  Move a replication rule.

  Status Codes: | 200 OK – Rule found 401 Unauthorized – Invalid Auth Token 404 Not Found – no rule found for id 409 Conflict – Rule replace failed.
  Returns: | List of rule ids.

`GET` `/rule/`(scope)`/`(name)`/history`

  get history for a given DID.

  Response Headers:
  | Content-Type – application/x-json-stream
  Status Codes: | 200 OK – Rule found 500 Internal Server Error – Database Exception
  Returns: | JSON dict containing informations about the requested user.

`PUT` `/rule/`(rule_id)

  Update the replication rules locked flag .

  Status Codes: | 200 OK – Rule found 401 Unauthorized – Invalid Auth Token 404 Not Found – no rule found for id

`GET` `/rule/`(rule_id)

  get rule information for given rule id.

  Returns: | JSON dict containing informations about the requested user.
  Status Codes: | 200 OK – Rule found 410 Gone – Invalid Auth Token 404 Not Found – no rule found for id

`DELETE` `/rule/`(rule_id)

  Delete a new replication rule.

  Status Codes: | 200 OK – DIDs found 401 Unauthorized – Invalid Auth Token 404 Not Found – no rule found for id