mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Fix some CC issues
This commit is contained in:
parent
2ca9697b46
commit
d1cd0867c8
13 changed files with 72 additions and 63 deletions
|
@ -6,6 +6,13 @@ module Repp
|
|||
before_action :set_new_contact, only: [:update]
|
||||
before_action :set_domain, only: %i[index create destroy]
|
||||
|
||||
def_param_group :contacts_apidoc do
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
end
|
||||
|
||||
api :GET, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "View domain's admin and tech contacts"
|
||||
def index
|
||||
|
@ -17,11 +24,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :POST, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "Link new contact(s) to domain"
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
desc 'Link new contact(s) to domain'
|
||||
param_group :contacts_apidoc
|
||||
def create
|
||||
contact_create_params[:contacts].each { |c| c[:action] = 'add' }
|
||||
action = Actions::DomainUpdate.new(@domain, contact_create_params, current_user)
|
||||
|
@ -35,11 +39,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :DELETE, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "Remove contact(s) from domain"
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
desc 'Remove contact(s) from domain'
|
||||
param_group :contacts_apidoc
|
||||
def destroy
|
||||
contact_create_params[:contacts].each { |c| c[:action] = 'rem' }
|
||||
action = Actions::DomainUpdate.new(@domain, contact_create_params, current_user)
|
||||
|
|
|
@ -4,6 +4,13 @@ module Repp
|
|||
class DnssecController < BaseController
|
||||
before_action :set_domain, only: %i[index create destroy]
|
||||
|
||||
def_param_group :dns_keys_apidoc do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
end
|
||||
|
||||
api :GET, '/repp/v1/domains/:domain_name/dnssec'
|
||||
desc "View specific domain's DNSSEC keys"
|
||||
def index
|
||||
|
@ -15,10 +22,7 @@ module Repp
|
|||
api :POST, '/repp/v1/domains/:domain_name/dnssec'
|
||||
desc 'Create a new DNSSEC key(s) for domain'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of new DNSSEC keys' do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
param_group :dns_keys_apidoc, DnssecController
|
||||
end
|
||||
def create
|
||||
dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'add' }
|
||||
|
@ -33,11 +37,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :DELETE, 'repp/v1/domains/:domain_name/dnssec'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of removable DNSSEC keys' do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of new DNSSEC keys' do
|
||||
param_group :dns_keys_apidoc, DnssecController
|
||||
end
|
||||
def destroy
|
||||
dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'rem' }
|
||||
|
|
|
@ -4,14 +4,14 @@ module Repp
|
|||
class StatusesController < BaseController
|
||||
before_action :set_domain, only: %i[update destroy]
|
||||
before_action :verify_status
|
||||
before_action :verify_status_removal, only: [:destroy]
|
||||
before_action :verify_status_create, only: [:update]
|
||||
|
||||
api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status'
|
||||
desc 'Remove status from specific domain'
|
||||
param :domain_name, String, required: true, desc: 'Domain name'
|
||||
param :status, String, required: true, desc: 'Status to be removed'
|
||||
def destroy
|
||||
return editing_failed unless @domain.statuses.include?(params[:id])
|
||||
|
||||
@domain.statuses = @domain.statuses.delete(params[:id])
|
||||
if @domain.save
|
||||
render_success
|
||||
|
@ -25,8 +25,12 @@ module Repp
|
|||
param :domain_name, String, required: true, desc: 'Domain name'
|
||||
param :status, String, required: true, desc: 'Status to be added'
|
||||
def update
|
||||
return editing_failed if @domain.statuses.include?(params[:id])
|
||||
|
||||
@domain.statuses = @domain.statuses << params[:id]
|
||||
# rubocop:disable Style/AndOr
|
||||
handle_errors(@domain) and return unless @domain.save
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
render_success(data: { domain: @domain.name, status: params[:id] })
|
||||
end
|
||||
|
@ -39,23 +43,16 @@ module Repp
|
|||
|
||||
return if allowed_statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
@domain.add_epp_error('2306', nil, nil,
|
||||
"#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
|
||||
def verify_status_removal
|
||||
def editing_failed
|
||||
stat = params[:id]
|
||||
return if @domain.statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
|
||||
def verify_status_create
|
||||
stat = params[:id]
|
||||
return unless @domain.statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
@domain.add_epp_error('2306', nil, nil,
|
||||
"#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,8 +24,9 @@ module Repp
|
|||
private
|
||||
|
||||
def set_domain
|
||||
domain_id = transfer_params[:domain_id]
|
||||
h = {}
|
||||
h[transfer_params[:domain_id].match?(/\A[0-9]+\z/) ? :id : :name] = transfer_params[:domain_id]
|
||||
h[domain_id.match?(/\A[0-9]+\z/) ? :id : :name] = domain_id
|
||||
@domain = Epp::Domain.find_by!(h)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue