func (c *SpaceController) Delete(ctx *app.DeleteSpaceContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	id, err := uuid.FromString(ctx.ID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
	}
	var resourceID string
	var permissionID string
	var policyID string
	err = application.Transactional(c.db, func(appl application.Application) error {
		// Delete associated space resource
		resource, err := appl.SpaceResources().LoadBySpace(ctx, &id)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		appl.SpaceResources().Delete(ctx, resource.ID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}

		err = appl.Spaces().Delete(ctx.Context, id)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}

		resourceID = resource.ResourceID
		permissionID = resource.PermissionID
		policyID = resource.PolicyID

		return ctx.OK([]byte{})
	})

	if err != nil {
		return err
	}
	c.resourceManager.DeleteResource(ctx, ctx.RequestData, auth.Resource{ResourceID: resourceID, PermissionID: permissionID, PolicyID: policyID})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return nil
}
// Delete runs the delete action.
Delete runs the delete action.
// Delete runs the delete action .
func (c *SpaceController) Delete(ctx *app.DeleteSpaceContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	id, err := uuid.FromString(ctx.ID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
	}
	var resourceID string
	var permissionID string
	var policyID string
	err = application.Transactional(c.db, func(appl application.Application) error {
		resource, err := appl.SpaceResources().LoadBySpace(ctx, &id)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		appl.SpaceResources().Delete(ctx, resource.ID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		err = appl.Spaces().Delete(ctx.Context, id)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		resourceID = resource.ResourceID
		permissionID = resource.PermissionID
		policyID = resource.PolicyID
		return ctx.OK([]byte{})
	})
	if err != nil {
		return err
	}
	c.resourceManager.DeleteResource(ctx, ctx.RequestData, auth.Resource{ResourceID: resourceID, PermissionID: permissionID, PolicyID: policyID})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return nil
}
func ( c * SpaceController ) Delete ( ctx * app . DeleteSpaceContext ) error { _ , err := login . ContextIdentity ( ctx ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrUnauthorized ( err . Error ( ) ) ) } id , err := uuid . FromString ( ctx . ID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrNotFound ( err . Error ( ) ) ) } var resourceID string var permissionID string var policyID string err = application . Transactional ( c . db , func ( appl application . Application ) error { resource , err := appl . SpaceResources ( ) . LoadBySpace ( ctx , & id ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } appl . SpaceResources ( ) . Delete ( ctx , resource . ID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } err = appl . Spaces ( ) . Delete ( ctx . Context , id ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } resourceID = resource . ResourceID permissionID = resource . PermissionID policyID = resource . PolicyID return ctx . OK ( [ ] byte { } ) } ) if err != nil { return err } c . resourceManager . DeleteResource ( ctx , ctx . RequestData , auth . Resource { ResourceID : resourceID , PermissionID : permissionID , PolicyID : policyID } ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } return nil }
Delete runs the delete action.
Delete runs the delete action .
// Delete associated space resource