You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: modeldestroy.go
    path of file: ./repos/juju/apiserver/common
    
    the code of the file until where you have to start completion: // Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package common

import (
	"time"

	"github.com/juju/clock"
	"github.com/juju/errors"

	"github.com/juju/juju/apiserver/facades/agent/metricsender"
	"github.com/juju/juju/core/status"
	"github.com/juju/juju/state"
	stateerrors "github.com/juju/juju/state/errors"
)

var sendMetrics = func(st metricsender.ModelBackend) error {
	ccfg, err := st.ControllerConfig()
	if err != nil {
		return errors.Annotate(err, "failed to get controller config")
	}
	meteringURL := ccfg.MeteringURL()
	cfg, err := st.ModelConfig()
	if err != nil {
		return errors.Annotatef(err, "failed to get model config for %s", st.ModelTag())
	}

	err = metricsender.SendMetrics(
		st,
		metricsender.DefaultSenderFactory()(meteringURL),
		clock.WallClock,
		metricsender.DefaultMaxBatchesPerSend(),
		cfg.TransmitVendorMetrics(),
	)
	
    
func destroyModel(st ModelManagerBackend, args state.DestroyModelParams) error {
	check := NewBlockChecker(st)
	if err := check.DestroyAllowed(); err != nil {
		return errors.Trace(err)
	}

	model, err := st.Model()
	if err != nil {
		return errors.Trace(err)
	}
	notForcing := args.Force == nil || !*args.Force
	if notForcing {
		// If model status is suspended, then model's cloud credential is invalid.
		modelStatus, err := model.Status()
		if err != nil {
			return errors.Trace(err)
		}
		if modelStatus.Status == status.Suspended {
			return errors.Errorf("invalid cloud credential, use --force")
		}
	}
	if err := model.Destroy(args); err != nil {
		if notForcing {
			return errors.Trace(err)
		}
		logger.Warningf("failed destroying model %v: %v", model.UUID(), err)
		if err := filterNonCriticalErrorForForce(err); err != nil {
			return errors.Trace(err)
		}
	}

	err = sendMetrics(st)
	if err != nil {
		logger.Errorf("failed to send leftover metrics: %v", err)
	}

	// Return to the caller. If it's the CLI, it will finish up by calling the
	// provider's Destroy method, which will destroy the controllers, any
	// straggler instances, and other provider-specific resources. Once all
	// resources are torn down, the Undertaker worker handles the removal of
	// the model.
	return nil
}