runcible / lib / runcible / resources / repository_schedule.rb @ 27b106f4
1 |
require 'active_support/core_ext/hash'
|
---|---|
2 |
|
3 |
module Runcible |
4 |
module Resources |
5 |
# @see https://docs.pulpproject.org/dev-guide/integration/rest-api/repo/sync.html#scheduling-a-sync
|
6 |
class RepositorySchedule < Runcible::Base |
7 |
# Generates the API path for Repository Schedules
|
8 |
#
|
9 |
# @param [String] repo_id the ID of the repository
|
10 |
# @param [String] importer_id the ID of the importer
|
11 |
# @param [String] schedule_id the ID of the schedule
|
12 |
# @return [String] the repository schedule path, may contain the ID of the schedule if passed
|
13 |
def self.path(repo_id, importer_id, schedule_id = nil) |
14 |
repo_path = Runcible::Resources::Repository.path(repo_id) |
15 |
path = "#{repo_path}importers/#{importer_id}/schedules/sync/"
|
16 |
schedule_id.nil? ? path : "#{path}#{schedule_id}/"
|
17 |
end
|
18 |
|
19 |
# List the schedules for a repository for a given importer type
|
20 |
#
|
21 |
# @param [String] repo_id the ID of the repository
|
22 |
# @param [String] importer_type the importer type
|
23 |
# @return [RestClient::Response]
|
24 |
def list(repo_id, importer_type) |
25 |
call(:get, path(repo_id, importer_type))
|
26 |
end
|
27 |
|
28 |
# Create a schedule for a repository for a given importer type
|
29 |
#
|
30 |
# @param [String] repo_id the ID of the repository
|
31 |
# @param [String] importer_type the importer type
|
32 |
# @param [Hash] schedule a hash representing a schedule
|
33 |
# @param [Hash] optional container for all optional parameters
|
34 |
# @return [RestClient::Response]
|
35 |
def create(repo_id, importer_type, schedule, optional = {}) |
36 |
call(:post, path(repo_id, importer_type),
|
37 |
:payload => { :required => {:schedule => schedule}, :optional => optional }) |
38 |
end
|
39 |
|
40 |
# Update a schedule for a repository for a given importer type
|
41 |
#
|
42 |
# @param [String] repo_id the ID of the repository
|
43 |
# @param [String] importer_type the importer type
|
44 |
# @param [String] schedule_id the ID of the schedule
|
45 |
# @param [Hash] optional container for all optional parameters
|
46 |
# @return [RestClient::Response]
|
47 |
def update(repo_id, importer_type, schedule_id, optional = {}) |
48 |
call(:put, path(repo_id, importer_type, schedule_id),
|
49 |
:payload => {:optional => optional }) |
50 |
end
|
51 |
|
52 |
# Delete a schedule for a repository for a given importer type
|
53 |
#
|
54 |
# @param [String] repo_id the ID of the repository
|
55 |
# @param [String] importer_type the importer type
|
56 |
# @param [String] schedule_id the ID of the schedule
|
57 |
# @return [RestClient::Response]
|
58 |
def delete(repo_id, importer_type, schedule_id) |
59 |
call(:delete, path(repo_id, importer_type, schedule_id))
|
60 |
end
|
61 |
end
|
62 |
end
|
63 |
end
|