blob: 7a450d5bee67f72d8d6d4aa59a6ecc603a2258b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
module Groups
module SshCertificates
class DestroyService
def initialize(group, params)
@group = group
@params = params
end
def execute
ssh_certificate = group.ssh_certificates.find(params[:ssh_certificates_id])
ssh_certificate.destroy!
ServiceResponse.success
rescue ActiveRecord::RecordNotFound
ServiceResponse.error(
message: 'SSH Certificate not found',
reason: :not_found
)
rescue ActiveRecord::RecordNotDestroyed
ServiceResponse.error(
message: 'SSH Certificate could not be deleted',
reason: :method_not_allowed
)
end
private
attr_reader :group, :params
end
end
end
|