code: func (n *NetworkServerAPI) CreateGateway(ctx context.Context, req *ns.CreateGatewayRequest) (*empty.Empty, error) {
  	if req.Gateway == nil {
  		return nil, grpc.Errorf(codes.InvalidArgument, "gateway must not be nil")
  	}
  
  	if req.Gateway.Location == nil {
  		return nil, grpc.Errorf(codes.InvalidArgument, "gateway.location must not be nil")
  	}
  
  	gw := storage.Gateway{
  		Location: storage.GPSPoint{
  			Latitude:  req.Gateway.Location.Latitude,
  			Longitude: req.Gateway.Location.Longitude,
  		},
  		Altitude: req.Gateway.Location.Altitude,
  	}
  
  	// Gateway ID
  	copy(gw.GatewayID[:], req.Gateway.Id)
  
  	// Gateway-profile ID.
  	if b := req.Gateway.GatewayProfileId; len(b) != 0 {
  		var gpID uuid.UUID
  		copy(gpID[:], b)
  		gw.GatewayProfileID = &gpID
  	}
  
  	for _, board := range req.Gateway.Boards {
  		var gwBoard storage.GatewayBoard
  
  		if b := board.FpgaId; len(b) != 0 {
  			var fpgaID lorawan.EUI64
  			copy(fpgaID[:], b)
  			gwBoard.FPGAID = &fpgaID
  		}
  
  		if b := board.FineTimestampKey; len(b) != 0 {
  			var key lorawan.AES128Key
  			copy(key[:], b)
  			gwBoard.FineTimestampKey = &key
  		}
  
  		gw.Boards = append(gw.Boards, gwBoard)
  	}
  
  	err := storage.Transaction(func(tx sqlx.Ext) error {
  		if err := storage.CreateGateway(tx, &gw); err != nil {
  			return errToRPCError(err)
  		}
  		return nil
  	})
  	if err != nil {
  		return nil, err
  	}
  
  	return &empty.Empty{}, nil
  }
docs: // CreateGateway creates the given gateway.