Class: Openlayer::Resources::Governance::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/openlayer/resources/governance/rules.rb,
sig/openlayer/resources/governance/rules.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Rules

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Rules.

Parameters:



235
236
237
# File 'lib/openlayer/resources/governance/rules.rb', line 235

def initialize(client:)
  @client = client
end

Instance Method Details

#create(workspace_id, name:, scope:, type:, assignee_id: nil, automation_params: nil, automation_type: nil, deactivated: nil, description: nil, evidence_type: nil, renewal_cadence_days: nil, tag_ids: nil, request_options: {}) ⇒ Openlayer::Models::Governance::RuleCreateResponse

Some parameter documentations has been truncated, see Models::Governance::RuleCreateParams for more details.

Create a governance rule in a workspace.

A rule is one requirement. Its type decides how it is satisfied, and the two types accept different fields:

  • platform rules are evaluated automatically from the state of your workspace. Set automationType to the signal to check. Their scope must be project, and evidenceType and renewalCadenceDays must be omitted or null.
  • evidence rules are satisfied by attaching evidence. Set evidenceType to the kind of evidence that satisfies them. automationType and automationParams must be omitted or null.

A new rule belongs to no framework. Map it to one from the Openlayer app.

Parameters:

  • workspace_id (String) —

    The workspace id.

  • name (String) —

    The rule name.

  • scope (Symbol, Openlayer::Models::Governance::RuleCreateParams::Scope) —

    Whether the rule is evaluated once for the whole workspace, or once per project

  • type (Symbol, Openlayer::Models::Governance::RuleCreateParams::Type) —

    platform rules are evaluated automatically from the state of your Openlayer wo

  • assignee_id (String, nil) —

    The user responsible for satisfying the rule.

  • automation_params (Hash{Symbol=>Object}, nil) —

    Configuration for the platform check, when the automation takes parameters.

  • automation_type (String, nil) —

    Which workspace signal a platform rule checks, for example `monitoring_mode_enab

  • deactivated (Boolean) —

    Whether the rule is excluded from compliance calculations.

  • description (String, nil) —

    What the rule requires.

  • evidence_type (Symbol, Openlayer::Models::Governance::RuleCreateParams::EvidenceType, nil) —

    The kind of evidence that satisfies the rule. null for platform rules.

  • renewal_cadence_days (Integer, nil) —

    How often evidence must be renewed, in days. Once evidence is older than this, t

  • tag_ids (Array<String>, nil) —

    The ids of the rule tags to associate with the rule. Replaces the rule's tags. R

  • request_options (Openlayer::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



55
56
57
58
59
60
61
62
63
64
# File 'lib/openlayer/resources/governance/rules.rb', line 55

def create(workspace_id, params)
  parsed, options = Openlayer::Governance::RuleCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["workspaces/%1$s/rules", workspace_id],
    body: parsed,
    model: Openlayer::Models::Governance::RuleCreateResponse,
    options: options
  )
end

#delete(rule_id, request_options: {}) ⇒ nil

Delete a governance rule and its rule results.

Only rules you created can be deleted. Rules that ship with Openlayer report immutable: true and cannot be deleted -- exclude one from compliance by setting deactivated with PUT /rules/{ruleId} instead.

Parameters:

Returns:

  • (nil)

See Also:



223
224
225
226
227
228
229
230
# File 'lib/openlayer/resources/governance/rules.rb', line 223

def delete(rule_id, params = {})
  @client.request(
    method: :delete,
    path: ["rules/%1$s", rule_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(workspace_id, asc: nil, assignee_id: nil, deactivated: nil, enabled_framework_only: nil, framework_id: nil, group: nil, include_results: nil, include_unframed: nil, page: nil, per_page: nil, project_id: nil, scope: nil, search_query: nil, sort_by: nil, status: nil, tags: nil, type: nil, request_options: {}) ⇒ Openlayer::Models::Governance::RuleListResponse

Some parameter documentations has been truncated, see Models::Governance::RuleListParams for more details.

List the governance rules in a workspace.

A rule is a single requirement Openlayer tracks. platform rules are evaluated automatically from the state of your workspace; evidence rules are satisfied by attaching evidence. A rule can belong to several frameworks at once, and rules that belong to none are returned too unless you pass includeUnframed=false.

Pass includeResults=true to get each rule's compliance results inline instead of fetching them separately.

Parameters:

  • workspace_id (String) —

    The workspace id.

  • asc (Boolean) —

    Whether to sort in ascending order.

  • assignee_id (String) —

    Only include rules assigned to this user.

  • deactivated (Boolean) —

    Only include rules that are deactivated (or active).

  • enabled_framework_only (Boolean) —

    Only include items belonging to at least one enabled framework.

  • framework_id (String) —

    Only include items belonging to this framework.

  • group (Symbol, Openlayer::Models::Governance::RuleListParams::Group) —

    Only include rules in one bucket of the compliance workflow. open covers rules

  • include_results (Boolean) —

    Whether to include each rule's results inline, in a results array.

  • include_unframed (Boolean) —

    Whether to include rules that are not part of any framework.

  • page (Integer) —

    The page to return in a paginated query.

  • per_page (Integer) —

    Maximum number of items to return per page.

  • project_id (String) —

    Only include items that apply to this project.

  • scope (Symbol, Openlayer::Models::Governance::RuleListParams::Scope) —

    Only include rules with this scope.

  • search_query (String) —

    Filter by a free-text search over names and descriptions.

  • sort_by (Symbol, Openlayer::Models::Governance::RuleListParams::SortBy) —

    The field to sort on.

  • status (Symbol, Openlayer::Models::Governance::RuleListParams::Status) —

    Only include items whose rule result has this compliance status.

  • tags (Array<String>) —

    Only include rules carrying all of these rule tags. Pass tag ids, which you can

  • type (Symbol, Openlayer::Models::Governance::RuleListParams::Type) —

    Only include rules of this type.

  • request_options (Openlayer::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/openlayer/resources/governance/rules.rb', line 186

def list(workspace_id, params = {})
  parsed, options = Openlayer::Governance::RuleListParams.dump_request(params)
  query = Openlayer::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["workspaces/%1$s/rules", workspace_id],
    query: query.transform_keys(
      assignee_id: "assigneeId",
      enabled_framework_only: "enabledFrameworkOnly",
      framework_id: "frameworkId",
      include_results: "includeResults",
      include_unframed: "includeUnframed",
      per_page: "perPage",
      project_id: "projectId",
      search_query: "searchQuery",
      sort_by: "sortBy"
    ),
    model: Openlayer::Models::Governance::RuleListResponse,
    options: options
  )
end

#retrieve(rule_id, request_options: {}) ⇒ Openlayer::Models::Governance::RuleRetrieveResponse

Retrieve a governance rule by its id, including the frameworks it belongs to and its tags.

Parameters:

Returns:

See Also:



78
79
80
81
82
83
84
85
# File 'lib/openlayer/resources/governance/rules.rb', line 78

def retrieve(rule_id, params = {})
  @client.request(
    method: :get,
    path: ["rules/%1$s", rule_id],
    model: Openlayer::Models::Governance::RuleRetrieveResponse,
    options: params[:request_options]
  )
end

#update(rule_id, assignee_id: nil, deactivated: nil, description: nil, name: nil, renewal_cadence_days: nil, tag_ids: nil, request_options: {}) ⇒ Openlayer::Models::Governance::RuleUpdateResponse

Some parameter documentations has been truncated, see Models::Governance::RuleUpdateParams for more details.

Update a governance rule. Only the fields you send are changed.

Rules that ship with Openlayer report immutable: true and cannot be edited.

A rule's scope, type, evidenceType, and automation are fixed once it exists -- create a new rule instead of converting one.

Parameters:

  • rule_id (String) —

    The rule id.

  • assignee_id (String, nil) —

    The user responsible for satisfying the rule.

  • deactivated (Boolean) —

    Whether the rule is excluded from compliance calculations.

  • description (String, nil) —

    What the rule requires.

  • name (String) —

    The rule name.

  • renewal_cadence_days (Integer, nil) —

    How often evidence must be renewed, in days. Once evidence is older than this, t

  • tag_ids (Array<String>, nil) —

    The ids of the rule tags to associate with the rule. Replaces the rule's tags. R

  • request_options (Openlayer::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



118
119
120
121
122
123
124
125
126
127
# File 'lib/openlayer/resources/governance/rules.rb', line 118

def update(rule_id, params = {})
  parsed, options = Openlayer::Governance::RuleUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["rules/%1$s", rule_id],
    body: parsed,
    model: Openlayer::Models::Governance::RuleUpdateResponse,
    options: options
  )
end