Class: Cerbos::Input::ResourceQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/cerbos/input/resource_query.rb

Overview

Partial details of resources to be queried.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, attributes: {}, policy_version: nil, scope: nil) ⇒ ResourceQuery

Specify partial details of resources to be queried.

Parameters:

  • kind (String)

    the type of resources to be queried.

  • attributes (Attributes, Hash) (defaults to: {})

    any application-specific attributes describing the resources to be queried that are known in advance.

  • policy_version (String, nil) (defaults to: nil)

    the policy version to use when planning the query (nil to use the Cerbos policy decision point server's configured default version).

  • scope (String, nil) (defaults to: nil)

    the policy scope to use when planning the query.


37
38
39
40
41
42
# File 'lib/cerbos/input/resource_query.rb', line 37

def initialize(kind:, attributes: {}, policy_version: nil, scope: nil)
  @kind = kind
  @attributes = Input.coerce_required(attributes, Attributes)
  @policy_version = policy_version
  @scope = scope
end

Instance Attribute Details

#attributesAttributes (readonly)

Any application-specific attributes describing the resources to be queried that are known in advance.

Returns:


15
16
17
# File 'lib/cerbos/input/resource_query.rb', line 15

def attributes
  @attributes
end

#kindString (readonly)

The type of resources to be queried.

Returns:

  • (String)

10
11
12
# File 'lib/cerbos/input/resource_query.rb', line 10

def kind
  @kind
end

#policy_versionString? (readonly)

The policy version to use when planning the query.

Returns:

  • (String)
  • (nil)

    if not provided (in which case the Cerbos policy decision point server's configured default version will be used).


21
22
23
# File 'lib/cerbos/input/resource_query.rb', line 21

def policy_version
  @policy_version
end

#scopeString? (readonly)

The policy scope to use when planning the query.

Returns:

  • (String)
  • (nil)

    if not provided.

See Also:


29
30
31
# File 'lib/cerbos/input/resource_query.rb', line 29

def scope
  @scope
end