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 = {}) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)

    New rule



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

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

#delete_rule(project_id, rule_id) ⇒ Hashie::Mash

Delete an existing rule project

Parameters:

  • project_id (Integer)

    Id The project id

  • rule_id (Integer)

    Id The rule id

Returns:

  • (Hashie::Mash)

    Deleted rule



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

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

#get_rule(project_id, rule_id) ⇒ Hashie::Mash

Get a specific rule in project

Parameters:

  • project_id (Integer)

    id The id of project

  • rule_id (Integer)

    id The id of rule

Returns:

  • (Hashie::Mash)

    Specific rule



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

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

#rules(project_id, opts = {}) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)

    All rules in project



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

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

#update_rule(project_id, rule_id, opts = {}) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)

    Updated rule



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

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