Class: UffizziCore::Api::Cli::V1::Account::CredentialsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UffizziCore::Api::Cli::V1::Account::CredentialsController
- Defined in:
- app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb
Instance Method Summary collapse
-
#check_credential ⇒ Object
Check if credential of the type already exists in the account.
-
#create ⇒ Object
Create account credential.
-
#destroy ⇒ Object
Delete account credential.
-
#index ⇒ Object
Get a list of accounts credential.
Instance Method Details
#check_credential ⇒ Object
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.account = resource_account if credential_form.valid? respond_with credential_form else respond_with credential_form.errors, status: :unprocessable_entity end end |
#create ⇒ Object
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.account = resource_account 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 |
#destroy ⇒ Object
Delete account credential
69 70 71 72 |
# File 'app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb', line 69 def destroy credential = resource_account.credentials.find_by!(type: params[:type]) credential.destroy end |
#index ⇒ Object
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 = resource_account.credentials.pluck(:type) render json: { credentials: credentials }, status: :ok end |