Project

General

Profile

Download (1.77 KB) Statistics
| Branch: | Tag: | Revision:

runcible / lib / runcible / resources / event_notifier.rb @ 27b106f4

1
module Runcible
2
  module Resources
3
    # @see https://docs.pulpproject.org/dev-guide/integration/events/index.html
4
    class EventNotifier < Runcible::Base
5
      class EventTypes
6
        REPO_SYNC_COMPLETE    = 'repo.sync.finish'.freeze
7
        REPO_SYNC_START       = 'repo.sync.start'.freeze
8
        REPO_PUBLISH_COMPLETE = 'repo.publish.finish'.freeze
9
        REPO_PUBLISH_START    = 'repo.publish.start'.freeze
10
      end
11

    
12
      class NotifierTypes
13
        REST_API = 'http'.freeze
14
      end
15

    
16
      # Generates the API path for Event Notifiers
17
      #
18
      # @param  [String]  id  the ID of the event notifier
19
      # @return [String]      the event notifier path, may contain the ID if passed
20
      def self.path(id = nil)
21
        id.nil? ? 'events/' : "events/#{id}/"
22
      end
23

    
24
      # Creates an Event Notification
25
      #
26
      # @param  [String]                notifier_type_id  the type ID of the event notifier
27
      # @param  [Hash]                  notifier_config   configuration options for the notifier
28
      # @param  [Hash]                  event_types       event types to include in the notifier
29
      # @return [RestClient::Response]
30
      def create(notifier_type_id, notifier_config, event_types)
31
        required = required_params(binding.send(:local_variables), binding)
32
        call(:post, path, :payload => {:required => required})
33
      end
34

    
35
      # Deletes an Event Notification
36
      #
37
      # @param  [String]                id  the ID of the event notifier
38
      # @return [RestClient::Response]
39
      def delete(id)
40
        call(:delete, path(id))
41
      end
42

    
43
      # List all Event Notifiers
44
      #
45
      # @param  [String]                id  the ID of the event notifier
46
      # @return [RestClient::Response]
47
      def list
48
        call(:get, path)
49
      end
50
    end
51
  end
52
end