Class: Maestrano::Account::GroupsController

Inherits:
Rails::WebHookController
  • Object
show all
Defined in:
app/controllers/maestrano/account/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /maestrano/account/groups/cld-1/tenant Delete an entire group



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/maestrano/account/groups_controller.rb', line 4

def destroy
  # id
  org_uid = params[:id]

  # Get entity
  organization = Maestrano::Connector::Rails::Organization.find_by(uid: org_uid, tenant: params[:tenant] || 'default')

  unless organization
    Maestrano::Connector::Rails::ConnectorLogger.log('info', nil, 'Organization not found')
    return render json: {success: true}, status: :no_content
  end

  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'delete organization')

  # Delete all relations
  organization.user_organization_rels.delete_all

  # Delete the organization
  organization.destroy

  # Respond
  render json: {success: true}
end