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: app_device.go
    path of file: ./repos/heketi/apps/glusterfs
    
    the code of the file until where you have to start completion: //
// Copyright (c) 2015 The heketi Authors
//
// This file is licensed to you under your choice of the GNU Lesser
// General Public License, version 3 or any later version (LGPLv3 or
// later), or the GNU General Public License, version 2 (GPLv2), in all
// cases as published by the Free Software Foundation.
//

package glusterfs

import (
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/boltdb/bolt"
	"github.com/gorilla/mux"

	"github.com/heketi/heketi/v10/executors"
	wdb "github.com/heketi/heketi/v10/pkg/db"
	"github.com/heketi/heketi/v10/pkg/glusterfs/api"
	"github.com/heketi/heketi/v10/pkg/utils"
)

func (a *App) DeviceAdd(w http.ResponseWriter, r *http.Request) {

	var msg api.DeviceAddRequest
	err := utils.GetJsonFromRequest(r, &msg)
	if err != nil {
		http.Error(w, "request unable to be parsed", 422)
		return
	}

	err = msg.Validate()
	if err != nil {
		http.Error(w, "validation failed: "+err.Error(), http.StatusBadRequest)
		logger.LogError("validation failed: " + err.Error())
		return
	}

	// Check the message has devices
	if msg.Name == "" {
		http.Error(w, "no devices added", http.StatusBadRequest)
		return
	}

	// Create device entry
	device := 
    
func allowDestroyDevice(db wdb.RODB, e error) error {
	if derr, ok := e.(*executors.DeviceNotAvailableErr); ok {
		if !derr.ConnectionOk {
			// device status could not be checked. deny destroy
			return derr
		}
		if derr.CurrentMeta == nil {
			// device was checked but is not a Physical Volume. is ok to wipe.
			return nil
		}
		pvmap, dcount, err := allDevicePvUUID(db)
		if err != nil {
			logger.LogError("failed to read PV UUIDs from db: %v", err)
			// db lookups failed. deny
			return derr
		}
		if len(pvmap) != dcount {
			logger.Warning(
				"devices without PV UUIDs detected (found %v uuids, %v devices)",
				len(pvmap), dcount)
			// can't check all devices (backwards compat old devices). deny
			return fmt.Errorf(
				"Can not destroy device, destroy may not be safe: %v",
				derr)
		}
		if deviceId, found := pvmap[derr.CurrentMeta.UUID]; found {
			logger.Warning(
				"device uuid %v already tracked as %v",
				derr.CurrentMeta.UUID, deviceId)
			return fmt.Errorf(
				"Device already in use (ID: %v)",
				deviceId)
		}
		// it has lvm metadata but not (this) heketi's. ok to wipe
		// destroydata is really never safe, but this is what we allowed
		// prior to the new approach to devices, so whatever. :-\
		return nil
	}
	// not an expected error type. better safe than sorry, deny destroy
	return e
}