Module: BWAPI::Client::Projects::Rules

Includes:
Backfill, Copy
Included in:
BWAPI::Client::Projects
Defined in:
lib/bwapi/client/projects/rules.rb,
lib/bwapi/client/projects/rules/copy.rb,
lib/bwapi/client/projects/rules/backfill.rb

Overview

Rules module for projects/rules endpoints

Defined Under Namespace

Modules: Backfill, Copy

Instance Method Summary collapse

Methods included from Copy

#create_rule_copy

Methods included from Backfill

#create_rule_backfill

Instance Method Details

#create_rule(project_id, opts = {}) ⇒ Hash

Create a new rule in project

Parameters:

  • project_id (Integer)

    The project id

  • opts (Hash) (defaults to: {})

    options Hash of parameters

Options Hash (opts):

  • id (String)

    The rule id

  • name (String)

    The name of the rule

  • filter (Hash)

    Filter object

  • scope (String)

    The scope of the rule

  • enabled (Boolean)

    If the rule is paused

  • rule (Hash)

    Rule object

  • queryName (String)

    The query name the rule is applied to

  • projectName (String)

    The project name the rule is applied to

Returns:

  • (Hash)

    New rule



44
45
46
# File 'lib/bwapi/client/projects/rules.rb', line 44

def create_rule(project_id, opts = {})
  post "projects/#{project_id}/rules", opts
end

#delete_rule(project_id, rule_id) ⇒ Hash

Delete an existing rule project

Parameters:

  • project_id (Integer)

    Id The project id

  • rule_id (Integer)

    Id The rule id

Returns:

  • (Hash)

    Deleted rule



70
71
72
# File 'lib/bwapi/client/projects/rules.rb', line 70

def delete_rule(project_id, rule_id)
  delete "projects/#{project_id}/rules/#{rule_id}"
end

#get_rule(project_id, rule_id) ⇒ Hash

Get a specific rule in project

Parameters:

  • project_id (Integer)

    id The id of project

  • rule_id (Integer)

    id The id of rule

Returns:

  • (Hash)

    Specific rule



27
28
29
# File 'lib/bwapi/client/projects/rules.rb', line 27

def get_rule(project_id, rule_id)
  get "projects/#{project_id}/rules/#{rule_id}"
end

#rules(project_id, opts = {}) ⇒ Hash

Get all rules in project

Parameters:

  • project_id (Integer)

    The id of project

  • opts (Hash) (defaults to: {})

    options Hash of parameters

Options Hash (opts):

  • nameContains (String)

    Partial name to filter by

  • getPaused (Boolean)

    Includes the paused rules if true

  • page (Integer)

    Page Number of results to retrieve

  • pageSize (Integer)

    Results per page of results

Returns:

  • (Hash)

    All rules in project



18
19
20
# File 'lib/bwapi/client/projects/rules.rb', line 18

def rules(project_id, opts = {})
  get "projects/#{project_id}/rules", opts
end

#update_rule(project_id, rule_id, opts = {}) ⇒ Hash

Update an existing rule in project

Parameters:

  • project_id (Integer)

    The project id

  • opts (Hash) (defaults to: {})

    options Hash of parameters

Options Hash (opts):

  • id (String)

    The rule id

  • name (String)

    The name of the rule

  • filter (Hash)

    Filter object

  • scope (String)

    The scope of the rule

  • enabled (Boolean)

    If the rule is paused

  • rule (Hash)

    Rule object

  • queryName (String)

    The query name the rule is applied to

  • projectName (String)

    The project name the rule is applied to

Returns:

  • (Hash)

    Updated rule



61
62
63
# File 'lib/bwapi/client/projects/rules.rb', line 61

def update_rule(project_id, rule_id, opts = {})
  put "projects/#{project_id}/rules/#{rule_id}", opts
end