Class: UffizziCore::Api::Cli::V1::Account::CredentialsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb

Instance Method Summary collapse

Instance Method Details

#check_credentialObject

Check if credential of the type already exists in the account



50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb', line 50

def check_credential
  credential_form = UffizziCore::Api::Cli::V1::Account::Credential::CheckCredentialForm.new
  credential_form.type = params[:type]
  credential_form. = 
  if credential_form.valid?
    respond_with credential_form
  else
    respond_with credential_form.errors, status: :unprocessable_entity
  end
end

#createObject

Create account credential



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb', line 30

def create
  credential_form = UffizziCore::Api::Cli::V1::Account::Credential::CreateForm.new
  credential_form.assign_attributes(credential_params)
  credential_form. = 
  credential_form.registry_url = registry_url(credential_form)
  credential_form.username = '_json_key' if credential_form.google?
  credential_form.activate

  UffizziCore::Account::CreateCredentialJob.perform_async(credential_form.id) if credential_form.save

  respond_with credential_form
end

#destroyObject

Delete account credential



69
70
71
72
# File 'app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb', line 69

def destroy
  credential = .credentials.find_by!(type: params[:type])
  credential.destroy
end

#indexObject

Get a list of accounts credential



12
13
14
15
16
# File 'app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb', line 12

def index
  credentials = .credentials.pluck(:type)

  render json: { credentials: credentials }, status: :ok
end