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:, attr: {}, attributes: nil, policy_version: nil, scope: nil) ⇒ ResourceQuery

Specify partial details of resources to be queried.

Parameters:

  • kind (String)

    the type of resources to be queried.

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

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

  • attributes (Attributes, Hash) (defaults to: nil)

    deprecated (use attr instead).

  • 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.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cerbos/input/resource_query.rb', line 38

def initialize(kind:, attr: {}, attributes: nil, policy_version: nil, scope: nil)
  unless attributes.nil?
    Cerbos.deprecation_warning "The `attributes` keyword argument is deprecated. Use `attr` instead."
    attr = attributes
  end

  @kind = kind
  @attr = Input.coerce_required(attr, Attributes)
  @policy_version = policy_version
  @scope = scope
end

Instance Attribute Details

#attrAttributes (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 attr
  @attr
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

Instance Method Details

#attributesAttributes

Deprecated.

Use #attr instead.

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

Returns:



54
55
56
57
# File 'lib/cerbos/input/resource_query.rb', line 54

def attributes
  Cerbos.deprecation_warning "The `attributes` method is deprecated. Use `attr` instead."
  attr
end