Class: HTTPClients::AccessioningNotificationClient

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/http_clients/accessioning_notification_client.rb

Overview

Uploads accessioning failure notifications to the Integration Hub for emailing to users.

Usage:

```rb
sample = Sample.last
message = "Accessioning failed due to XYZ reason"
failure_groups = ['Internal validation failure', 'ENA validation failure'] # can be any consistent values

client = HTTPClients::AccessioningNotificationClient.new
client.create_notification(sample, message, failure_groups)
````

API documentation: https://integration-hub.sanger.ac.uk/docs/notification-api/how-to-use/#invoking-the-api

Configuration options (see config/config.rb):

configatron .integration_hub .auth_token_url .base_url .accession .notifications .client_id .client_secret .recipient .template_id .notification_type .content_type

Constant Summary collapse

NOTIFICATIONS_URL =
'/notifications/v1'
PRIORITY =
'BATCH'
SUBJECT =
'Accessioning Failure Notification'

Instance Method Summary collapse

Instance Method Details

#connObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/http_clients/accessioning_notification_client.rb', line 38

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#create_notification(sample, message, failure_groups) ⇒ String

Creates a notification in the Integration Hub for a given sample, message, and failure groups.

Parameters:

  • sample (Sample)

    The sample associated with the notification.

  • message (String)

    The message to include in the notification.

  • failure_groups (Array<String>)

    An array of failure group names to include in the notification summary.

Returns:

  • (String)

    The ID of the created notification if successful.

Raises:

  • (Faraday::Error)

    If the HTTP request fails.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/http_clients/accessioning_notification_client.rb', line 56

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end