Create default roles and filters Deprecated

POST /groups/{groupId}/apps/{appId}/services/{serviceId}/default_rule

Create default roles and filters for a data source.

Path parameters

application/json

Body Required

A default rule configuration object.

  • roles array[object]

    An ordered list of default user roles.

    Hide roles attributes Show roles attributes object
    • document_filters object
      Hide document_filters attributes Show document_filters attributes object
      • read
        One of:

        A rule expression that evaluates to true if the role can read the document.

        A rule expression that evaluates to true if the role can read the document.

      • write
        One of:

        A rule expression that evaluates to true if the role can write to the document.

        A rule expression that evaluates to true if the role can write to the document.

    • name string

      The role's name.

    • apply_when
      One of:

      A rule expression that evaluates to true when this role applies to a user for a specific document.

      A rule expression that evaluates to true when this role applies to a user for a specific document.

    • read
      One of:

      A rule expression that evaluates to true if the role has permission to read all fields in the document. If Device Sync is enabled, use document_filters.read instead.

      A rule expression that evaluates to true if the role has permission to read all fields in the document. If Device Sync is enabled, use document_filters.read instead.

    • write
      One of:

      A rule expression that evaluates to true if the role has permission to add, modify, or remove all fields in the document. If Device Sync is enabled, use document_filters.write instead.

      A rule expression that evaluates to true if the role has permission to add, modify, or remove all fields in the document. If Device Sync is enabled, use document_filters.write instead.

    • insert
      One of:

      A rule expression that evaluates to true if the role has permission to insert a new document into the collection.

      A rule expression that evaluates to true if the role has permission to insert a new document into the collection.

    • delete
      One of:

      A rule expression that evaluates to true if the role has permission to delete a document from the collection.

      A rule expression that evaluates to true if the role has permission to delete a document from the collection.

    • fields object

      Field-level rules for any fields that are not explicitly configured in the role's properties.

    • additional_fields object

      Field-level rules for any fields that are not explicitly configured in the role's properties.

      Hide additional_fields attributes Show additional_fields attributes object
      • read
        One of:

        A rule expression that evaluates to true if the role can read the field's value.

        A rule expression that evaluates to true if the role can read the field's value.

      • write
        One of:

        A rule expression that evaluates to true if the role can write the field's value.

        A rule expression that evaluates to true if the role can write the field's value.

  • filters array[object]

    A list of default query filters.

    Hide filters attributes Show filters attributes object

    A filter that conditionally modifies incoming query operations before they run.

    • name string

      The filter's name.

    • apply_when
      One of:

      A rule expression that evaluates to true if the filter applies to an incoming query.

      A rule expression that evaluates to true if the filter applies to an incoming query.

    • query object

      A MongoDB query object that is merged into an incoming query before the operation runs.

    • projection object

      A MongoDB projection object that is merged into an incoming query before the operation runs.

      Hide projection attribute Show projection attribute object
      • * number Additional properties

        Values are 0 or 1.

Responses

  • 201 application/json

    Created default rule.

    Hide response attributes Show response attributes object
    • _id string

      The default rule's unique ObjectId identifier.

    • roles array[object]

      An ordered list of default user roles.

      Hide roles attributes Show roles attributes object
      • _id string

        The role's unique ObjectId identifier.

      • document_filters object
        Hide document_filters attributes Show document_filters attributes object
        • read
          One of:

          A rule expression that evaluates to true if the role can read the document.

          A rule expression that evaluates to true if the role can read the document.

        • write
          One of:

          A rule expression that evaluates to true if the role can write to the document.

          A rule expression that evaluates to true if the role can write to the document.

      • name string

        The role's name.

      • apply_when
        One of:

        A rule expression that evaluates to true when this role applies to a user for a specific document.

        A rule expression that evaluates to true when this role applies to a user for a specific document.

      • read
        One of:

        A rule expression that evaluates to true if the role has permission to read all fields in the document. If Device Sync is enabled, use document_filters.read instead.

        A rule expression that evaluates to true if the role has permission to read all fields in the document. If Device Sync is enabled, use document_filters.read instead.

      • write
        One of:

        A rule expression that evaluates to true if the role has permission to add, modify, or remove all fields in the document. If Device Sync is enabled, use document_filters.write instead.

        A rule expression that evaluates to true if the role has permission to add, modify, or remove all fields in the document. If Device Sync is enabled, use document_filters.write instead.

      • insert
        One of:

        A rule expression that evaluates to true if the role has permission to insert a new document into the collection.

        A rule expression that evaluates to true if the role has permission to insert a new document into the collection.

      • delete
        One of:

        A rule expression that evaluates to true if the role has permission to delete a document from the collection.

        A rule expression that evaluates to true if the role has permission to delete a document from the collection.

      • fields object

        Field-level rules for any fields that are not explicitly configured in the role's properties.

      • additional_fields object

        Field-level rules for any fields that are not explicitly configured in the role's properties.

        Hide additional_fields attributes Show additional_fields attributes object
        • read
          One of:

          A rule expression that evaluates to true if the role can read the field's value.

          A rule expression that evaluates to true if the role can read the field's value.

        • write
          One of:

          A rule expression that evaluates to true if the role can write the field's value.

          A rule expression that evaluates to true if the role can write the field's value.

    • filters array[object]

      A list of default query filters.

      Hide filters attributes Show filters attributes object
      • _id string

        The filter's unique ObjectId identifier.

      • name string

        The filter's name.

      • apply_when
        One of:

        A rule expression that evaluates to true if the filter applies to an incoming query.

        A rule expression that evaluates to true if the filter applies to an incoming query.

      • query object

        A MongoDB query object that is merged into an incoming query before the operation runs.

      • projection object

        A MongoDB projection object that is merged into an incoming query before the operation runs.

        Hide projection attribute Show projection attribute object
        • * number Additional properties

          Values are 0 or 1.

  • 400 application/json

    Default rule already exists.

    Hide response attribute Show response attribute object
    • error string

      Value is default rule already exists.

POST /groups/{groupId}/apps/{appId}/services/{serviceId}/default_rule
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/services/{serviceId}/default_rule' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{
  "roles": [
    {
      "document_filters": {},
      "name": "string",
      "fields": {},
      "additional_fields": {}
    }
  ],
  "filters": [
    {
      "name": "string",
      "query": {},
      "projection": {
        "additionalProperty1": 0,
        "additionalProperty2": 0
      }
    }
  ]
}'
Request examples
{
  "roles": [
    {
      "document_filters": {},
      "name": "string",
      "fields": {},
      "additional_fields": {}
    }
  ],
  "filters": [
    {
      "name": "string",
      "query": {},
      "projection": {
        "additionalProperty1": 0,
        "additionalProperty2": 0
      }
    }
  ]
}
Response examples (201)
{
  "_id": "string",
  "roles": [
    {
      "_id": "string",
      "document_filters": {},
      "name": "string",
      "fields": {},
      "additional_fields": {}
    }
  ],
  "filters": [
    {
      "_id": "string",
      "name": "string",
      "query": {},
      "projection": {
        "additionalProperty1": 0,
        "additionalProperty2": 0
      }
    }
  ]
}
Response examples (400)
{
  "error": "default rule already exists"
}